Rev 4940: (jam, in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Jan 7 17:02:54 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4940 [merge]
revision-id: pqm at pqm.ubuntu.com-20100107170244-3cgdapvuokgf8l42
parent: pqm at pqm.ubuntu.com-20100107071820-8rn58yjf0444bh5h
parent: john at arbash-meinel.com-20100107154505-wbl0vaobj01s3d76
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-01-07 17:02:44 +0000
message:
(jam,
gz) (bug #488724) Set the mtime of files touched in a TreeTransform.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
bzrlib/transform.py transform.py-20060105172343-dd99e54394d91687
=== modified file 'NEWS'
--- a/NEWS 2010-01-07 06:34:14 +0000
+++ b/NEWS 2010-01-07 17:02:44 +0000
@@ -71,6 +71,12 @@
changed underneath it (like another autopack). Now concurrent
autopackers will properly succeed. (John Arbash Meinel, #495000)
+* When operations update the working tree, all affected files should end
+ up with the same mtime. (eg. when versioning a generated file, if you
+ update the source and the generated file together, the generated file
+ should appear up-to-date.)
+ (John Arbash Meinel, Martin <gzlist>, #488724)
+
Improvements
************
=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py 2009-12-04 06:13:25 +0000
+++ b/bzrlib/tests/test_transform.py 2010-01-06 20:18:42 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2008 Canonical Ltd
+# Copyright (C) 2006, 2007, 2008, 2009, 2010 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@
import os
from StringIO import StringIO
import sys
+import time
from bzrlib import (
bencode,
@@ -136,6 +137,29 @@
transform.finalize()
transform.finalize()
+ def test_create_files_same_timestamp(self):
+ transform, root = self.get_transform()
+ self.wt.lock_tree_write()
+ self.addCleanup(self.wt.unlock)
+ # Roll back the clock, so that we know everything is being set to the
+ # exact time
+ transform._creation_mtime = creation_mtime = time.time() - 20.0
+ transform.create_file('content-one',
+ transform.create_path('one', root))
+ time.sleep(1) # *ugly*
+ transform.create_file('content-two',
+ transform.create_path('two', root))
+ transform.apply()
+ fo, st1 = self.wt.get_file_with_stat(None, path='one', filtered=False)
+ fo.close()
+ fo, st2 = self.wt.get_file_with_stat(None, path='two', filtered=False)
+ fo.close()
+ # We only guarantee 2s resolution
+ self.assertTrue(abs(creation_mtime - st1.st_mtime) < 2.0,
+ "%s != %s within 2 seconds" % (creation_mtime, 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)
+
def test_hardlink(self):
self.requireFeature(HardlinkFeature)
transform, root = self.get_transform()
=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py 2009-12-03 05:57:41 +0000
+++ b/bzrlib/transform.py 2010-01-06 22:17:10 +0000
@@ -17,6 +17,7 @@
import os
import errno
from stat import S_ISREG, S_IEXEC
+import time
from bzrlib.lazy_import import lazy_import
lazy_import(globals(), """
@@ -1023,6 +1024,7 @@
self._limbo_children_names = {}
# List of transform ids that need to be renamed from limbo into place
self._needs_rename = set()
+ self._creation_mtime = None
def finalize(self):
"""Release the working tree lock, if held, clean up limbo dir.
@@ -1133,6 +1135,7 @@
f.writelines(contents)
finally:
f.close()
+ self._set_mtime(name)
self._set_mode(trans_id, mode_id, S_ISREG)
def _read_file_chunks(self, trans_id):
@@ -1145,6 +1148,15 @@
def _read_symlink_target(self, trans_id):
return os.readlink(self._limbo_name(trans_id))
+ def _set_mtime(self, path):
+ """All files that are created get the same mtime.
+
+ This time is set by the first object to be created.
+ """
+ if self._creation_mtime is None:
+ self._creation_mtime = time.time()
+ os.utime(path, (self._creation_mtime, self._creation_mtime))
+
def create_hardlink(self, path, trans_id):
"""Schedule creation of a hard link"""
name = self._limbo_name(trans_id)
More information about the bazaar-commits
mailing list