~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: aaron.bentley at utoronto
  • Date: 2005-08-18 02:24:28 UTC
  • mto: (1092.1.41) (1185.3.4) (974.1.47)
  • mto: This revision was merged to the branch mainline in revision 1110.
  • Revision ID: aaron.bentley@utoronto.ca-20050818022428-4c0bf84005f4dba8
mergedĀ mbp@sourcefrog.net-20050817233101-0939da1cf91f2472

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from merge_core import merge_flex, ApplyMerge3, BackupBeforeChange
2
 
from changeset import generate_changeset, ExceptionConflictHandler
3
 
from changeset import Inventory, Diff3Merge
 
1
from bzrlib.merge_core import merge_flex, ApplyMerge3, BackupBeforeChange
 
2
from bzrlib.changeset import generate_changeset, ExceptionConflictHandler
 
3
from bzrlib.changeset import Inventory, Diff3Merge
4
4
from bzrlib import find_branch
5
5
import bzrlib.osutils
6
6
from bzrlib.errors import BzrCommandError
7
 
from bzrlib.diff import compare_trees
 
7
from bzrlib.delta import compare_trees
8
8
from trace import mutter, warning
9
9
import os.path
10
10
import tempfile
11
11
import shutil
12
12
import errno
13
13
 
 
14
 
 
15
# comments from abentley on irc: merge happens in two stages, each
 
16
# of which generates a changeset object
 
17
 
 
18
# stage 1: generate OLD->OTHER,
 
19
# stage 2: use MINE and OLD->OTHER to generate MINE -> RESULT
 
20
 
14
21
class UnrelatedBranches(BzrCommandError):
15
22
    def __init__(self):
16
23
        msg = "Branches have no common ancestor, and no base revision"\
19
26
 
20
27
 
21
28
class MergeConflictHandler(ExceptionConflictHandler):
22
 
    """Handle conflicts encountered while merging"""
 
29
    """Handle conflicts encountered while merging.
 
30
 
 
31
    This subclasses ExceptionConflictHandler, so that any types of
 
32
    conflict that are not explicitly handled cause an exception and
 
33
    terminate the merge.
 
34
    """
23
35
    def __init__(self, dir, ignore_zero=False):
24
36
        ExceptionConflictHandler.__init__(self, dir)
25
37
        self.conflicts = 0
84
96
        os.rename(new_file, this_path)
85
97
        self.conflict("Diff3 conflict encountered in %s" % this_path)
86
98
 
 
99
    def new_contents_conflict(self, filename, other_contents):
 
100
        """Conflicting contents for newly added file."""
 
101
        self.copy(other_contents, filename + ".OTHER")
 
102
        self.conflict("Conflict in newly added file %s" % filename)
 
103
    
 
104
 
87
105
    def target_exists(self, entry, target, old_path):
88
106
        """Handle the case when the target file or dir exists"""
89
107
        moved_path = self.add_suffix(target, ".moved")