225
225
def __ne__(self, other):
226
226
return not self.__eq__(other)
229
return self.format % self.__dict__
229
232
def factory(type, **kwargs):
231
234
return ctype[type](**kwargs)
233
class ContentsConflict(Conflict):
234
typestring = 'contents conflict'
236
class TextConflict(ContentsConflict):
237
typestring = 'text conflict'
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
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)
251
class ContentsConflict(PathConflict):
252
typestring = 'contents conflict'
253
format = 'Contents conflict in %(path)s'
256
class TextConflict(PathConflict):
257
typestring = 'text conflict'
258
format = 'Text conflict in %(path)s'
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)
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)
275
288
class DuplicateID(HandledPathConflict):
276
289
typestring = 'duplicate id'
290
format = 'Conflict adding id to %(conflict_path)s. %(action)s %(path)s.'
278
293
class DuplicateEntry(HandledPathConflict):
279
294
typestring = 'duplicate'
295
format = 'Conflict adding file %(conflict_path)s. %(action)s %(path)s.'
281
298
class ParentLoop(HandledPathConflict):
282
299
typestring = 'parent loop'
300
format = 'Conflict moving %(conflict_path)s into %(path)s. %(action)s.'
284
303
class UnversionedParent(HandledConflict):
285
304
typestring = 'unversioned parent'
305
format = 'Conflict adding versioned files to %(path)s. %(action)s.'
287
308
class MissingParent(HandledConflict):
288
309
typestring = 'missing parent'
310
format = 'Conflict adding files to %(path)s. %(action)s.'
291
317
def register_types(*conflict_types):
292
318
"""Register a Conflict subclass for serialization purposes"""
294
320
for conflict_type in conflict_types:
295
321
ctype[conflict_type.typestring] = conflict_type
297
324
register_types(ContentsConflict, TextConflict, PathConflict, DuplicateID,
298
DuplicateEntry, ParentLoop, UnversionedParent, MissingParent)
325
DuplicateEntry, ParentLoop, UnversionedParent, MissingParent,)