~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Robert Collins
  • Date: 2005-10-17 11:56:54 UTC
  • mfrom: (1185.16.59)
  • Revision ID: robertc@robertcollins.net-20051017115654-662239e1587524a8
mergeĀ fromĀ martin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
import bzrlib.status
29
29
from bzrlib.branch import Branch
30
 
from bzrlib.errors import BzrCommandError, NotConflicted
 
30
from bzrlib.errors import BzrCommandError
31
31
from bzrlib.commands import register_command
32
32
from bzrlib.workingtree import CONFLICT_SUFFIXES
33
33
 
37
37
    files.)
38
38
    """
39
39
    def run(self):
40
 
        for path in Branch.open_containing(u'.')[0].working_tree().iter_conflicts():
 
40
        for path in Branch.open_containing('.').working_tree().iter_conflicts():
41
41
            print path
42
42
 
43
43
class cmd_resolve(bzrlib.commands.Command):
44
44
    """Mark a conflict as resolved.
45
45
    """
46
 
    aliases = ['resolved']
47
46
    takes_args = ['file*']
48
47
    takes_options = ['all']
49
48
    def run(self, file_list=None, all=False):
51
50
            if not all:
52
51
                raise BzrCommandError(
53
52
                    "command 'resolve' needs one or more FILE, or --all")
54
 
            tree = Branch.open_containing(u'.')[0].working_tree()
 
53
            tree = Branch.open_containing('.').working_tree()
55
54
            file_list = list(tree.abspath(f) for f in tree.iter_conflicts())
56
55
        else:
57
56
            if all:
72
71
                    print "%s does not exist" % filename
73
72
                else:
74
73
                    print "%s is not conflicted" % filename
75
 
 
76
 
def restore(filename):
77
 
    """\
78
 
    Restore a conflicted file to the state it was in before merging.
79
 
    Only text restoration supported at present.
80
 
    """
81
 
    conflicted = False
82
 
    try:
83
 
        os.rename(filename + ".THIS", filename)
84
 
        conflicted = True
85
 
    except OSError, e:
86
 
        if e.errno != errno.ENOENT:
87
 
            raise
88
 
    try:
89
 
        os.unlink(filename + ".BASE")
90
 
        conflicted = True
91
 
    except OSError, e:
92
 
        if e.errno != errno.ENOENT:
93
 
            raise
94
 
    try:
95
 
        os.unlink(filename + ".OTHER")
96
 
        conflicted = True
97
 
    except OSError, e:
98
 
        if e.errno != errno.ENOENT:
99
 
            raise
100
 
    if not conflicted:
101
 
        raise NotConflicted(filename)