1
# Copyright (C) 2005, 2007, 2009, 2010 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007, 2009, 2010 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
408
408
:param tree: The tree passed as a parameter to the method.
410
meth = getattr(self, action, None)
410
meth = getattr(self, 'action_%s' % action, None)
412
412
raise NotImplementedError(self.__class__.__name__ + '.' + action)
415
def associated_filenames(self):
416
"""The names of the files generated to help resolve the conflict."""
417
raise NotImplementedError(self.associated_filenames)
415
419
def cleanup(self, tree):
416
raise NotImplementedError(self.cleanup)
420
for fname in self.associated_filenames():
422
osutils.delete_any(tree.abspath(fname))
424
if e.errno != errno.ENOENT:
418
def done(self, tree):
427
def action_done(self, tree):
419
428
"""Mark the conflict as solved once it has been handled."""
420
429
# This method does nothing but simplifies the design of upper levels.
423
def take_this(self, tree):
424
raise NotImplementedError(self.take_this)
432
def action_take_this(self, tree):
433
raise NotImplementedError(self.action_take_this)
426
def take_other(self, tree):
427
raise NotImplementedError(self.take_other)
435
def action_take_other(self, tree):
436
raise NotImplementedError(self.action_take_other)
430
439
class PathConflict(Conflict):
446
455
s.add('conflict_path', self.conflict_path)
449
def cleanup(self, tree):
458
def associated_filenames(self):
450
459
# No additional files have been generated here
453
def take_this(self, tree):
462
def action_take_this(self, tree):
454
463
tree.rename_one(self.conflict_path, self.path)
456
def take_other(self, tree):
465
def action_take_other(self, tree):
457
466
# just acccept bzr proposal
468
477
format = 'Contents conflict in %(path)s'
470
def cleanup(self, tree):
471
for suffix in ('.BASE', '.OTHER'):
473
osutils.delete_any(tree.abspath(self.path + suffix))
475
if e.errno != errno.ENOENT:
479
def associated_filenames(self):
480
return [self.path + suffix for suffix in ('.BASE', '.OTHER')]
478
482
# FIXME: I smell something weird here and it seems we should be able to be
479
483
# more coherent with some other conflict ? bzr *did* a choice there but
480
# neither take_this nor take_other reflect that... -- vila 091224
481
def take_this(self, tree):
484
# neither action_take_this nor action_take_other reflect that...
486
def action_take_this(self, tree):
482
487
tree.remove([self.path + '.OTHER'], force=True, keep_files=False)
484
def take_other(self, tree):
489
def action_take_other(self, tree):
485
490
tree.remove([self.path], force=True, keep_files=False)
501
506
format = 'Text conflict in %(path)s'
503
def cleanup(self, tree):
504
for suffix in CONFLICT_SUFFIXES:
506
osutils.delete_any(tree.abspath(self.path+suffix))
508
if e.errno != errno.ENOENT:
508
def associated_filenames(self):
509
return [self.path + suffix for suffix in CONFLICT_SUFFIXES]
512
512
class HandledConflict(Conflict):
528
528
s.add('action', self.action)
531
def cleanup(self, tree):
532
"""Nothing to cleanup."""
531
def associated_filenames(self):
532
# Nothing has been generated here
536
536
class HandledPathConflict(HandledConflict):
579
579
format = 'Conflict adding file %(conflict_path)s. %(action)s %(path)s.'
581
def take_this(self, tree):
581
def action_take_this(self, tree):
582
582
tree.remove([self.conflict_path], force=True, keep_files=False)
583
583
tree.rename_one(self.path, self.conflict_path)
585
def take_other(self, tree):
585
def action_take_other(self, tree):
586
586
tree.remove([self.path], force=True, keep_files=False)
602
602
format = 'Conflict moving %(conflict_path)s into %(path)s. %(action)s.'
604
def take_this(self, tree):
604
def action_take_this(self, tree):
605
605
# just acccept bzr proposal
608
def take_other(self, tree):
608
def action_take_other(self, tree):
609
609
# FIXME: We shouldn't have to manipulate so many paths here (and there
610
610
# is probably a bug or two...)
611
611
base_path = osutils.basename(self.path)
637
637
# FIXME: We silently do nothing to make tests pass, but most probably the
638
638
# conflict shouldn't exist (the long story is that the conflict is
639
639
# generated with another one that can be resolved properly) -- vila 091224
640
def take_this(self, tree):
640
def action_take_this(self, tree):
643
def take_other(self, tree):
643
def action_take_other(self, tree):
656
656
format = 'Conflict adding files to %(path)s. %(action)s.'
658
def take_this(self, tree):
658
def action_take_this(self, tree):
659
659
tree.remove([self.path], force=True, keep_files=False)
661
def take_other(self, tree):
661
def action_take_other(self, tree):
662
662
# just acccept bzr proposal
677
677
# FIXME: It's a bit strange that the default action is not coherent with
678
678
# MissingParent from the *user* pov.
680
def take_this(self, tree):
680
def action_take_this(self, tree):
681
681
# just acccept bzr proposal
684
def take_other(self, tree):
684
def action_take_other(self, tree):
685
685
tree.remove([self.path], force=True, keep_files=False)
698
698
# FIXME: .OTHER should be used instead of .new when the conflict is created
700
def take_this(self, tree):
700
def action_take_this(self, tree):
701
701
# FIXME: we should preserve that path when the conflict is generated !
702
702
if self.path.endswith('.new'):
703
703
conflict_path = self.path[:-(len('.new'))]
704
704
tree.remove([self.path], force=True, keep_files=False)
705
705
tree.add(conflict_path)
707
raise NotImplementedError(self.take_this)
707
raise NotImplementedError(self.action_take_this)
709
def take_other(self, tree):
709
def action_take_other(self, tree):
710
710
# FIXME: we should preserve that path when the conflict is generated !
711
711
if self.path.endswith('.new'):
712
712
conflict_path = self.path[:-(len('.new'))]
713
713
tree.remove([conflict_path], force=True, keep_files=False)
714
714
tree.rename_one(self.path, conflict_path)
716
raise NotImplementedError(self.take_other)
716
raise NotImplementedError(self.action_take_other)