/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: Jelmer Vernooij
  • Date: 2018-04-02 00:52:27 UTC
  • mfrom: (6939 work)
  • mto: This revision was merged to the branch mainline in revision 7274.
  • Revision ID: jelmer@jelmer.uk-20180402005227-pecflp1mvdjrjqd6
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
    option,
43
43
    registry,
44
44
    )
 
45
from .sixish import text_type
45
46
 
46
47
 
47
48
CONFLICT_SUFFIXES = ('.THIS', '.BASE', '.OTHER')
76
77
                    continue
77
78
                self.outf.write(conflict.path + '\n')
78
79
            else:
79
 
                self.outf.write(unicode(conflict) + '\n')
 
80
                self.outf.write(text_type(conflict) + '\n')
80
81
 
81
82
 
82
83
resolve_action_registry = registry.Registry()
154
155
                        len(resolved))
155
156
                    trace.note(gettext('Remaining conflicts:'))
156
157
                    for conflict in un_resolved:
157
 
                        trace.note(unicode(conflict))
 
158
                        trace.note(text_type(conflict))
158
159
                    return 1
159
160
                else:
160
161
                    trace.note(gettext('All conflicts resolved.'))
186
187
        paths do not have conflicts.
187
188
    :param action: How the conflict should be resolved,
188
189
    """
189
 
    tree.lock_tree_write()
190
190
    nb_conflicts_after = None
191
 
    try:
 
191
    with tree.lock_tree_write():
192
192
        tree_conflicts = tree.conflicts()
193
193
        nb_conflicts_before = len(tree_conflicts)
194
194
        if paths is None:
208
208
            tree.set_conflicts(new_conflicts)
209
209
        except errors.UnsupportedOperation:
210
210
            pass
211
 
    finally:
212
 
        tree.unlock()
213
211
    if nb_conflicts_after is None:
214
212
        nb_conflicts_after = nb_conflicts_before
215
213
    return nb_conflicts_before, nb_conflicts_after
298
296
    def to_strings(self):
299
297
        """Generate strings for the provided conflicts"""
300
298
        for conflict in self:
301
 
            yield unicode(conflict)
 
299
            yield text_type(conflict)
302
300
 
303
301
    def remove_files(self, tree):
304
302
        """Remove the THIS, BASE and OTHER files for listed conflicts"""
371
369
        self.path = path
372
370
        # the factory blindly transfers the Stanza values to __init__ and
373
371
        # Stanza is purely a Unicode api.
374
 
        if isinstance(file_id, unicode):
 
372
        if isinstance(file_id, text_type):
375
373
            file_id = cache_utf8.encode(file_id)
376
374
        self.file_id = osutils.safe_file_id(file_id)
377
375
 
515
513
            raise AssertionError('bad winner: %r' % (winner,))
516
514
        if path_to_create is not None:
517
515
            tid = tt.trans_id_tree_path(path_to_create)
 
516
            tree = self._revision_tree(tt._tree, revid)
518
517
            transform.create_from_tree(
519
 
                tt, tid, self._revision_tree(tt._tree, revid), file_id)
 
518
                tt, tid, tree, tree.id2path(file_id), file_id=file_id)
520
519
            tt.version_file(file_id, tid)
521
520
        else:
522
521
            tid = tt.trans_id_file_id(file_id)
716
715
        self.conflict_path = conflict_path
717
716
        # the factory blindly transfers the Stanza values to __init__,
718
717
        # so they can be unicode.
719
 
        if isinstance(conflict_file_id, unicode):
 
718
        if isinstance(conflict_file_id, text_type):
720
719
            conflict_file_id = cache_utf8.encode(conflict_file_id)
721
720
        self.conflict_file_id = osutils.safe_file_id(conflict_file_id)
722
721