~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-03-11 13:47:06 UTC
  • mfrom: (5051.3.16 use-branch-open)
  • Revision ID: pqm@pqm.ubuntu.com-20100311134706-kaerqhx3lf7xn6rh
(Jelmer) Pass colocated branch names further down the call stack.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
from bzrlib import (
28
28
    builtins,
 
29
    cleanup,
29
30
    commands,
30
31
    errors,
31
32
    osutils,
479
480
    def associated_filenames(self):
480
481
        return [self.path + suffix for suffix in ('.BASE', '.OTHER')]
481
482
 
482
 
    # FIXME: I smell something weird here and it seems we should be able to be
483
 
    # more coherent with some other conflict ? bzr *did* a choice there but
484
 
    # neither action_take_this nor action_take_other reflect that...
485
 
    # -- vila 20091224
 
483
    def _take_it(self, tt, suffix_to_remove):
 
484
        """Resolve the conflict.
 
485
 
 
486
        :param tt: The TreeTransform where the conflict is resolved.
 
487
        :param suffix_to_remove: Either 'THIS' or 'OTHER'
 
488
 
 
489
        The resolution is symmetric, when taking THIS, OTHER is deleted and
 
490
        item.THIS is renamed into item and vice-versa.
 
491
        """
 
492
        try:
 
493
            # Delete 'item.THIS' or 'item.OTHER' depending on
 
494
            # suffix_to_remove
 
495
            tt.delete_contents(
 
496
                tt.trans_id_tree_path(self.path + '.' + suffix_to_remove))
 
497
        except errors.NoSuchFile:
 
498
            # There are valid cases where 'item.suffix_to_remove' either
 
499
            # never existed or was already deleted (including the case
 
500
            # where the user deleted it)
 
501
            pass
 
502
        # Rename 'item.suffix_to_remove' (note that if
 
503
        # 'item.suffix_to_remove' has been deleted, this is a no-op)
 
504
        this_tid = tt.trans_id_file_id(self.file_id)
 
505
        parent_tid = tt.get_tree_parent(this_tid)
 
506
        tt.adjust_path(self.path, parent_tid, this_tid)
 
507
        tt.apply()
 
508
 
 
509
    def _take_it_with_cleanups(self, tree, suffix_to_remove):
 
510
        tt = transform.TreeTransform(tree)
 
511
        op = cleanup.OperationWithCleanups(self._take_it)
 
512
        op.add_cleanup(tt.finalize)
 
513
        op.run_simple(tt, suffix_to_remove)
 
514
 
486
515
    def action_take_this(self, tree):
487
 
        tree.remove([self.path + '.OTHER'], force=True, keep_files=False)
 
516
        self._take_it_with_cleanups(tree, 'OTHER')
488
517
 
489
518
    def action_take_other(self, tree):
490
 
        tree.remove([self.path], force=True, keep_files=False)
491
 
 
 
519
        self._take_it_with_cleanups(tree, 'THIS')
492
520
 
493
521
 
494
522
# FIXME: TextConflict is about a single file-id, there never is a conflict_path