Rev 4940: It turns out that with os/python/C buffering, we need to flush in http://bazaar.launchpad.net/~jameinel/bzr/2.1.0rc1-set-mtime
John Arbash Meinel
john at arbash-meinel.com
Tue Jan 5 22:13:32 GMT 2010
At http://bazaar.launchpad.net/~jameinel/bzr/2.1.0rc1-set-mtime
------------------------------------------------------------
revno: 4940
revision-id: john at arbash-meinel.com-20100105221312-ez1orftbr65ws6yd
parent: john at arbash-meinel.com-20100105214109-4jd065q8anu53r3o
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1.0rc1-set-mtime
timestamp: Tue 2010-01-05 16:13:12 -0600
message:
It turns out that with os/python/C buffering, we need to flush
Make the test compatibily with filesystems that only have 1s resolution.
Also, it seems on my Linux machine, .writelines() leaves data in buffers
that doesn't get written out until .close(). But that messes up the
timestamps. So now we call flush before we close.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py 2010-01-05 18:35:25 +0000
+++ b/bzrlib/tests/test_transform.py 2010-01-05 22:13:12 +0000
@@ -154,8 +154,10 @@
fo.close()
fo, st2 = self.wt.get_file_with_stat(None, path='two', filtered=False)
fo.close()
+ # We only guarantee 1s resolution
+ self.assertEqual(int(transform._creation_mtime), int(st1.st_mtime))
+ # But if we have more than that, all files should get the same result
self.assertEqual(st1.st_mtime, st2.st_mtime)
- self.assertEqual(transform._creation_mtime, st1.st_mtime)
def test_hardlink(self):
self.requireFeature(HardlinkFeature)
=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py 2010-01-05 21:15:22 +0000
+++ b/bzrlib/transform.py 2010-01-05 22:13:12 +0000
@@ -1133,6 +1133,10 @@
raise
f.writelines(contents)
+ # We have to flush before calling _set_mtime, otherwise buffered
+ # data can be written after we force the mtime. This shouldn't have
+ # a huge performance impact, because 'close()' will flush anyway
+ f.flush()
self._set_mtime(f)
finally:
f.close()
More information about the bazaar-commits
mailing list