~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: John Arbash Meinel
  • Date: 2005-11-30 15:43:57 UTC
  • mto: (1185.50.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1518.
  • Revision ID: john@arbash-meinel.com-20051130154357-614206b3a7b83cd0
Refactored bzrlib/ui.py into a module with the possibility for multiple ui forms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
# TODO: Move this into builtins
 
18
 
 
19
# TODO: 'bzr resolve' should accept a directory name and work from that 
 
20
# point down
 
21
 
 
22
# TODO: bzr revert should resolve; even when reverting the whole tree
 
23
# or particular directories
 
24
 
 
25
import os
 
26
import errno
 
27
 
17
28
import bzrlib.status
18
29
from bzrlib.branch import Branch
19
 
from bzrlib.errors import BzrCommandError
 
30
from bzrlib.errors import BzrCommandError, NotConflicted
20
31
from bzrlib.commands import register_command
21
32
from bzrlib.workingtree import CONFLICT_SUFFIXES
22
 
import os
23
 
import errno
24
33
 
25
34
class cmd_conflicts(bzrlib.commands.Command):
26
35
    """List files with conflicts.
28
37
    files.)
29
38
    """
30
39
    def run(self):
31
 
        for path in Branch.open_containing('.').working_tree().iter_conflicts():
 
40
        for path in Branch.open_containing(u'.')[0].working_tree().iter_conflicts():
32
41
            print path
33
42
 
34
 
register_command(cmd_conflicts)
35
 
 
36
43
class cmd_resolve(bzrlib.commands.Command):
37
44
    """Mark a conflict as resolved.
38
45
    """
 
46
    aliases = ['resolved']
39
47
    takes_args = ['file*']
40
48
    takes_options = ['all']
41
49
    def run(self, file_list=None, all=False):
43
51
            if not all:
44
52
                raise BzrCommandError(
45
53
                    "command 'resolve' needs one or more FILE, or --all")
46
 
            tree = Branch.open_containing('.').working_tree()
 
54
            tree = Branch.open_containing(u'.')[0].working_tree()
47
55
            file_list = list(tree.abspath(f) for f in tree.iter_conflicts())
48
56
        else:
49
57
            if all:
64
72
                    print "%s does not exist" % filename
65
73
                else:
66
74
                    print "%s is not conflicted" % filename
67
 
                        
68
 
register_command(cmd_resolve)
 
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)