Rev 2518: (John Arbash Meinel) Fix bug #115947, set_state_from_inventory needs to watch out for certain paths. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Jun 8 00:35:26 BST 2007


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

------------------------------------------------------------
revno: 2518
revision-id: pqm at pqm.ubuntu.com-20070607233523-rrkkcg7n2ks0zi18
parent: pqm at pqm.ubuntu.com-20070607135016-0u2o57cfwa9ts265
parent: john at arbash-meinel.com-20070607223144-u4oljlajcvq6by2n
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-06-08 00:35:23 +0100
message:
  (John Arbash Meinel) Fix bug #115947, set_state_from_inventory needs to watch out for certain paths.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/dirstate.py             dirstate.py-20060728012006-d6mvoihjb3je9peu-1
  bzrlib/tests/test_dirstate.py  test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
    ------------------------------------------------------------
    revno: 2487.1.3
    merged: john at arbash-meinel.com-20070607223144-u4oljlajcvq6by2n
    parent: john at arbash-meinel.com-20070521113638-3gnfdxspxklyv8bb
    parent: pqm at pqm.ubuntu.com-20070607135016-0u2o57cfwa9ts265
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: dirstate_set_state_from_inv_115947
    timestamp: Thu 2007-06-07 17:31:44 -0500
    message:
      [merge] bzr.dev 2517
    ------------------------------------------------------------
    revno: 2487.1.2
    merged: john at arbash-meinel.com-20070521113638-3gnfdxspxklyv8bb
    parent: john at arbash-meinel.com-20070521112814-156v4tp2oyya2oqb
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: dirstate_set_state_from_inv_115947
    timestamp: Mon 2007-05-21 13:36:38 +0200
    message:
      Fix bug #115947, DirState.set_state_from_inventory() needs to iterate in
      the correct order when there are common prefixes.
    ------------------------------------------------------------
    revno: 2487.1.1
    merged: john at arbash-meinel.com-20070521112814-156v4tp2oyya2oqb
    parent: pqm at pqm.ubuntu.com-20070517174205-qwgn733pkui2xqr4
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: dirstate_set_state_from_inv_115947
    timestamp: Mon 2007-05-21 13:28:14 +0200
    message:
      Adding a (broken) test that set_state_from_inventory works
      when a record is deleted from a directory which has a sibling directory with a common prefix.
=== modified file 'NEWS'
--- a/NEWS	2007-06-07 12:49:00 +0000
+++ b/NEWS	2007-06-07 22:31:44 +0000
@@ -62,6 +62,10 @@
       that we can pass in the Transport that we already have.
       (John Arbash Meinel, #75721)
 
+    * ``DirState.set_state_from_inventory()`` needs to properly order
+      based on split paths, not just string paths.
+      (John Arbash Meinel, #115947)
+
     * Let TestUIFactoy encode the password prompt with its own stdout.
       (Vincent Ladeuil, #110204)
 

=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py	2007-06-06 06:07:45 +0000
+++ b/bzrlib/dirstate.py	2007-06-07 22:31:44 +0000
@@ -2007,7 +2007,8 @@
                 # both sides are dealt with, move on
                 current_old = advance(old_iterator)
                 current_new = advance(new_iterator)
-            elif new_entry_key < current_old[0]:
+            elif (new_entry_key[0].split('/') < current_old[0][0].split('/')
+                  and new_entry_key[1:] < current_old[0][1:]):
                 # new comes before:
                 # add a entry for this and advance new
                 self.update_minimal(new_entry_key, current_new_minikind,

=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py	2007-05-31 20:29:04 +0000
+++ b/bzrlib/tests/test_dirstate.py	2007-06-07 22:31:44 +0000
@@ -691,6 +691,47 @@
             # This will unlock it
             self.check_state_with_reopen(expected_result, state)
 
+    def test_set_state_from_inventory_mixed_paths(self):
+        tree1 = self.make_branch_and_tree('tree1')
+        self.build_tree(['tree1/a/', 'tree1/a/b/', 'tree1/a-b/',
+                         'tree1/a/b/foo', 'tree1/a-b/bar'])
+        tree1.lock_write()
+        try:
+            tree1.add(['a', 'a/b', 'a-b', 'a/b/foo', 'a-b/bar'],
+                      ['a-id', 'b-id', 'a-b-id', 'foo-id', 'bar-id'])
+            tree1.commit('rev1', rev_id='rev1')
+            root_id = tree1.get_root_id()
+            inv = tree1.inventory
+        finally:
+            tree1.unlock()
+        expected_result1 = [('', '', root_id, 'd'),
+                            ('', 'a', 'a-id', 'd'),
+                            ('', 'a-b', 'a-b-id', 'd'),
+                            ('a', 'b', 'b-id', 'd'),
+                            ('a/b', 'foo', 'foo-id', 'f'),
+                            ('a-b', 'bar', 'bar-id', 'f'),
+                           ]
+        expected_result2 = [('', '', root_id, 'd'),
+                            ('', 'a', 'a-id', 'd'),
+                            ('', 'a-b', 'a-b-id', 'd'),
+                            ('a-b', 'bar', 'bar-id', 'f'),
+                           ]
+        state = dirstate.DirState.initialize('dirstate')
+        try:
+            state.set_state_from_inventory(inv)
+            values = []
+            for entry in state._iter_entries():
+                values.append(entry[0] + entry[1][0][:1])
+            self.assertEqual(expected_result1, values)
+            del inv['b-id']
+            state.set_state_from_inventory(inv)
+            values = []
+            for entry in state._iter_entries():
+                values.append(entry[0] + entry[1][0][:1])
+            self.assertEqual(expected_result2, values)
+        finally:
+            state.unlock()
+
     def test_set_path_id_no_parents(self):
         """The id of a path can be changed trivally with no parents."""
         state = dirstate.DirState.initialize('dirstate')




More information about the bazaar-commits mailing list