Rev 4754: (abentley) TT.adjust_path renames limbo descendants. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Oct 16 19:04:35 BST 2009


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

------------------------------------------------------------
revno: 4754 [merge]
revision-id: pqm at pqm.ubuntu.com-20091016180433-a22cve9xzbdc0xa8
parent: pqm at pqm.ubuntu.com-20091016075934-ynnp9jfrwjr2r2wk
parent: aaron at aaronbentley.com-20091016152950-jb6385i2yxk375bi
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-10-16 19:04:33 +0100
message:
  (abentley) TT.adjust_path renames limbo descendants.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
  bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
=== modified file 'NEWS'
--- a/NEWS	2009-10-16 00:10:26 +0000
+++ b/NEWS	2009-10-16 15:25:24 +0000
@@ -22,6 +22,9 @@
 Bug Fixes
 *********
 
+* TreeTransform.adjust_path updates the limbo paths of descendants of adjusted
+  files.  (Aaron Bentley)
+
 Improvements
 ************
 

=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py	2009-10-02 05:43:41 +0000
+++ b/bzrlib/tests/test_transform.py	2009-10-16 15:25:24 +0000
@@ -369,6 +369,18 @@
         self.assertContainsRe(transform._limbo_name(first), 'new-1/file')
         self.assertNotContainsRe(transform._limbo_name(second), 'new-1/FiLe')
 
+    def test_adjust_path_updates_child_limbo_names(self):
+        tree = self.make_branch_and_tree('tree')
+        transform = TreeTransform(tree)
+        self.addCleanup(transform.finalize)
+        foo_id = transform.new_directory('foo', transform.root)
+        bar_id = transform.new_directory('bar', foo_id)
+        baz_id = transform.new_directory('baz', bar_id)
+        qux_id = transform.new_directory('qux', baz_id)
+        transform.adjust_path('quxx', foo_id, bar_id)
+        self.assertStartsWith(transform._limbo_name(qux_id),
+                              transform._limbo_name(bar_id))
+
     def test_add_del(self):
         start, root = self.get_transform()
         start.new_directory('a', root, 'a')

=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py	2009-10-02 05:43:41 +0000
+++ b/bzrlib/transform.py	2009-10-16 15:29:50 +0000
@@ -1122,6 +1122,17 @@
                 continue
             new_path = self._limbo_name(trans_id)
             os.rename(old_path, new_path)
+            for descendant in self._limbo_descendants(trans_id):
+                desc_path = self._limbo_files[descendant]
+                desc_path = new_path + desc_path[len(old_path):]
+                self._limbo_files[descendant] = desc_path
+
+    def _limbo_descendants(self, trans_id):
+        """Return the set of trans_ids whose limbo paths descend from this."""
+        descendants = set(self._limbo_children.get(trans_id, []))
+        for descendant in list(descendants):
+            descendants.update(self._limbo_descendants(descendant))
+        return descendants
 
     def create_file(self, contents, trans_id, mode_id=None):
         """Schedule creation of a new file.




More information about the bazaar-commits mailing list