~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Martin Packman
  • Date: 2012-01-05 09:50:04 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6426.
  • Revision ID: martin.packman@canonical.com-20120105095004-mia9xb7y0efmto0v
Merge bzr.dev to resolve conflicts in bzrlib.builtins

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# TODO: 'bzr resolve' should accept a directory name and work from that
18
18
# point down
19
19
 
 
20
from __future__ import absolute_import
 
21
 
20
22
import os
21
23
 
22
24
from bzrlib.lazy_import import lazy_import
32
34
    transform,
33
35
    workingtree,
34
36
    )
 
37
from bzrlib.i18n import gettext, ngettext
35
38
""")
36
39
from bzrlib import (
37
40
    commands,
79
82
 
80
83
 
81
84
resolve_action_registry.register(
82
 
    'done', 'done', 'Marks the conflict as resolved' )
 
85
    'done', 'done', 'Marks the conflict as resolved.')
83
86
resolve_action_registry.register(
84
87
    'take-this', 'take_this',
85
 
    'Resolve the conflict preserving the version in the working tree' )
 
88
    'Resolve the conflict preserving the version in the working tree.')
86
89
resolve_action_registry.register(
87
90
    'take-other', 'take_other',
88
 
    'Resolve the conflict taking the merged version into account' )
 
91
    'Resolve the conflict taking the merged version into account.')
89
92
resolve_action_registry.default_key = 'done'
90
93
 
91
94
class ResolveActionOption(option.RegistryOption):
120
123
    def run(self, file_list=None, all=False, action=None, directory=None):
121
124
        if all:
122
125
            if file_list:
123
 
                raise errors.BzrCommandError("If --all is specified,"
124
 
                                             " no FILE may be provided")
 
126
                raise errors.BzrCommandError(gettext("If --all is specified,"
 
127
                                             " no FILE may be provided"))
125
128
            if directory is None:
126
129
                directory = u'.'
127
130
            tree = workingtree.WorkingTree.open_containing(directory)[0]
145
148
            if file_list is None:
146
149
                un_resolved, resolved = tree.auto_resolve()
147
150
                if len(un_resolved) > 0:
148
 
                    trace.note('%d conflict(s) auto-resolved.', len(resolved))
149
 
                    trace.note('Remaining conflicts:')
 
151
                    trace.note(ngettext('%d conflict auto-resolved.',
 
152
                        '%d conflicts auto-resolved.', len(resolved)),
 
153
                        len(resolved))
 
154
                    trace.note(gettext('Remaining conflicts:'))
150
155
                    for conflict in un_resolved:
151
156
                        trace.note(unicode(conflict))
152
157
                    return 1
153
158
                else:
154
 
                    trace.note('All conflicts resolved.')
 
159
                    trace.note(gettext('All conflicts resolved.'))
155
160
                    return 0
156
161
            else:
157
162
                # FIXME: This can never occur but the block above needs some
160
165
                pass
161
166
        else:
162
167
            before, after = resolve(tree, file_list, action=action)
163
 
            trace.note('%d conflict(s) resolved, %d remaining'
164
 
                       % (before - after, after))
 
168
            trace.note(ngettext('{0} conflict resolved, {1} remaining',
 
169
                                '{0} conflicts resolved, {1} remaining',
 
170
                                before-after).format(before - after, after))
165
171
 
166
172
 
167
173
def resolve(tree, paths=None, ignore_misses=False, recursive=False,