~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Martin Pool
  • Date: 2010-02-25 06:17:27 UTC
  • mfrom: (5055 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5057.
  • Revision ID: mbp@sourcefrog.net-20100225061727-4sd9lt0qmdc6087t
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2009, 2010 Canonical Ltd
2
2
#
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
412
412
            raise NotImplementedError(self.__class__.__name__ + '.' + action)
413
413
        meth(tree)
414
414
 
 
415
    def associated_filenames(self):
 
416
        """The names of the files generated to help resolve the conflict."""
 
417
        raise NotImplementedError(self.associated_filenames)
 
418
 
415
419
    def cleanup(self, tree):
416
 
        raise NotImplementedError(self.cleanup)
 
420
        for fname in self.associated_filenames():
 
421
            try:
 
422
                osutils.delete_any(tree.abspath(fname))
 
423
            except OSError, e:
 
424
                if e.errno != errno.ENOENT:
 
425
                    raise
417
426
 
418
427
    def action_done(self, tree):
419
428
        """Mark the conflict as solved once it has been handled."""
446
455
            s.add('conflict_path', self.conflict_path)
447
456
        return s
448
457
 
449
 
    def cleanup(self, tree):
 
458
    def associated_filenames(self):
450
459
        # No additional files have been generated here
451
 
        pass
 
460
        return []
452
461
 
453
462
    def action_take_this(self, tree):
454
463
        tree.rename_one(self.conflict_path, self.path)
467
476
 
468
477
    format = 'Contents conflict in %(path)s'
469
478
 
470
 
    def cleanup(self, tree):
471
 
        for suffix in ('.BASE', '.OTHER'):
472
 
            try:
473
 
                osutils.delete_any(tree.abspath(self.path + suffix))
474
 
            except OSError, e:
475
 
                if e.errno != errno.ENOENT:
476
 
                    raise
 
479
    def associated_filenames(self):
 
480
        return [self.path + suffix for suffix in ('.BASE', '.OTHER')]
477
481
 
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
501
505
 
502
506
    format = 'Text conflict in %(path)s'
503
507
 
504
 
    def cleanup(self, tree):
505
 
        for suffix in CONFLICT_SUFFIXES:
506
 
            try:
507
 
                osutils.delete_any(tree.abspath(self.path+suffix))
508
 
            except OSError, e:
509
 
                if e.errno != errno.ENOENT:
510
 
                    raise
 
508
    def associated_filenames(self):
 
509
        return [self.path + suffix for suffix in CONFLICT_SUFFIXES]
511
510
 
512
511
 
513
512
class HandledConflict(Conflict):
529
528
        s.add('action', self.action)
530
529
        return s
531
530
 
532
 
    def cleanup(self, tree):
533
 
        """Nothing to cleanup."""
534
 
        pass
 
531
    def associated_filenames(self):
 
532
        # Nothing has been generated here
 
533
        return []
535
534
 
536
535
 
537
536
class HandledPathConflict(HandledConflict):