Rev 2784: Retrieve the sha from the dirstate for path_content_summary on hash cache hits; slight performance hit but a big win for incremental commits. in http://people.ubuntu.com/~robertc/baz2.0/workingtree
Robert Collins
robertc at robertcollins.net
Tue Sep 25 06:50:43 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/workingtree
------------------------------------------------------------
revno: 2784
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-04 10:08:58 +0000
+++ b/bzrlib/workingtree.py 2007-09-25 05:50:31 +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-04 10:08:58 +0000
+++ b/bzrlib/workingtree_4.py 2007-09-25 05:50:31 +0000
@@ -49,7 +49,6 @@
errors,
generate_ids,
globbing,
- hashcache,
ignores,
merge,
osutils,
@@ -1098,6 +1097,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