Rev 3021: Revert now resolves conflicts recursively (#102739) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Nov 23 21:35:06 GMT 2007


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

------------------------------------------------------------
revno: 3021
revision-id:pqm at pqm.ubuntu.com-20071123213500-mrqqeapz0f1mcfs3
parent: pqm at pqm.ubuntu.com-20071123184413-m5uanmtvxcllbjee
parent: abentley at panoramicfeedback.com-20071123205907-zbes1t0jx2a3lefe
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-11-23 21:35:00 +0000
message:
  Revert now resolves conflicts recursively (#102739)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/conflicts.py            conflicts.py-20051001061850-78ef952ba63d2b42
  bzrlib/tests/test_conflicts.py test_conflicts.py-20051006031059-e2dad9bbeaa5891f
  bzrlib/tests/test_workingtree.py testworkingtree.py-20051004024258-b88d0fe8f101d468
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
    ------------------------------------------------------------
    revno: 3017.2.2
    revision-id:abentley at panoramicfeedback.com-20071123205907-zbes1t0jx2a3lefe
    parent: abentley at panoramicfeedback.com-20071123201957-xntyi59nfugfz2u1
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: revert
    timestamp: Fri 2007-11-23 15:59:07 -0500
    message:
      Add docstring to resolve
    modified:
      bzrlib/conflicts.py            conflicts.py-20051001061850-78ef952ba63d2b42
    ------------------------------------------------------------
    revno: 3017.2.1
    revision-id:abentley at panoramicfeedback.com-20071123201957-xntyi59nfugfz2u1
    parent: pqm at pqm.ubuntu.com-20071123053719-gxfu09uacv4heh6w
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: revert
    timestamp: Fri 2007-11-23 15:19:57 -0500
    message:
      Revert now resolves conflicts recursively (#102739)
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/conflicts.py            conflicts.py-20051001061850-78ef952ba63d2b42
      bzrlib/tests/test_conflicts.py test_conflicts.py-20051006031059-e2dad9bbeaa5891f
      bzrlib/tests/test_workingtree.py testworkingtree.py-20051004024258-b88d0fe8f101d468
      bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'NEWS'
--- a/NEWS	2007-11-23 18:44:13 +0000
+++ b/NEWS	2007-11-23 21:35:00 +0000
@@ -60,6 +60,9 @@
    * ``commit`` is now able to invoke an external editor in a non-ascii
      directory. (Daniel Watkins, #84043)
 
+   * Conflicts are now resolved recursively by ``revert``.
+     (Aaron Bentley, #102739)
+
    * Detect invalid transport reuse attempts by catching invalid URLs.
      (Vincent Ladeuil, #161819)
 

=== modified file 'bzrlib/conflicts.py'
--- a/bzrlib/conflicts.py	2007-07-23 14:27:42 +0000
+++ b/bzrlib/conflicts.py	2007-11-23 20:59:07 +0000
@@ -117,7 +117,19 @@
                 resolve(tree, file_list)
 
 
-def resolve(tree, paths=None, ignore_misses=False):
+def resolve(tree, paths=None, ignore_misses=False, recursive=False):
+    """Resolve some or all of the conflicts in a working tree.
+
+    :param paths: If None, resolve all conflicts.  Otherwise, select only
+        specified conflicts.
+    :param recursive: If True, then elements of paths which are directories
+        have all their children resolved, etc.  When invoked as part of
+        recursive commands like revert, this should be True.  For commands
+        or applications wishing finer-grained control, like the resolve
+        command, this should be False.
+    :ignore_misses: If False, warnings will be printed if the supplied paths
+        do not have conflicts.
+    """
     tree.lock_tree_write()
     try:
         tree_conflicts = tree.conflicts()
@@ -126,7 +138,8 @@
             selected_conflicts = tree_conflicts
         else:
             new_conflicts, selected_conflicts = \
-                tree_conflicts.select_conflicts(tree, paths, ignore_misses)
+                tree_conflicts.select_conflicts(tree, paths, ignore_misses,
+                    recursive)
         try:
             tree.set_conflicts(new_conflicts)
         except errors.UnsupportedOperation:

=== modified file 'bzrlib/tests/test_conflicts.py'
--- a/bzrlib/tests/test_conflicts.py	2007-07-23 14:51:48 +0000
+++ b/bzrlib/tests/test_conflicts.py	2007-11-23 20:19:57 +0000
@@ -20,10 +20,19 @@
 from bzrlib import bzrdir
 from bzrlib.tests import TestCaseWithTransport, TestCase
 from bzrlib.branch import Branch
-from bzrlib.conflicts import (MissingParent, ContentsConflict, TextConflict,
-        PathConflict, DuplicateID, DuplicateEntry, ParentLoop, UnversionedParent,
-        ConflictList, 
-        restore)
+from bzrlib.conflicts import (
+    ConflictList,
+    ContentsConflict,
+    DuplicateID,
+    DuplicateEntry,
+    MissingParent,
+    ParentLoop,
+    PathConflict,
+    TextConflict,
+    UnversionedParent,
+    resolve,
+    restore,
+    )
 from bzrlib.errors import NotConflicted
 
 
@@ -115,6 +124,18 @@
                          tree_conflicts.select_conflicts(tree, ['foo'],
                                                          ignore_misses=True))
 
+    def test_resolve_conflicts_recursive(self):
+        tree = self.make_branch_and_tree('.')
+        self.build_tree(['dir/', 'dir/hello'])
+        tree.add(['dir', 'dir/hello'])
+        tree.set_conflicts(ConflictList([TextConflict('dir/hello')]))
+        resolve(tree, ['dir'], recursive=False, ignore_misses=True)
+        self.assertEqual(ConflictList([TextConflict('dir/hello')]),
+                         tree.conflicts())
+        resolve(tree, ['dir'], recursive=True, ignore_misses=True)
+        self.assertEqual(ConflictList([]),
+                         tree.conflicts())
+
 
 class TestConflictStanzas(TestCase):
 

=== modified file 'bzrlib/tests/test_workingtree.py'
--- a/bzrlib/tests/test_workingtree.py	2007-11-01 21:02:36 +0000
+++ b/bzrlib/tests/test_workingtree.py	2007-11-23 20:19:57 +0000
@@ -309,6 +309,25 @@
         self.assertEqual(['t', 'u', 't', 'u'], tree._locks)
 
 
+class TestRevert(TestCaseWithTransport):
+
+    def test_revert_conflicts_recursive(self):
+        this_tree = self.make_branch_and_tree('this-tree')
+        self.build_tree_contents([('this-tree/foo/',),
+                                  ('this-tree/foo/bar', 'bar')])
+        this_tree.add(['foo', 'foo/bar'])
+        this_tree.commit('created foo/bar')
+        other_tree = this_tree.bzrdir.sprout('other-tree').open_workingtree()
+        self.build_tree_contents([('other-tree/foo/bar', 'baz')])
+        other_tree.commit('changed bar')
+        self.build_tree_contents([('this-tree/foo/bar', 'qux')])
+        this_tree.commit('changed qux')
+        this_tree.merge_from_branch(other_tree.branch)
+        self.assertEqual(1, len(this_tree.conflicts()))
+        this_tree.revert(['foo'])
+        self.assertEqual(0, len(this_tree.conflicts()))
+
+
 class TestAutoResolve(TestCaseWithTransport):
 
     def test_auto_resolve(self):

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2007-11-19 22:54:30 +0000
+++ b/bzrlib/workingtree.py	2007-11-23 20:19:57 +0000
@@ -1982,7 +1982,7 @@
                 self.set_parent_trees(parent_trees)
                 resolve(self)
             else:
-                resolve(self, filenames, ignore_misses=True)
+                resolve(self, filenames, ignore_misses=True, recursive=True)
         finally:
             if basis_tree is not None:
                 basis_tree.unlock()




More information about the bazaar-commits mailing list