Rev 2783: Merge reinstated sha cache support. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Tue Sep 25 06:55:01 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/repository

------------------------------------------------------------
revno: 2783
revision-id: robertc at robertcollins.net-20070925055346-pbpuxhgnnyas1i9q
parent: robertc at robertcollins.net-20070925052839-rh5bzzgqx11xds65
parent: robertc at robertcollins.net-20070925055031-ybtg84jah7lei4gc
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Tue 2007-09-25 15:53:46 +1000
message:
  Merge reinstated sha cache support.
modified:
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.38.1.1
    revision-id: robertc at robertcollins.net-20070925055031-ybtg84jah7lei4gc
    parent: robertc at robertcollins.net-20070904100858-971b6sssddwfmwrw
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: workingtree
    timestamp: Tue 2007-09-25 15:50:31 +1000
    message:
      Retrieve the sha from the dirstate for path_content_summary on hash cache hits; slight performance hit but a big win for incremental commits.
    modified:
      bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
      bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2007-09-20 22:58:47 +0000
+++ b/bzrlib/workingtree.py	2007-09-25 05:53:46 +0000
@@ -723,8 +723,8 @@
             else:
                 mode = stat_result.st_mode
                 executable = bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
-            sha1 = None # 'stat-hit-check' here
-            return (kind, size, executable, sha1)
+            return (kind, size, executable, self._sha_from_stat(
+                path, stat_result))
         elif kind == 'directory':
             # perhaps it looks like a plain directory, but it's really a
             # reference.
@@ -833,6 +833,16 @@
                 yield Stanza(file_id=file_id.decode('utf8'), hash=hash)
         self._put_rio('merge-hashes', iter_stanzas(), MERGE_MODIFIED_HEADER_1)
 
+    def _sha_from_stat(self, path, stat_result):
+        """Get a sha digest from the tree's stat cache.
+
+        The default implementation assumes no stat cache is present.
+
+        :param path: The path.
+        :param stat_result: The stat result being looked up.
+        """
+        return None
+
     def _put_rio(self, filename, stanzas, header):
         self._must_be_locked()
         my_file = rio_file(stanzas, header)

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-09-21 06:24:46 +0000
+++ b/bzrlib/workingtree_4.py	2007-09-25 05:53:46 +0000
@@ -49,7 +49,6 @@
     errors,
     generate_ids,
     globbing,
-    hashcache,
     ignores,
     merge,
     osutils,
@@ -1092,6 +1091,24 @@
         if state._dirblock_state == dirstate.DirState.IN_MEMORY_MODIFIED:
             self._make_dirty(reset_inventory=True)
 
+    def _sha_from_stat(self, path, stat_result):
+        """Get a sha digest from the tree's stat cache.
+
+        The default implementation assumes no stat cache is present.
+
+        :param path: The path.
+        :param stat_result: The stat result being looked up.
+        """
+        state = self.current_dirstate()
+        # XXX: should we make the path be passed in as utf8 ?
+        entry = state._get_entry(0, path_utf8=cache_utf8.encode(path))
+        tree_details = entry[1][0]
+        packed_stat = dirstate.pack_stat(stat_result)
+        if tree_details[4] == packed_stat:
+            return tree_details[1]
+        else:
+            return None
+
     @needs_read_lock
     def supports_tree_reference(self):
         return self._repo_supports_tree_reference



More information about the bazaar-commits mailing list