Rev 4539: (robertc) Fix bugs 187207, in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jul 16 00:13:59 BST 2009


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

------------------------------------------------------------
revno: 4539 [merge]
revision-id: pqm at pqm.ubuntu.com-20090715231357-3abvg8h62kjh3zak
parent: pqm at pqm.ubuntu.com-20090715201337-pujob8s96drd11p3
parent: robertc at robertcollins.net-20090715221323-blvetujtylg8ut3g
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-07-16 00:13:57 +0100
message:
  (robertc) Fix bugs 187207,
  	282402 - small but annoying bugs in commit. (Robert Collins
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
  bzrlib/tests/per_workingtree/test_commit.py test_commit.py-20060421013633-1610ec2331c8190f
  bzrlib/tests/per_workingtree/test_unversion.py test_unversion.py-20060907074408-bygh2y28jz8u0cg7-1
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== modified file 'NEWS'
--- a/NEWS	2009-07-15 19:06:39 +0000
+++ b/NEWS	2009-07-15 23:13:57 +0000
@@ -25,6 +25,15 @@
 * BranchBuilder now accepts timezone to avoid test failures in countries far
   from GMT. (Vincent Ladeuil, #397716)
 
+* ``bzr commit`` no longer saves the unversioning of missing files until
+  the commit has completed on the branch. This means that aborting a
+  commit that found a missing file will leave the tree unedited.
+  (Robert Collins, #282402)
+
+* ``WorkingTree4.unversion`` will no longer fail to unversion ids which
+  were present in a parent tree but renamed in the working tree.
+  (Robert Collins, #187207)
+
 Improvements
 ************
 

=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py	2009-06-15 19:04:38 +0000
+++ b/bzrlib/commit.py	2009-07-15 05:54:37 +0000
@@ -204,6 +204,7 @@
         """Commit working copy as a new revision.
 
         :param message: the commit message (it or message_callback is required)
+        :param message_callback: A callback: message = message_callback(cmt_obj)
 
         :param timestamp: if not None, seconds-since-epoch for a
             postdated/predated commit.
@@ -392,7 +393,10 @@
             # and now do the commit locally.
             self.branch.set_last_revision_info(new_revno, self.rev_id)
 
-            # Make the working tree up to date with the branch
+            # Make the working tree be up to date with the branch. This
+            # includes automatic changes scheduled to be made to the tree, such
+            # as updating its basis and unversioning paths that were missing.
+            self.work_tree.unversion(self.deleted_ids)
             self._set_progress_stage("Updating the working tree")
             self.work_tree.update_basis_by_delta(self.rev_id,
                  self.builder.get_basis_delta())
@@ -679,7 +683,7 @@
                             reporter.snapshot_change('modified', new_path)
             self._next_progress_entry()
         # Unversion IDs that were found to be deleted
-        self.work_tree.unversion(deleted_ids)
+        self.deleted_ids = deleted_ids
 
     def _record_unselected(self):
         # If specific files are selected, then all un-selected files must be
@@ -842,7 +846,7 @@
                 content_summary)
 
         # Unversion IDs that were found to be deleted
-        self.work_tree.unversion(deleted_ids)
+        self.deleted_ids = deleted_ids
 
     def _commit_nested_tree(self, file_id, path):
         "Commit a nested tree."

=== modified file 'bzrlib/tests/per_workingtree/test_commit.py'
--- a/bzrlib/tests/per_workingtree/test_commit.py	2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_workingtree/test_commit.py	2009-07-15 05:54:37 +0000
@@ -280,6 +280,15 @@
         wt2.merge_from_branch(wt.branch)
         wt2.commit('merged kind change')
 
+    def test_commit_aborted_does_not_apply_automatic_changes_bug_282402(self):
+        wt = self.make_branch_and_tree('.')
+        wt.add(['a'], ['a-id'], ['file'])
+        def fail_message(obj):
+            raise errors.BzrCommandError("empty commit message")
+        self.assertRaises(errors.BzrCommandError, wt.commit,
+            message_callback=fail_message)
+        self.assertEqual('a', wt.id2path('a-id'))
+
     def test_local_commit_ignores_master(self):
         # a --local commit does not require access to the master branch
         # at all, or even for it to exist.

=== modified file 'bzrlib/tests/per_workingtree/test_unversion.py'
--- a/bzrlib/tests/per_workingtree/test_unversion.py	2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_workingtree/test_unversion.py	2009-07-15 04:33:14 +0000
@@ -37,6 +37,20 @@
         tree = self.make_branch_and_tree('.')
         self.assertRaises(errors.NoSuchId, tree.unversion, ['missing-id'])
 
+    def test_unversion_parent_and_child_renamed_bug_187207(self):
+        # When unversioning dirstate trees show a bug in dealing with
+        # unversioning children of reparented children of unversioned
+        # paths when relocation entries are present and the relocation
+        # points later into the dirstate.
+        tree = self.make_branch_and_tree(['.'])
+        self.build_tree(['del/', 'del/sub/', 'del/sub/b'])
+        tree.add(['del', 'del/sub', 'del/sub/b'], ['del', 'sub', 'b'])
+        tree.commit('setup')
+        tree.rename_one('del/sub', 'sub')
+        self.assertEqual('sub/b', tree.id2path('b'))
+        tree.unversion(['del', 'b'])
+        self.assertRaises(errors.NoSuchId, tree.id2path, 'b')
+
     def test_unversion_several_files(self):
         """After unversioning several files, they should not be versioned."""
         tree = self.make_branch_and_tree('.')

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2009-07-06 07:51:29 +0000
+++ b/bzrlib/workingtree_4.py	2009-07-15 04:33:14 +0000
@@ -1195,13 +1195,16 @@
                 # just forget the whole block.
                 entry_index = 0
                 while entry_index < len(block[1]):
-                    # Mark this file id as having been removed
                     entry = block[1][entry_index]
-                    ids_to_unversion.discard(entry[0][2])
-                    if (entry[1][0][0] in 'ar' # don't remove absent or renamed
-                                               # entries
-                        or not state._make_absent(entry)):
+                    if entry[1][0][0] in 'ar':
+                        # don't remove absent or renamed entries
                         entry_index += 1
+                    else:
+                        # Mark this file id as having been removed
+                        ids_to_unversion.discard(entry[0][2])
+                        if not state._make_absent(entry):
+                            # The block has not shrunk.
+                            entry_index += 1
                 # go to the next block. (At the moment we dont delete empty
                 # dirblocks)
                 block_index += 1




More information about the bazaar-commits mailing list