~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

Merge from mpool.

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
 
30
from bzrlib.errors import BzrCommandError, NotConflicted
31
31
from bzrlib.commands import register_command
32
32
from bzrlib.workingtree import CONFLICT_SUFFIXES
33
33
 
43
43
class cmd_resolve(bzrlib.commands.Command):
44
44
    """Mark a conflict as resolved.
45
45
    """
 
46
    aliases = ['resolved']
46
47
    takes_args = ['file*']
47
48
    takes_options = ['all']
48
49
    def run(self, file_list=None, all=False):
71
72
                    print "%s does not exist" % filename
72
73
                else:
73
74
                    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)