[patch] handle 'bzr resolve' in subdirectory

Martin Pool mbp at sourcefrog.net
Wed Apr 12 07:06:21 BST 2006


On 12/04/2006, at 3:36 PM, Martin Pool wrote:

>
> On 12/04/2006, at 2:43 PM, Martin Pool wrote:
>
>> This fixes a bug I saw the other day: if you're in e.g. bzrlib and  
>> type
>> "bzr resolve branch.py" it doesn't work.  As you might expect it  
>> was not
>> calling relpath() at the right time.
>
> Actually this was not very good, updated patch coming soon.

--- ../bzr.dev/bzrlib/conflicts.py      2006-04-11 11:53:54.000000000  
+1000
+++ bzrlib/conflicts.py 2006-04-12 15:35:24.000000000 +1000
@@ -54,6 +54,7 @@
          for conflict in wt.conflicts():
              print conflict

+
class cmd_resolve(bzrlib.commands.Command):
      """Mark a conflict as resolved.

@@ -73,16 +74,17 @@
      takes_options = [Option('all', help='Resolve all conflicts in  
this tree')]
      def run(self, file_list=None, all=False):
          from bzrlib.workingtree import WorkingTree
-        if file_list is None:
-            if not all:
-                raise BzrCommandError(
-                    "command 'resolve' needs one or more FILE, or -- 
all")
+        if all:
+            if file_list:
+                raise BzrCommandError("If --all is specified, no  
FILE may be provided")
+            tree = WorkingTree.open_containing('.')[0]
+            resolve(tree)
          else:
-            if all:
-                raise BzrCommandError(
-                    "If --all is specified, no FILE may be provided")
-        tree = WorkingTree.open_containing(u'.')[0]
-        resolve(tree, file_list)
+            if file_list is None:
+                raise BzrCommandError("command 'resolve' needs one  
or more FILE, or --all")
+            tree = WorkingTree.open_containing(file_list[0])[0]
+            to_resolve = [tree.relpath(p) for p in file_list]
+            resolve(tree, to_resolve)


def resolve(tree, paths=None, ignore_misses=False):
@@ -133,7 +135,10 @@


class ConflictList(object):
-    """List of conflicts
+    """List of conflicts.
+
+    Typically obtained from WorkingTree.conflicts()
+
      Can be instantiated from stanzas or from Conflict subclasses.
      """

@@ -144,6 +149,9 @@
          else:
              self.__list = conflicts

+    def is_empty(self):
+        return len(self.__list) == 0
+
      def __len__(self):
          return len(self.__list)



-- 
Martin







More information about the bazaar mailing list