~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-16 01:25:46 UTC
  • mfrom: (2071 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2080.
  • Revision ID: john@arbash-meinel.com-20061016012546-d01a0740671b4d73
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
# point down
21
21
 
22
22
import os
 
23
 
 
24
from bzrlib.lazy_import import lazy_import
 
25
lazy_import(globals(), """
23
26
import errno
24
27
 
25
 
import bzrlib
26
 
from bzrlib.commands import register_command
27
 
from bzrlib.errors import BzrCommandError, NotConflicted, UnsupportedOperation
 
28
from bzrlib import (
 
29
    commands,
 
30
    errors,
 
31
    osutils,
 
32
    rio,
 
33
    )
 
34
""")
28
35
from bzrlib.option import Option
29
 
from bzrlib.osutils import rename, delete_any
30
 
from bzrlib.rio import Stanza
31
36
 
32
37
 
33
38
CONFLICT_SUFFIXES = ('.THIS', '.BASE', '.OTHER')
34
39
 
35
40
 
36
 
class cmd_conflicts(bzrlib.commands.Command):
 
41
class cmd_conflicts(commands.Command):
37
42
    """List files with conflicts.
38
43
 
39
44
    Merge will do its best to combine the changes in two branches, but there
55
60
            print conflict
56
61
 
57
62
 
58
 
class cmd_resolve(bzrlib.commands.Command):
 
63
class cmd_resolve(commands.Command):
59
64
    """Mark a conflict as resolved.
60
65
 
61
66
    Merge will do its best to combine the changes in two branches, but there
76
81
        from bzrlib.workingtree import WorkingTree
77
82
        if all:
78
83
            if file_list:
79
 
                raise BzrCommandError("If --all is specified, no FILE may be provided")
 
84
                raise errors.BzrCommandError("If --all is specified,"
 
85
                                             " no FILE may be provided")
80
86
            tree = WorkingTree.open_containing('.')[0]
81
87
            resolve(tree)
82
88
        else:
83
89
            if file_list is None:
84
 
                raise BzrCommandError("command 'resolve' needs one or more FILE, or --all")
 
90
                raise errors.BzrCommandError("command 'resolve' needs one or"
 
91
                                             " more FILE, or --all")
85
92
            tree = WorkingTree.open_containing(file_list[0])[0]
86
93
            to_resolve = [tree.relpath(p) for p in file_list]
87
94
            resolve(tree, to_resolve)
99
106
                tree_conflicts.select_conflicts(tree, paths, ignore_misses)
100
107
        try:
101
108
            tree.set_conflicts(new_conflicts)
102
 
        except UnsupportedOperation:
 
109
        except errors.UnsupportedOperation:
103
110
            pass
104
111
        selected_conflicts.remove_files(tree)
105
112
    finally:
113
120
    """
114
121
    conflicted = False
115
122
    try:
116
 
        rename(filename + ".THIS", filename)
 
123
        osutils.rename(filename + ".THIS", filename)
117
124
        conflicted = True
118
125
    except OSError, e:
119
126
        if e.errno != errno.ENOENT:
131
138
        if e.errno != errno.ENOENT:
132
139
            raise
133
140
    if not conflicted:
134
 
        raise NotConflicted(filename)
 
141
        raise errors.NotConflicted(filename)
135
142
 
136
143
 
137
144
class ConflictList(object):
198
205
                continue
199
206
            for suffix in CONFLICT_SUFFIXES:
200
207
                try:
201
 
                    delete_any(tree.abspath(conflict.path+suffix))
 
208
                    osutils.delete_any(tree.abspath(conflict.path+suffix))
202
209
                except OSError, e:
203
210
                    if e.errno != errno.ENOENT:
204
211
                        raise
261
268
        self.file_id = file_id
262
269
 
263
270
    def as_stanza(self):
264
 
        s = Stanza(type=self.typestring, path=self.path)
 
271
        s = rio.Stanza(type=self.typestring, path=self.path)
265
272
        if self.file_id is not None:
266
273
            s.add('file_id', self.file_id)
267
274
        return s