Rev 5429: Revert to 'conflict' being the default orphaning policy and fix fallouts. in file:///home/vila/src/bzr/bugs/323111-orphans/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Sep 21 17:58:50 BST 2010


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

------------------------------------------------------------
revno: 5429
revision-id: v.ladeuil+lp at free.fr-20100921165850-fkrlj18p68l7xxz4
parent: v.ladeuil+lp at free.fr-20100921145608-2c6q12x42xfksdkh
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: orphan-config-option
timestamp: Tue 2010-09-21 18:58:50 +0200
message:
  Revert to 'conflict' being the default orphaning policy and fix fallouts.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2010-09-21 14:56:08 +0000
+++ b/NEWS	2010-09-21 16:58:50 +0000
@@ -27,21 +27,17 @@
 Bug Fixes
 *********
 
-* Orphan creation (when a directory is deleted) is now controlled by the
+* It's now possible to request orphan creation when a versioned directory
+  should be deleted (when doing a pull, a merge or switch) via the
   ``bzrlib.transform.orphan_policy`` configuration variable. Acceptable
-  values are ``never`` (the previous behaviour) or ``always`` to create
-  orphans when a versioned directory is deleted and contains unversioned
-  files (the orphans). (Vincent Ladeuil, #323111)
-
-Improvements
-************
-
-* 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.
+  values are ``conflict`` (the default behaviour that refuse to delete the
+  directory) or ``move`` to create orphans (the unversioned files present
+  in the directory). The orphans will name ``<file>.~#~``.
   (Vincent Ladeuil, #323111)
 
+Improvements
+************
+
 Documentation
 *************
 

=== modified file 'bzrlib/tests/per_workingtree/test_pull.py'
--- a/bzrlib/tests/per_workingtree/test_pull.py	2010-09-10 08:23:31 +0000
+++ b/bzrlib/tests/per_workingtree/test_pull.py	2010-09-21 16:58:50 +0000
@@ -91,6 +91,8 @@
                 'WorkingTreeFormat2 does not support missing parent conflicts')
         trunk = self.make_branch_deleting_dir('trunk')
         work = trunk.bzrdir.sprout('work', revision_id='2').open_workingtree()
+        work.branch.get_config().set_user_option(
+            'bzrlib.transform.orphan_policy', 'move')
         # Add some unversioned files in dir
         self.build_tree(['work/dir/foo',
                          'work/dir/subdir/',

=== modified file 'bzrlib/tests/test_bzrdir.py'
--- a/bzrlib/tests/test_bzrdir.py	2010-09-10 08:23:31 +0000
+++ b/bzrlib/tests/test_bzrdir.py	2010-09-21 16:58:50 +0000
@@ -791,6 +791,9 @@
         self.build_tree(['tree1/subtree/file'])
         sub_tree.add('file')
         tree.commit('Initial commit')
+        # The following line force the orhaning to reveal bug #634470
+        tree.branch.get_config().set_user_option(
+            'bzrlib.transform.orphan_policy', 'move')
         tree.bzrdir.destroy_workingtree()
         # FIXME: subtree/.bzr is left here which allows the test to pass (or
         # fail :-( ) -- vila 20100909

=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py	2010-09-16 16:43:05 +0000
+++ b/bzrlib/tests/test_transform.py	2010-09-21 16:58:50 +0000
@@ -2362,7 +2362,7 @@
         # parent
         self.assertLength(2, conflicts)
 
-    def test_resolve_orphan_non_versioned_file(self):
+    def test_non_versioned_file_create_conflict(self):
         wt, tt = self.make_tt_with_versioned_dir()
         dir_tid = tt.trans_id_tree_file_id('dir-id')
         tt.new_file('file', dir_tid, 'Contents')
@@ -2370,7 +2370,9 @@
         tt.unversion_file(dir_tid)
         conflicts = resolve_conflicts(tt)
         # no conflicts or rather: orphaning 'file' resolve the 'dir' conflict
-        self.assertLength(0, conflicts)
+        self.assertLength(1, conflicts)
+        self.assertEqual(('deleting parent', 'Not deleting', 'new-1'),
+                         conflicts.pop())
 
 
 A_ENTRY = ('a-id', ('a', 'a'), True, (True, True),
@@ -3284,6 +3286,7 @@
 
     def test_new_orphan_created(self):
         wt = self.make_branch_and_tree('.')
+        self._set_orphan_policy(wt, 'move')
         tt, orphan_tid = self._prepare_orphan(wt)
         remaining_conflicts = resolve_conflicts(tt)
         # Yeah for resolved conflicts !
@@ -3295,7 +3298,7 @@
 
     def test_never_orphan(self):
         wt = self.make_branch_and_tree('.')
-        self._set_orphan_policy(wt, 'never')
+        self._set_orphan_policy(wt, 'conflict')
         tt, orphan_tid = self._prepare_orphan(wt)
         remaining_conflicts = resolve_conflicts(tt)
         self.assertLength(1, remaining_conflicts)
@@ -3326,9 +3329,9 @@
             warnings.append(args[0] % args[1:])
         self.overrideAttr(trace, 'warning', warning)
         remaining_conflicts = resolve_conflicts(tt)
-        # We fallback to the default policy which resolve the conflict by
-        # creating an orphan
-        self.assertLength(0, remaining_conflicts)
-        self.assertLength(2, warnings)
-        self.assertStartsWith( warnings[0], 'donttouchmypreciouuus')
-        self.assertStartsWith(warnings[1], 'dir/foo has been orphaned')
+        # We fallback to the default policy which create a conflict
+        self.assertLength(1, remaining_conflicts)
+        self.assertEqual(('deleting parent', 'Not deleting', 'new-1'),
+                         remaining_conflicts.pop())
+        self.assertLength(1, warnings)
+        self.assertStartsWith(warnings[0], 'donttouchmypreciouuus')

=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py	2010-09-16 16:43:05 +0000
+++ b/bzrlib/transform.py	2010-09-21 16:58:50 +0000
@@ -1412,11 +1412,11 @@
 
 
 orphaning_registry = registry.Registry()
-orphaning_registry.register('always', move_orphan,
+orphaning_registry.register('conflict', refuse_orphan,
+                            'Never create orphans.')
+orphaning_registry.register('move', move_orphan,
                             'Move orphans into the bzr-orphans directory.')
-orphaning_registry._set_default_key('always')
-orphaning_registry.register('never', refuse_orphan,
-                            'Never create orphans.')
+orphaning_registry._set_default_key('conflict')
 
 
 class TreeTransform(DiskTreeTransform):

=== modified file 'doc/en/whats-new/whats-new-in-2.3.txt'
--- a/doc/en/whats-new/whats-new-in-2.3.txt	2010-09-21 14:55:22 +0000
+++ b/doc/en/whats-new/whats-new-in-2.3.txt	2010-09-21 16:58:50 +0000
@@ -64,12 +64,14 @@
 Improved conflict handling
 **************************
 
-* Deleting a versioned directory containing unversioned files will no
-  longer create a conflict. Instead, the unversioned files will be moved
-  into a 'bzr-orphans' directory at the root of the working tree.  This is
-  controlled by the ``bzrlib.transform.orphan_policy`` configuration
-  variable with a value of ``always`` (the default). The previous behaviour
-  can be restored by using the ``never`` value.  (Vincent Ladeuil, #323111)
+* ``pull``, ``merge`` or ``switch`` can lead to conflicts when deleting a
+  versioned directory contains unversioned files. This can now be avoided
+  by setting the ``bzrlib.transform.orphan_policy`` configuration variable
+  with a value of ``move``. In this case the unversioned files are moved to
+  a ``bzr-orphans`` directory at the root of the working tree. The default
+  behaviour is specified (if needed) by setting the variable to
+  ``conflict``.
+  (Vincent Ladeuil, #323111)
 
 Documentation
 *************



More information about the bazaar-commits mailing list