Rev 5420: Add NEWS entry, a missing test and some cleanup. in file:///home/vila/src/bzr/bugs/323111-orphans/

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Sep 10 09:23:32 BST 2010


At file:///home/vila/src/bzr/bugs/323111-orphans/

------------------------------------------------------------
revno: 5420
revision-id: v.ladeuil+lp at free.fr-20100910082331-poegognv5g9kqnso
parent: v.ladeuil+lp at free.fr-20100909204337-jdpaggctu2x23x5m
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: orphan-non-versioned-files
timestamp: Fri 2010-09-10 10:23:31 +0200
message:
  Add NEWS entry, a missing test and some cleanup.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2010-09-09 20:20:15 +0000
+++ b/NEWS	2010-09-10 08:23:31 +0000
@@ -197,6 +197,12 @@
   have dropped from 68 bytes to 40, and directory entries from 120 bytes
   to 48).  (Andrew Bennetts)
 
+* When a bzr command remove a previously versioned directory, all
+  unversioned files are moved to a 'bzr-orphans' directory at the working
+  tree root with backup names (<file>.~#~). This was previously creating
+  spurious conflicts during merge, pull or switch operations.
+  (Vincent Ladeuil, #323111)
+
 * When building new working trees, default to reading from the repository
   rather than the source tree unless explicitly requested. (via
   ``--files-from`` and ``--hardlink`` for ``bzr branch`` and

=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2010-09-09 13:41:52 +0000
+++ b/bzrlib/bzrdir.py	2010-09-10 08:23:31 +0000
@@ -1311,7 +1311,7 @@
         empty = repository.revision_tree(_mod_revision.NULL_REVISION)
         # We ignore the conflicts returned by wt.revert since we're about to
         # delete the wt metadata anyway, all that should be left here are
-        # detritus.
+        # detritus. But see bug #634470.
         conflicts = wt.revert(old_tree=empty)
         self.destroy_workingtree_metadata()
 

=== modified file 'bzrlib/tests/per_workingtree/test_pull.py'
--- a/bzrlib/tests/per_workingtree/test_pull.py	2010-09-07 15:48:29 +0000
+++ b/bzrlib/tests/per_workingtree/test_pull.py	2010-09-10 08:23:31 +0000
@@ -91,7 +91,11 @@
                 'WorkingTreeFormat2 does not support missing parent conflicts')
         trunk = self.make_branch_deleting_dir('trunk')
         work = trunk.bzrdir.sprout('work', revision_id='2').open_workingtree()
-        # Add an unversioned file in dir
-        self.build_tree(['work/dir/foo'])
+        # Add some unversioned files in dir
+        self.build_tree(['work/dir/foo',
+                         'work/dir/subdir/',
+                         'work/dir/subdir/foo'])
         work.pull(trunk)
         self.assertLength(0, work.conflicts())
+        # The directory removal should succeed
+        self.failIfExists('work/dir')

=== modified file 'bzrlib/tests/test_bzrdir.py'
--- a/bzrlib/tests/test_bzrdir.py	2010-09-09 13:41:52 +0000
+++ b/bzrlib/tests/test_bzrdir.py	2010-09-10 08:23:31 +0000
@@ -803,8 +803,8 @@
         # turn the line below into an assertRaises when 'subtree/.bzr' is
         # orphaned and sprout tries to access the branch there (which is left
         # by bzrdir.BzrDirMeta1.destroy_workingtree when it ignores the
-        # [DeletingParent('Not deleting', u'subtree', None)] conflict)
-        # -- vila 20100909
+        # [DeletingParent('Not deleting', u'subtree', None)] conflict). See bug
+        # #634470.  -- vila 20100909
         self.assertRaises(errors.NotBranchError,
                           tree.bzrdir.sprout, 'repo/tree2')
 #        self.failUnlessExists('repo/tree2/subtree')

=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py	2010-09-09 20:43:37 +0000
+++ b/bzrlib/tests/test_transform.py	2010-09-10 08:23:31 +0000
@@ -2375,6 +2375,7 @@
         tt.delete_contents(dir_tid)
         tt.unversion_file(dir_tid)
         conflicts = resolve_conflicts(tt)
+        # no conflicts or rather: orphaning 'file' resolve the 'dir' conflict
         self.assertLength(0, conflicts)
 
 
@@ -3262,14 +3263,33 @@
 
 class TestOrphan(tests.TestCaseWithTransport):
 
-    # - can't create oprhan dir
+    # Alternative implementations may want to test:
+    # - can't create orphan dir
     # - orphaning forbidden
     # - can't create orphan
-    # - create orphan
 
     def test_no_orphan_for_transform_preview(self):
         tree = self.make_branch_and_tree('tree')
-        tt = TransformPreview(tree)
+        tt = transform.TransformPreview(tree)
         self.addCleanup(tt.finalize)
         self.assertRaises(NotImplementedError, tt.new_orphan, 'foo', 'bar')
 
+    def test_new_orphan(self):
+        wt = self.make_branch_and_tree('.')
+        self.build_tree(['dir/', 'dir/foo'])
+        wt.add(['dir'], ['dir-id'])
+        wt.commit('add dir')
+        tt = transform.TreeTransform(wt)
+        self.addCleanup(tt.finalize)
+        dir_tid = tt.trans_id_tree_path('dir')
+        foo_tid = tt.trans_id_tree_path('dir/foo')
+        tt.delete_contents(dir_tid)
+        tt.unversion_file(dir_tid)
+        raw_conflicts = tt.find_conflicts()
+        self.assertLength(1, raw_conflicts)
+        self.assertEqual(('missing parent', 'new-1'), raw_conflicts[0])
+        remaining_conflicts = resolve_conflicts(tt)
+        # Yeah for resolved conflicts !
+        self.assertLength(0, remaining_conflicts)
+        # We have a new orphan
+        self.assertEndsWith('foo.~1~', tt.final_name(foo_tid))



More information about the bazaar-commits mailing list