Rev 2506: Fix workingtree.remove with tree references in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Jun 4 20:45:41 BST 2007


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

------------------------------------------------------------
revno: 2506
revision-id: pqm at pqm.ubuntu.com-20070604194535-ihhpf84qp0icoj2t
parent: pqm at pqm.ubuntu.com-20070604062925-0a2e6fvr3qpfngzo
parent: abentley at panoramicfeedback.com-20070604185921-xbnqxwypl1junwy3
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2007-06-04 20:45:35 +0100
message:
  Fix workingtree.remove with tree references
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/workingtree_implementations/test_remove.py test_remove.py-20070413183901-rvnp85rtc0q0sclp-1
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.16
    merged: abentley at panoramicfeedback.com-20070604185921-xbnqxwypl1junwy3
    parent: abentley at panoramicfeedback.com-20070524153619-o4ici00lpcmbshiw
    parent: pqm at pqm.ubuntu.com-20070604062925-0a2e6fvr3qpfngzo
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Mon 2007-06-04 14:59:21 -0400
    message:
      Merge bzr.dev
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.15
    merged: abentley at panoramicfeedback.com-20070524153619-o4ici00lpcmbshiw
    parent: abentley at panoramicfeedback.com-20070524150452-sifbv1wlrjnlw1zx
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Thu 2007-05-24 11:36:19 -0400
    message:
      Remove redundant listdir
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.14
    merged: abentley at panoramicfeedback.com-20070524150452-sifbv1wlrjnlw1zx
    parent: abentley at panoramicfeedback.com-20070524150356-218vhkzsxubtzikd
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Thu 2007-05-24 11:04:52 -0400
    message:
      Add NEWS entry
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.13
    merged: abentley at panoramicfeedback.com-20070524150356-218vhkzsxubtzikd
    parent: abentley at panoramicfeedback.com-20070524150109-is07n3xarwa63736
    parent: pqm at pqm.ubuntu.com-20070524130959-7zpl03vgx35bezhf
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Thu 2007-05-24 11:03:56 -0400
    message:
      Merge bzr.dev
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.12
    merged: abentley at panoramicfeedback.com-20070524150109-is07n3xarwa63736
    parent: aaron.bentley at utoronto.ca-20070524121941-p1ch5bu1bvm6qn72
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Thu 2007-05-24 11:01:09 -0400
    message:
      Stop using inventory directly in WorkingTree.remove
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.11
    merged: aaron.bentley at utoronto.ca-20070524121941-p1ch5bu1bvm6qn72
    parent: aaron.bentley at utoronto.ca-20070523113246-8z2a83w2qxnhxxr8
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: Aaron's mergeable stuff
    timestamp: Thu 2007-05-24 08:19:41 -0400
    message:
      Bugfix WorkingTree.remove to handle subtrees, and non-cwd trees
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.10
    merged: aaron.bentley at utoronto.ca-20070523113246-8z2a83w2qxnhxxr8
    parent: aaron.bentley at utoronto.ca-20070521141436-x3aw0x8tksw2yu0e
    parent: pqm at pqm.ubuntu.com-20070523095110-bqaodkh3q7v0fime
    committer: Aaron Bentley <aaron.bentley at utoronto.ca>
    branch nick: Aaron's mergeable stuff
    timestamp: Wed 2007-05-23 07:32:46 -0400
    message:
      Merge bzr.dev
=== modified file 'NEWS'
--- a/NEWS	2007-06-01 23:10:18 +0000
+++ b/NEWS	2007-06-04 18:59:21 +0000
@@ -47,6 +47,9 @@
     * WorkingTree4.get_file_sha1 no longer raises an exception when invoked
       on a missing file.  (Aaron Bentley, #118186)
 
+    * WorkingTree.remove works correctly with tree references, and when pwd is
+      not the tree root. (Aaron Bentley)
+
 bzr 0.16  2007-05-07
   
   BUGFIXES:

=== modified file 'bzrlib/tests/workingtree_implementations/test_remove.py'
--- a/bzrlib/tests/workingtree_implementations/test_remove.py	2007-04-18 20:12:15 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_remove.py	2007-05-24 12:19:41 +0000
@@ -203,3 +203,18 @@
         tree.remove(TestRemove.b, keep_files=False, force=True)
         self.assertNotInWorkingTree(TestRemove.b_c)
         self.failIfExists(TestRemove.b_c)
+
+    def test_remove_subtree(self):
+        tree = self.make_branch_and_tree('.')
+        subtree = self.make_branch_and_tree('subtree')
+        tree.add('subtree', 'subtree-id')
+        tree.remove('subtree')
+        self.assertIs(None, tree.path2id('subtree'))
+
+    def test_non_cwd(self):
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree(['tree/dir/', 'tree/dir/file'])
+        tree.add(['dir', 'dir/file'])
+        tree.commit('add file')
+        tree.remove('dir/', keep_files=False)
+        self.failIfExists('tree/dir/file')

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2007-05-02 14:54:20 +0000
+++ b/bzrlib/workingtree.py	2007-05-24 15:36:19 +0000
@@ -1775,7 +1775,7 @@
         if isinstance(files, basestring):
             files = [files]
 
-        inv = self.inventory
+        inv_delta = []
 
         new_files=set()
         unknown_files_in_directory=set()
@@ -1783,22 +1783,24 @@
         def recurse_directory_to_add_files(directory):
             # recurse directory and add all files
             # so we can check if they have changed.
-            for contained_dir_info in self.walkdirs(directory):
-                for file_info in contained_dir_info[1]:
-                    if file_info[2] == 'file':
-                        relpath = self.relpath(file_info[0])
-                        if file_info[4]: #is it versioned?
+            for parent_info, file_infos in\
+                osutils.walkdirs(self.abspath(directory),
+                    directory):
+                for relpath, basename, kind, lstat, abspath in file_infos:
+                    if kind == 'file':
+                        if self.path2id(relpath): #is it versioned?
                             new_files.add(relpath)
                         else:
                             unknown_files_in_directory.add(
-                                (relpath, None, file_info[2]))
+                                (relpath, None, kind))
 
         for filename in files:
             # Get file name into canonical form.
-            filename = self.relpath(self.abspath(filename))
+            abspath = self.abspath(filename)
+            filename = self.relpath(abspath)
             if len(filename) > 0:
                 new_files.add(filename)
-                if osutils.isdir(filename) and len(os.listdir(filename)) > 0:
+                if osutils.isdir(abspath):
                     recurse_directory_to_add_files(filename)
         files = [f for f in new_files]
 
@@ -1818,7 +1820,7 @@
 
         # do this before any modifications
         for f in files:
-            fid = inv.path2id(f)
+            fid = self.path2id(f)
             message=None
             if not fid:
                 message="%s is not versioned." % (f,)
@@ -1829,10 +1831,10 @@
                         new_status = 'I'
                     else:
                         new_status = '?'
-                    textui.show_status(new_status, inv[fid].kind, f,
+                    textui.show_status(new_status, self.kind(fid), f,
                                        to_file=to_file)
                 # unversion file
-                del inv[fid]
+                inv_delta.append((f, None, fid, None))
                 message="removed %s" % (f,)
 
             if not keep_files:
@@ -1852,7 +1854,7 @@
             # print only one message (if any) per file.
             if message is not None:
                 note(message)
-        self._write_inventory(inv)
+        self.apply_inventory_delta(inv_delta)
 
     @needs_tree_write_lock
     def revert(self, filenames, old_tree=None, backups=True, 




More information about the bazaar-commits mailing list