Rev 4538: Instrument dirstate.set_state_from_inventory. in http://bazaar.launchpad.net/~lifeless/bzr/bug-395556

Robert Collins robertc at robertcollins.net
Thu Jul 16 01:01:25 BST 2009


At http://bazaar.launchpad.net/~lifeless/bzr/bug-395556

------------------------------------------------------------
revno: 4538
revision-id: robertc at robertcollins.net-20090716000117-u7kc320lzvg5tbaa
parent: robertc at robertcollins.net-20090715011320-coi9b5psw5d3tr2r
committer: Robert Collins <robertc at robertcollins.net>
branch nick: bug-395556
timestamp: Thu 2009-07-16 10:01:17 +1000
message:
  Instrument dirstate.set_state_from_inventory.
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py	2009-07-15 01:13:20 +0000
+++ b/bzrlib/dirstate.py	2009-07-16 00:01:17 +0000
@@ -2423,6 +2423,9 @@
         if 'evil' in debug.debug_flags:
             trace.mutter_callsite(1,
                 "set_state_from_inventory called; please mutate the tree instead")
+        tracing = 'dirstate' in debug.debug_flags
+        if tracing:
+            trace.mutter("set_state_from_inventory trace:")
         self._read_dirblocks_if_needed()
         # sketch:
         # Two iterators: current data and new data, both in dirblock order.
@@ -2441,7 +2444,7 @@
         # more complex. Using a shallow copy results in all entries being seen
         # but the state of the entries being wrong, and that leads to stale
         # entries being left behind.
-        old_iterator = iter(deepcopy(list(self._iter_entries())))
+        old_iterator = iter(list(self._iter_entries()))
         # both must have roots so this is safe:
         current_new = new_iterator.next()
         current_old = old_iterator.next()
@@ -2480,12 +2483,19 @@
             # we make both end conditions explicit
             if not current_old:
                 # old is finished: insert current_new into the state.
+                if tracing:
+                    trace.mutter("Appending from new '%s'.",
+                        new_path_utf8.decode('utf8'))
                 self.update_minimal(new_entry_key, current_new_minikind,
                     executable=current_new[1].executable,
                     path_utf8=new_path_utf8, fingerprint=fingerprint)
                 current_new = advance(new_iterator)
             elif not current_new:
                 # new is finished
+                if tracing:
+                    trace.mutter("Truncating from old '%s/%s'.",
+                        current_old[0][0].decode('utf'),
+                        current_old[0][1].decode('utf8'))
                 self._make_absent(current_old)
                 current_old = advance(old_iterator)
             elif new_entry_key == current_old[0]:
@@ -2498,6 +2508,9 @@
                 # kind has changed.
                 if (current_old[1][0][3] != current_new[1].executable or
                     current_old[1][0][0] != current_new_minikind):
+                    if tracing:
+                        trace.mutter("Updating in-place change '%s'.",
+                            new_path_utf8.decode('utf8'))
                     self.update_minimal(current_old[0], current_new_minikind,
                         executable=current_new[1].executable,
                         path_utf8=new_path_utf8, fingerprint=fingerprint)
@@ -2509,6 +2522,9 @@
                       and new_entry_key[1:] < current_old[0][1:])):
                 # new comes before:
                 # add a entry for this and advance new
+                if tracing:
+                    trace.mutter("Inserting from new '%s'.",
+                        new_path_utf8.decode('utf8'))
                 self.update_minimal(new_entry_key, current_new_minikind,
                     executable=current_new[1].executable,
                     path_utf8=new_path_utf8, fingerprint=fingerprint)
@@ -2516,11 +2532,17 @@
             else:
                 # we've advanced past the place where the old key would be,
                 # without seeing it in the new list.  so it must be gone.
+                if tracing:
+                    trace.mutter("Deleting from old '%s/%s'.",
+                        current_old[0][0].decode('utf'),
+                        current_old[0][1].decode('utf8'))
                 self._make_absent(current_old)
                 current_old = advance(old_iterator)
         self._dirblock_state = DirState.IN_MEMORY_MODIFIED
         self._id_index = None
         self._packed_stat_index = None
+        if tracing:
+            trace.mutter("set_state_from_inventory complete.")
 
     def _make_absent(self, current_old):
         """Mark current_old - an entry - as absent for tree 0.

=== modified file 'bzrlib/help_topics/en/debug-flags.txt'
--- a/bzrlib/help_topics/en/debug-flags.txt	2009-07-06 09:47:35 +0000
+++ b/bzrlib/help_topics/en/debug-flags.txt	2009-07-16 00:01:17 +0000
@@ -5,6 +5,7 @@
 prefix) put in the ``debug_flags`` variable in ``bazaar.conf``.
 
 -Dauth            Trace authentication sections used.
+-Ddirstate        Trace dirstate activity (verbose!)
 -Derror           Instead of normal error handling, always print a traceback
                   on error.
 -Devil            Capture call sites that do expensive or badly-scaling




More information about the bazaar-commits mailing list