Rev 22: Start working on the log file. in lp:~jameinel/+junk/file_locking
John Arbash Meinel
john at arbash-meinel.com
Mon Sep 21 21:19:57 BST 2009
At lp:~jameinel/+junk/file_locking
------------------------------------------------------------
revno: 22
revision-id: john at arbash-meinel.com-20090921201949-sj8qm5wm6ahbemnu
parent: john at arbash-meinel.com-20090921200915-w15tstoyu4rtki3m
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: file_locking
timestamp: Mon 2009-09-21 15:19:49 -0500
message:
Start working on the log file.
-------------- next part --------------
=== modified file 'file_lock.py'
--- a/file_lock.py 2009-09-21 20:09:15 +0000
+++ b/file_lock.py 2009-09-21 20:19:49 +0000
@@ -258,7 +258,17 @@
# Instead of having a separate 'format' file, we put the data into
# the 'info' file. Which means that we have 1 less object to read
# from remote.
- transport.put_bytes('info', bytes)
+ transport.put_bytes_non_atomic('info', bytes)
+ global_conf = _mod_config.GlobalConfig()
+ stanza = rio.Stanza()
+ stanza.add('action', 'Lock Store created')
+ t = int(time.time())
+ stanza.add('time', str(t))
+ stanza.add('date', osutils.format_date(t,
+ offset=osutils.local_time_offset()))
+ stanza.add('user', global_conf.username())
+ stanza.add('host', osutils.get_host_name())
+ transport.put_bytes_non_atomic('log', stanza.to_string())
store = cls(transport, locking_info, lock)
except:
lock.unlock()
=== modified file 'tests/test_file_lock.py'
--- a/tests/test_file_lock.py 2009-09-21 20:09:15 +0000
+++ b/tests/test_file_lock.py 2009-09-21 20:19:49 +0000
@@ -17,6 +17,7 @@
"""Tests for cooperative file locking."""
import os
+import re
from bzrlib import (
errors,
@@ -312,9 +313,16 @@
self.addCleanup(fls.unlock)
self.assertIsInstance(fls, file_lock.FileLockStore)
self.assertEqual(trans, fls._transport)
- self.assertEqual(['README.txt', 'info', 'lock'],
+ self.assertEqual(['README.txt', 'info', 'lock', 'log'],
sorted(trans.list_dir('')))
self.assertIsInstance(fls._locking_info, file_lock.FileLockingInfo)
+ log_bytes = trans.get_bytes('log')
+ self.assertContainsRe(log_bytes,
+ 'action: Lock Store created\n'
+ 'time: \\d+\n'
+ 'date: .*\n'
+ 'user: .*\n'
+ 'host: .*\n', flags=re.MULTILINE)
def test_open_not_there(self):
trans = self.get_transport('lock-store')
More information about the bazaar-commits
mailing list