~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Aaron Bentley
  • Date: 2006-04-05 20:37:37 UTC
  • mto: (2027.1.2 revert-subpath-56549)
  • mto: This revision was merged to the branch mainline in revision 1647.
  • Revision ID: abentley@panoramicfeedback.com-20060405203737-d50848ef2df7344a
Eliminated conflicts_to_strings, made remove_files a ConflictList member

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    def run(self):
52
52
        from bzrlib.workingtree import WorkingTree
53
53
        wt = WorkingTree.open_containing(u'.')[0]
54
 
        for conflict in conflicts_to_strings(wt.conflicts()):
 
54
        for conflict in wt.conflicts():
55
55
            print conflict
56
56
 
57
57
class cmd_resolve(bzrlib.commands.Command):
99
99
            tree.set_conflicts(ConflictList(new_conflicts))
100
100
        except UnsupportedOperation:
101
101
            pass
102
 
        remove_conflict_files(tree, selected_conflicts)
 
102
        selected_conflicts.remove_files(tree)
103
103
    finally:
104
104
        tree.unlock()
105
105
 
146
146
                print "%s does not exist" % path
147
147
            else:
148
148
                print "%s is not conflicted" % path
149
 
    return new_conflicts, selected_conflicts
 
149
    return ConflictList(new_conflicts), ConflictList(selected_conflicts)
150
150
 
151
 
def remove_conflict_files(tree, conflicts):
152
 
    for stanza in conflicts.to_stanzas():
153
 
        if stanza['type'] in ("text conflict", "contents conflict"):
154
 
            for suffix in CONFLICT_SUFFIXES:
155
 
                try:
156
 
                    os.unlink(tree.abspath(stanza['path']+suffix))
157
 
                except OSError, e:
158
 
                    if e.errno != errno.ENOENT:
159
 
                        raise
160
151
    
161
152
 
162
153
def restore(filename):
233
224
        for conflict in self:
234
225
            yield conflict.as_stanza()
235
226
            
236
 
 
237
 
def conflicts_to_strings(conflicts):
238
 
    """Generate strings for the provided conflicts"""
239
 
    for conflict in conflicts:
240
 
        yield str(conflict)
241
 
 
 
227
    def to_strings(self):
 
228
        """Generate strings for the provided conflicts"""
 
229
        for conflict in self:
 
230
            yield str(conflict)
 
231
 
 
232
 
 
233
    def remove_files(self, tree):
 
234
        for conflict in self:
 
235
            if not conflict.has_files:
 
236
                continue
 
237
            for suffix in CONFLICT_SUFFIXES:
 
238
                try:
 
239
                    os.unlink(tree.abspath(conflict.path+suffix))
 
240
                except OSError, e:
 
241
                    if e.errno != errno.ENOENT:
 
242
                        raise
242
243
 
243
244
class Conflict(object):
244
245
    """Base class for all types of conflict"""
 
246
 
 
247
    has_files = False
 
248
 
245
249
    def __init__(self, path, file_id=None):
246
250
        self.path = path
247
251
        self.file_id = file_id
302
306
class ContentsConflict(PathConflict):
303
307
    """The files are of different types, or not present"""
304
308
 
 
309
    has_files = True
 
310
 
305
311
    typestring = 'contents conflict'
306
312
 
307
313
    format = 'Contents conflict in %(path)s'
310
316
class TextConflict(PathConflict):
311
317
    """The merge algorithm could not resolve all differences encountered."""
312
318
 
 
319
    has_files = True
 
320
 
313
321
    typestring = 'text conflict'
314
322
 
315
323
    format = 'Text conflict in %(path)s'