~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 04:29:35 UTC
  • mto: (2027.1.2 revert-subpath-56549)
  • mto: This revision was merged to the branch mainline in revision 1647.
  • Revision ID: aaron.bentley@utoronto.ca-20060405042935-7a86762d00a3ae2e
Got all tests passing

Show diffs side-by-side

added added

removed removed

Lines of Context:
225
225
    def __ne__(self, other):
226
226
        return not self.__eq__(other)
227
227
 
 
228
    def __str__(self):
 
229
        return self.format % self.__dict__
 
230
 
228
231
    @staticmethod
229
232
    def factory(type, **kwargs):
230
233
        global ctype
231
234
        return ctype[type](**kwargs)
232
235
 
233
 
class ContentsConflict(Conflict):
234
 
    typestring = 'contents conflict'
235
 
 
236
 
class TextConflict(ContentsConflict):
237
 
    typestring = 'text conflict'
238
236
 
239
237
class PathConflict(Conflict):
240
238
    typestring = 'path conflict'
241
 
    def __init__(self, path, conflict_path, file_id=None):
 
239
    format = 'Path conflict: %(path)s / %(conflict_path)s'
 
240
    def __init__(self, path, conflict_path=None, file_id=None):
242
241
        Conflict.__init__(self, path, file_id)
243
242
        self.conflict_path = conflict_path
244
243
 
245
244
    def as_stanza(self):
246
245
        s = Conflict.as_stanza(self)
247
 
        s.add('conflict_path', self.conflict_path)
 
246
        if self.conflict_path is not None:
 
247
            s.add('conflict_path', self.conflict_path)
248
248
        return s
249
249
 
 
250
 
 
251
class ContentsConflict(PathConflict):
 
252
    typestring = 'contents conflict'
 
253
    format = 'Contents conflict in %(path)s'
 
254
 
 
255
 
 
256
class TextConflict(PathConflict):
 
257
    typestring = 'text conflict'
 
258
    format = 'Text conflict in %(path)s'
 
259
 
 
260
 
250
261
class HandledConflict(Conflict):
251
262
    def __init__(self, action, path, file_id=None):
252
263
        Conflict.__init__(self, path, file_id)
257
268
        s.add('action', self.action)
258
269
        return s
259
270
 
 
271
 
260
272
class HandledPathConflict(HandledConflict):
261
273
    def __init__(self, action, path, conflict_path, file_id=None,
262
274
                 conflict_file_id=None):
271
283
            s.add('conflict_file_id', self.conflict_file_id)
272
284
            
273
285
        return s
274
 
    
 
286
 
 
287
 
275
288
class DuplicateID(HandledPathConflict):
276
289
    typestring = 'duplicate id'
 
290
    format = 'Conflict adding id to %(conflict_path)s.  %(action)s %(path)s.'
 
291
 
277
292
 
278
293
class DuplicateEntry(HandledPathConflict):
279
294
    typestring = 'duplicate'
 
295
    format = 'Conflict adding file %(conflict_path)s.  %(action)s %(path)s.'
 
296
 
280
297
 
281
298
class ParentLoop(HandledPathConflict):
282
299
    typestring = 'parent loop'
 
300
    format = 'Conflict moving %(conflict_path)s into %(path)s.  %(action)s.'
 
301
 
283
302
 
284
303
class UnversionedParent(HandledConflict):
285
304
    typestring = 'unversioned parent'
 
305
    format = 'Conflict adding versioned files to %(path)s.  %(action)s.'
 
306
 
286
307
 
287
308
class MissingParent(HandledConflict):
288
309
    typestring = 'missing parent'
 
310
    format = 'Conflict adding files to %(path)s.  %(action)s.'
 
311
 
 
312
 
289
313
 
290
314
ctype = {}
 
315
 
 
316
 
291
317
def register_types(*conflict_types):
292
318
    """Register a Conflict subclass for serialization purposes"""
293
319
    global ctype
294
320
    for conflict_type in conflict_types:
295
321
        ctype[conflict_type.typestring] = conflict_type
296
322
 
 
323
 
297
324
register_types(ContentsConflict, TextConflict, PathConflict, DuplicateID,
298
 
               DuplicateEntry, ParentLoop, UnversionedParent, MissingParent)
 
325
               DuplicateEntry, ParentLoop, UnversionedParent, MissingParent,)