/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/conflicts.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
    Use brz resolve when you have fixed a problem.
64
64
    """
65
65
    takes_options = [
66
 
            'directory',
67
 
            option.Option('text',
68
 
                          help='List paths of files with text conflicts.'),
 
66
        'directory',
 
67
        option.Option('text',
 
68
                      help='List paths of files with text conflicts.'),
69
69
        ]
70
70
    _see_also = ['resolve', 'conflict-types']
71
71
 
93
93
    'Resolve the conflict taking the merged version into account.')
94
94
resolve_action_registry.default_key = 'done'
95
95
 
 
96
 
96
97
class ResolveActionOption(option.RegistryOption):
97
98
 
98
99
    def __init__(self):
117
118
    aliases = ['resolved']
118
119
    takes_args = ['file*']
119
120
    takes_options = [
120
 
            'directory',
121
 
            option.Option('all', help='Resolve all conflicts in this tree.'),
122
 
            ResolveActionOption(),
123
 
            ]
 
121
        'directory',
 
122
        option.Option('all', help='Resolve all conflicts in this tree.'),
 
123
        ResolveActionOption(),
 
124
        ]
124
125
    _see_also = ['conflicts']
 
126
 
125
127
    def run(self, file_list=None, all=False, action=None, directory=None):
126
128
        if all:
127
129
            if file_list:
128
130
                raise errors.BzrCommandError(gettext("If --all is specified,"
129
 
                                             " no FILE may be provided"))
 
131
                                                     " no FILE may be provided"))
130
132
            if directory is None:
131
133
                directory = u'.'
132
134
            tree = workingtree.WorkingTree.open_containing(directory)[0]
151
153
                un_resolved, resolved = tree.auto_resolve()
152
154
                if len(un_resolved) > 0:
153
155
                    trace.note(ngettext('%d conflict auto-resolved.',
154
 
                        '%d conflicts auto-resolved.', len(resolved)),
155
 
                        len(resolved))
 
156
                                        '%d conflicts auto-resolved.', len(resolved)),
 
157
                               len(resolved))
156
158
                    trace.note(gettext('Remaining conflicts:'))
157
159
                    for conflict in un_resolved:
158
160
                        trace.note(text_type(conflict))
169
171
            before, after = resolve(tree, file_list, action=action)
170
172
            trace.note(ngettext('{0} conflict resolved, {1} remaining',
171
173
                                '{0} conflicts resolved, {1} remaining',
172
 
                                before-after).format(before - after, after))
 
174
                                before - after).format(before - after, after))
173
175
 
174
176
 
175
177
def resolve(tree, paths=None, ignore_misses=False, recursive=False,
503
505
        path_to_create = None
504
506
        if winner == 'this':
505
507
            if self.path == '<deleted>':
506
 
                return # Nothing to do
 
508
                return  # Nothing to do
507
509
            if self.conflict_path == '<deleted>':
508
510
                path_to_create = self.path
509
511
                revid = tt._tree.get_parent_ids()[0]
542
544
        possible_paths = []
543
545
        for p in (self.path, self.conflict_path):
544
546
            if p == '<deleted>':
545
 
                # special hard-coded path 
 
547
                # special hard-coded path
546
548
                continue
547
549
            if p is not None:
548
550
                possible_paths.append(p)
618
620
            # deleted the file either manually or when resolving a conflict on
619
621
            # the parent.  We may raise some exception to indicate that the
620
622
            # conflict doesn't exist anymore and as such doesn't need to be
621
 
            # resolved ? -- vila 20110615 
 
623
            # resolved ? -- vila 20110615
622
624
            this_tid = None
623
625
        else:
624
626
            this_tid = tt.trans_id_tree_path(this_path)
672
674
        # Switch the paths to preserve the content
673
675
        tt.adjust_path(osutils.basename(self.path),
674
676
                       winner_parent_tid, winner_tid)
675
 
        tt.adjust_path(osutils.basename(winner_path), item_parent_tid, item_tid)
 
677
        tt.adjust_path(osutils.basename(winner_path),
 
678
                       item_parent_tid, item_tid)
676
679
        # Associate the file_id to the right content
677
680
        tt.unversion_file(item_tid)
678
681
        tt.version_file(self.file_id, winner_tid)
899
902
    for conflict_type in conflict_types:
900
903
        ctype[conflict_type.typestring] = conflict_type
901
904
 
 
905
 
902
906
register_types(ContentsConflict, TextConflict, PathConflict, DuplicateID,
903
907
               DuplicateEntry, ParentLoop, UnversionedParent, MissingParent,
904
908
               DeletingParent, NonDirectoryParent)