Rev 2431: Shave off 200+ ms of 'time bzr status' in lp tree in http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate

John Arbash Meinel john at arbash-meinel.com
Wed Feb 28 16:01:33 GMT 2007


At http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate

------------------------------------------------------------
revno: 2431
revision-id: john at arbash-meinel.com-20070228160032-nt148nm9c1rrhopj
parent: john at arbash-meinel.com-20070228154412-3pwfza0d3839qpsg
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Wed 2007-02-28 10:00:32 -0600
message:
  Shave off 200+ ms of 'time bzr status' in lp tree
  We don't need to look up source and target parents of an entry if
  we know it hasn't moved, and we already have one, then we have the other.
modified:
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
-------------- next part --------------
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-02-28 15:44:12 +0000
+++ b/bzrlib/workingtree_4.py	2007-02-28 16:00:32 +0000
@@ -1372,6 +1372,7 @@
         target.branch.repository.fetch(source.branch.repository, revid)
         target.set_parent_ids([revid])
         return target.basis_tree(), target
+
     _matching_from_tree_format = WorkingTreeFormat4()
     _matching_to_tree_format = WorkingTreeFormat4()
     _test_mutable_trees_to_test_trees = make_source_parent_tree
@@ -1597,12 +1598,26 @@
                         raise Exception, "unknown kind %s" % path_info[2]
                 # parent id is the entry for the path in the target tree
                 # TODO: the target is the same for an entire directory: cache em.
-                source_parent_id = state._get_entry(source_index, path_utf8=old_dirname)[0][2]
+                source_parent_entry = state._get_entry(source_index,
+                                                       path_utf8=old_dirname)
+                source_parent_id = source_parent_entry[0][2]
                 if source_parent_id == entry[0][2]:
+                    # This is the root, so the parent is None
                     source_parent_id = None
-                target_parent_id = state._get_entry(target_index, path_utf8=entry[0][0])[0][2]
-                if target_parent_id == entry[0][2]:
-                    target_parent_id = None
+                if (old_dirname == entry[0][0]
+                    and source_parent_entry[1][target_index][0] not in ('r', 'a')):
+                    # We don't need to do another lookup. Because we know that
+                    # the target parent is at the same path, and since the
+                    # target parent entry is not renamed or absent, that means
+                    # it is the same directory.
+                    target_parent_id = source_parent_id
+                else:
+                    target_parent_entry = state._get_entry(target_index,
+                                                           path_utf8=entry[0][0])
+                    target_parent_id = target_parent_entry[0][2]
+                    if target_parent_id == entry[0][2]:
+                        # This is the root, so the parent is None
+                        target_parent_id = None
                 source_exec = source_details[3]
                 path_unicode = path.decode('utf8')
                 return ((entry[0][2], path_unicode, content_change,



More information about the bazaar-commits mailing list