~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

(gz) Fix test failure on alpha by correcting format string for
 gc_chk_sha1_record (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
from bzrlib import (
27
27
    cleanup,
 
28
    commands,
28
29
    errors,
29
30
    osutils,
30
31
    rio,
32
33
    transform,
33
34
    workingtree,
34
35
    )
35
 
from bzrlib.i18n import gettext, ngettext
36
36
""")
37
37
from bzrlib import (
38
 
    commands,
39
38
    option,
40
39
    registry,
41
40
    )
73
72
                    continue
74
73
                self.outf.write(conflict.path + '\n')
75
74
            else:
76
 
                self.outf.write(unicode(conflict) + '\n')
 
75
                self.outf.write(str(conflict) + '\n')
77
76
 
78
77
 
79
78
resolve_action_registry = registry.Registry()
121
120
    def run(self, file_list=None, all=False, action=None, directory=None):
122
121
        if all:
123
122
            if file_list:
124
 
                raise errors.BzrCommandError(gettext("If --all is specified,"
125
 
                                             " no FILE may be provided"))
 
123
                raise errors.BzrCommandError("If --all is specified,"
 
124
                                             " no FILE may be provided")
126
125
            if directory is None:
127
126
                directory = u'.'
128
127
            tree = workingtree.WorkingTree.open_containing(directory)[0]
146
145
            if file_list is None:
147
146
                un_resolved, resolved = tree.auto_resolve()
148
147
                if len(un_resolved) > 0:
149
 
                    trace.note(ngettext('%d conflict auto-resolved.',
150
 
                        '%d conflicts auto-resolved.', len(resolved)),
151
 
                        len(resolved))
152
 
                    trace.note(gettext('Remaining conflicts:'))
 
148
                    trace.note('%d conflict(s) auto-resolved.', len(resolved))
 
149
                    trace.note('Remaining conflicts:')
153
150
                    for conflict in un_resolved:
154
 
                        trace.note(unicode(conflict))
 
151
                        trace.note(conflict)
155
152
                    return 1
156
153
                else:
157
 
                    trace.note(gettext('All conflicts resolved.'))
 
154
                    trace.note('All conflicts resolved.')
158
155
                    return 0
159
156
            else:
160
157
                # FIXME: This can never occur but the block above needs some
163
160
                pass
164
161
        else:
165
162
            before, after = resolve(tree, file_list, action=action)
166
 
            trace.note(ngettext('{0} conflict resolved, {1} remaining',
167
 
                                '{0} conflicts resolved, {1} remaining',
168
 
                                before-after).format(before - after, after))
 
163
            trace.note('%d conflict(s) resolved, %d remaining'
 
164
                       % (before - after, after))
169
165
 
170
166
 
171
167
def resolve(tree, paths=None, ignore_misses=False, recursive=False,
295
291
    def to_strings(self):
296
292
        """Generate strings for the provided conflicts"""
297
293
        for conflict in self:
298
 
            yield unicode(conflict)
 
294
            yield str(conflict)
299
295
 
300
296
    def remove_files(self, tree):
301
297
        """Remove the THIS, BASE and OTHER files for listed conflicts"""
394
390
    def __ne__(self, other):
395
391
        return not self.__eq__(other)
396
392
 
397
 
    def __unicode__(self):
 
393
    def __str__(self):
398
394
        return self.format % self.__dict__
399
395
 
400
396
    def __repr__(self):
511
507
        if path_to_create is not None:
512
508
            tid = tt.trans_id_tree_path(path_to_create)
513
509
            transform.create_from_tree(
514
 
                tt, tid, self._revision_tree(tt._tree, revid), file_id)
 
510
                tt, tt.trans_id_tree_path(path_to_create),
 
511
                self._revision_tree(tt._tree, revid), file_id)
515
512
            tt.version_file(file_id, tid)
516
 
        else:
517
 
            tid = tt.trans_id_file_id(file_id)
 
513
 
518
514
        # Adjust the path for the retained file id
 
515
        tid = tt.trans_id_file_id(file_id)
519
516
        parent_tid = tt.get_tree_parent(tid)
520
517
        tt.adjust_path(osutils.basename(path), parent_tid, tid)
521
518
        tt.apply()
586
583
        :param tt: The TreeTransform where the conflict is resolved.
587
584
        :param suffix_to_remove: Either 'THIS' or 'OTHER'
588
585
 
589
 
        The resolution is symmetric: when taking THIS, OTHER is deleted and
 
586
        The resolution is symmetric, when taking THIS, OTHER is deleted and
590
587
        item.THIS is renamed into item and vice-versa.
591
588
        """
592
589
        try:
599
596
            # never existed or was already deleted (including the case
600
597
            # where the user deleted it)
601
598
            pass
602
 
        try:
603
 
            this_path = tt._tree.id2path(self.file_id)
604
 
        except errors.NoSuchId:
605
 
            # The file is not present anymore. This may happen if the user
606
 
            # deleted the file either manually or when resolving a conflict on
607
 
            # the parent.  We may raise some exception to indicate that the
608
 
            # conflict doesn't exist anymore and as such doesn't need to be
609
 
            # resolved ? -- vila 20110615 
610
 
            this_tid = None
611
 
        else:
612
 
            this_tid = tt.trans_id_tree_path(this_path)
613
 
        if this_tid is not None:
614
 
            # Rename 'item.suffix_to_remove' (note that if
615
 
            # 'item.suffix_to_remove' has been deleted, this is a no-op)
616
 
            parent_tid = tt.get_tree_parent(this_tid)
617
 
            tt.adjust_path(osutils.basename(self.path), parent_tid, this_tid)
618
 
            tt.apply()
 
599
        # Rename 'item.suffix_to_remove' (note that if
 
600
        # 'item.suffix_to_remove' has been deleted, this is a no-op)
 
601
        this_tid = tt.trans_id_file_id(self.file_id)
 
602
        parent_tid = tt.get_tree_parent(this_tid)
 
603
        tt.adjust_path(osutils.basename(self.path), parent_tid, this_tid)
 
604
        tt.apply()
619
605
 
620
606
    def action_take_this(self, tree):
621
607
        self._resolve_with_cleanups(tree, 'OTHER')