/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: 2020-07-28 02:47:10 UTC
  • mfrom: (7519.1.1 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200728024710-a2ylds219f1lsl62
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/388173

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# TODO: 'brz resolve' should accept a directory name and work from that
18
18
# point down
19
19
 
20
 
from __future__ import absolute_import
21
 
 
22
20
import os
23
21
import re
24
22
 
42
40
    option,
43
41
    registry,
44
42
    )
45
 
from .sixish import text_type
46
43
 
47
44
 
48
45
CONFLICT_SUFFIXES = ('.THIS', '.BASE', '.OTHER')
77
74
                    continue
78
75
                self.outf.write(conflict.path + '\n')
79
76
            else:
80
 
                self.outf.write(text_type(conflict) + '\n')
 
77
                self.outf.write(str(conflict) + '\n')
81
78
 
82
79
 
83
80
resolve_action_registry = registry.Registry()
129
126
    def run(self, file_list=None, all=False, action=None, directory=None):
130
127
        if all:
131
128
            if file_list:
132
 
                raise errors.BzrCommandError(gettext("If --all is specified,"
 
129
                raise errors.CommandError(gettext("If --all is specified,"
133
130
                                                     " no FILE may be provided"))
134
131
            if directory is None:
135
132
                directory = u'.'
154
151
                    before - after)
155
152
                trace.note(gettext('Remaining conflicts:'))
156
153
                for conflict in tree.conflicts():
157
 
                    trace.note(text_type(conflict))
 
154
                    trace.note(str(conflict))
158
155
                return 1
159
156
            else:
160
157
                trace.note(gettext('All conflicts resolved.'))
289
286
    def to_strings(self):
290
287
        """Generate strings for the provided conflicts"""
291
288
        for conflict in self:
292
 
            yield text_type(conflict)
 
289
            yield str(conflict)
293
290
 
294
291
    def remove_files(self, tree):
295
292
        """Remove the THIS, BASE and OTHER files for listed conflicts"""
362
359
        self.path = path
363
360
        # the factory blindly transfers the Stanza values to __init__ and
364
361
        # Stanza is purely a Unicode api.
365
 
        if isinstance(file_id, text_type):
 
362
        if isinstance(file_id, str):
366
363
            file_id = cache_utf8.encode(file_id)
367
 
        self.file_id = osutils.safe_file_id(file_id)
 
364
        self.file_id = file_id
368
365
 
369
366
    def as_stanza(self):
370
367
        s = rio.Stanza(type=self.typestring, path=self.path)
459
456
        raise NotImplementedError(self.action_take_other)
460
457
 
461
458
    def _resolve_with_cleanups(self, tree, *args, **kwargs):
462
 
        with tree.get_transform() as tt:
 
459
        with tree.transform() as tt:
463
460
            self._resolve(tt, *args, **kwargs)
464
461
 
465
462
 
518
515
            tree = self._revision_tree(tt._tree, revid)
519
516
            transform.create_from_tree(
520
517
                tt, tid, tree, tree.id2path(file_id))
521
 
            tt.version_file(file_id, tid)
 
518
            tt.version_file(tid, file_id=file_id)
522
519
        else:
523
520
            tid = tt.trans_id_file_id(file_id)
524
521
        # Adjust the path for the retained file id
672
669
                       item_parent_tid, item_tid)
673
670
        # Associate the file_id to the right content
674
671
        tt.unversion_file(item_tid)
675
 
        tt.version_file(self.file_id, winner_tid)
 
672
        tt.version_file(winner_tid, file_id=self.file_id)
676
673
        tt.apply()
677
674
 
678
675
    def action_auto(self, tree):
736
733
        self.conflict_path = conflict_path
737
734
        # the factory blindly transfers the Stanza values to __init__,
738
735
        # so they can be unicode.
739
 
        if isinstance(conflict_file_id, text_type):
 
736
        if isinstance(conflict_file_id, str):
740
737
            conflict_file_id = cache_utf8.encode(conflict_file_id)
741
 
        self.conflict_file_id = osutils.safe_file_id(conflict_file_id)
 
738
        self.conflict_file_id = conflict_file_id
742
739
 
743
740
    def _cmp_list(self):
744
741
        return HandledConflict._cmp_list(self) + [self.conflict_path,
796
793
        pass
797
794
 
798
795
    def action_take_other(self, tree):
799
 
        with tree.get_transform() as tt:
 
796
        with tree.transform() as tt:
800
797
            p_tid = tt.trans_id_file_id(self.file_id)
801
798
            parent_tid = tt.get_tree_parent(p_tid)
802
799
            cp_tid = tt.trans_id_file_id(self.conflict_file_id)