Rev 5759: (jameinel) WT._observed_sha1() will update the sha1, packed_stat, in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Apr 5 16:05:00 UTC 2011


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5759 [merge]
revision-id: pqm at pqm.ubuntu.com-20110405160457-sat8n5qv2lmscjoo
parent: pqm at pqm.ubuntu.com-20110405144726-zi3lj2kwvjml4kx5
parent: john at arbash-meinel.com-20110405150200-2ji7y1m7oqbqg08q
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2011-04-05 16:04:57 +0000
message:
  (jameinel) WT._observed_sha1() will update the sha1, packed_stat,
   and st_size fields. (John A Meinel)
modified:
  bzrlib/dirstate.py             dirstate.py-20060728012006-d6mvoihjb3je9peu-1
  bzrlib/tests/test_workingtree_4.py test_workingtree_4.p-20070223025758-531n3tznl3zacv2o-1
  doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py	2011-04-05 11:10:25 +0000
+++ b/bzrlib/dirstate.py	2011-04-05 15:02:00 +0000
@@ -1745,8 +1745,8 @@
                 self._sha_cutoff_time()
             if (stat_value.st_mtime < self._cutoff_time
                 and stat_value.st_ctime < self._cutoff_time):
-                entry[1][0] = ('f', sha1, entry[1][0][2], entry[1][0][3],
-                    packed_stat)
+                entry[1][0] = ('f', sha1, stat_value.st_size, entry[1][0][3],
+                               packed_stat)
                 self._dirblock_state = DirState.IN_MEMORY_MODIFIED
 
     def _sha_cutoff_time(self):

=== modified file 'bzrlib/tests/test_workingtree_4.py'
--- a/bzrlib/tests/test_workingtree_4.py	2010-07-21 09:58:42 +0000
+++ b/bzrlib/tests/test_workingtree_4.py	2011-04-05 14:00:26 +0000
@@ -597,38 +597,40 @@
 
     def get_tree_with_cachable_file_foo(self):
         tree = self.make_branch_and_tree('.')
-        self.build_tree(['foo'])
+        tree.lock_write()
+        self.addCleanup(tree.unlock)
+        self.build_tree_contents([('foo', 'a bit of content for foo\n')])
         tree.add(['foo'], ['foo-id'])
-        # a 4 second old timestamp is always hashable - sucks to delay
-        # the test suite, but not testing this is worse.
-        time.sleep(4)
+        tree.current_dirstate()._cutoff_time = time.time() + 60
         return tree
 
     def test_commit_updates_hash_cache(self):
         tree = self.get_tree_with_cachable_file_foo()
         revid = tree.commit('a commit')
         # tree's dirstate should now have a valid stat entry for foo.
-        tree.lock_read()
-        self.addCleanup(tree.unlock)
         entry = tree._get_entry(path='foo')
         expected_sha1 = osutils.sha_file_by_name('foo')
         self.assertEqual(expected_sha1, entry[1][0][1])
+        self.assertEqual(len('a bit of content for foo\n'), entry[1][0][2])
 
     def test_observed_sha1_cachable(self):
         tree = self.get_tree_with_cachable_file_foo()
         expected_sha1 = osutils.sha_file_by_name('foo')
         statvalue = os.lstat("foo")
-        tree.lock_write()
-        try:
-            tree._observed_sha1("foo-id", "foo", (expected_sha1, statvalue))
-            self.assertEqual(expected_sha1,
-                tree._get_entry(path="foo")[1][0][1])
-        finally:
-            tree.unlock()
+        tree._observed_sha1("foo-id", "foo", (expected_sha1, statvalue))
+        entry = tree._get_entry(path="foo")
+        entry_state = entry[1][0]
+        self.assertEqual(expected_sha1, entry_state[1])
+        self.assertEqual(statvalue.st_size, entry_state[2])
+        tree.unlock()
+        tree.lock_read()
         tree = tree.bzrdir.open_workingtree()
         tree.lock_read()
         self.addCleanup(tree.unlock)
-        self.assertEqual(expected_sha1, tree._get_entry(path="foo")[1][0][1])
+        entry = tree._get_entry(path="foo")
+        entry_state = entry[1][0]
+        self.assertEqual(expected_sha1, entry_state[1])
+        self.assertEqual(statvalue.st_size, entry_state[2])
 
     def test_observed_sha1_new_file(self):
         tree = self.make_branch_and_tree('.')

=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt	2011-04-05 12:25:13 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt	2011-04-05 15:02:00 +0000
@@ -78,6 +78,11 @@
   matches lstat results across all python versions.
   (John Arbash Meinel)
 
+* ``WorkingTree._observed_sha1`` also updates the 'size' column. It
+  happened to be updated as a side-effect of commit, but if we start using
+  the function elsewhere we might as well do it directly.
+  (John Arbash Meinel)
+
 Testing
 *******
 




More information about the bazaar-commits mailing list