~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to patches/pending-merge.patch

  • Committer: Martin Pool
  • Date: 2005-06-06 04:47:33 UTC
  • Revision ID: mbp@sourcefrog.net-20050606044733-e902b05ac1747cd2
- fix invocation of testbzr when giving explicit bzr location

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
*** modified file 'bzrlib/merge.py'
2
 
--- bzrlib/merge.py 
3
 
+++ bzrlib/merge.py 
4
 
@@ -105,14 +105,21 @@
5
 
     location, revno = treespec
6
 
     branch = find_branch(location)
7
 
     if revno is None:
8
 
+        rev_id = None
9
 
+    elif revno == -1:
10
 
+        rev_id = branch.last_patch()
11
 
+    else:
12
 
+        rev_id = branch.lookup_revision(revno)
13
 
+    return branch, get_revid_tree(branch, rev_id, temp_root, label)
14
 
+
15
 
+def get_revid_tree(branch, rev_id, temp_root, label):
16
 
+    if rev_id is None:
17
 
         base_tree = branch.working_tree()
18
 
-    elif revno == -1:
19
 
-        base_tree = branch.basis_tree()
20
 
     else:
21
 
-        base_tree = branch.revision_tree(branch.lookup_revision(revno))
22
 
+        base_tree = branch.revision_tree(rev_id)
23
 
     temp_path = os.path.join(temp_root, label)
24
 
     os.mkdir(temp_path)
25
 
-    return branch, MergeTree(base_tree, temp_path)
26
 
+    return MergeTree(base_tree, temp_path)
27
 
 
28
 
 
29
 
 def abspath(tree, file_id):
30
 
@@ -178,30 +185,68 @@
31
 
         If true, this_dir must have no uncommitted changes before the
32
 
         merge begins.
33
 
     """
34
 
+    from bzrlib.revision import common_ancestor, MultipleRevisionSources
35
 
+    from bzrlib.branch import NoSuchRevision
36
 
     tempdir = tempfile.mkdtemp(prefix="bzr-")
37
 
     try:
38
 
         if this_dir is None:
39
 
             this_dir = '.'
40
 
         this_branch = find_branch(this_dir)
41
 
+        this_rev_id = this_branch.last_patch()
42
 
+        if this_rev_id is None:
43
 
+            raise BzrCommandError("This branch has no commits")
44
 
         if check_clean:
45
 
             changes = compare_trees(this_branch.working_tree(), 
46
 
                                     this_branch.basis_tree(), False)
47
 
             if changes.has_changed():
48
 
                 raise BzrCommandError("Working tree has uncommitted changes.")
49
 
         other_branch, other_tree = get_tree(other_revision, tempdir, "other")
50
 
+        if other_revision[1] == -1:
51
 
+            other_rev_id = other_branch.last_patch()
52
 
+            other_basis = other_rev_id
53
 
+        elif other_revision[1] is not None:
54
 
+            other_rev_id = other_branch.lookup_revision(other_revision[1])
55
 
+            other_basis = other_rev_id
56
 
+        else:
57
 
+            other_rev_id = None
58
 
+            other_basis = other_branch.last_patch()
59
 
         if base_revision == [None, None]:
60
 
             if other_revision[1] == -1:
61
 
                 o_revno = None
62
 
             else:
63
 
                 o_revno = other_revision[1]
64
 
-            base_revno = this_branch.common_ancestor(other_branch, 
65
 
-                                                     other_revno=o_revno)[0]
66
 
-            if base_revno is None:
67
 
+            base_rev_id = common_ancestor(this_rev_id, other_basis,
68
 
+                                          MultipleRevisionSources(this_branch, 
69
 
+                                          other_branch))
70
 
+            if base_rev_id is None:
71
 
                 raise UnrelatedBranches()
72
 
-            base_revision = ['.', base_revno]
73
 
-        base_branch, base_tree = get_tree(base_revision, tempdir, "base")
74
 
+            try:
75
 
+                base_revision = this_branch.get_revision(base_rev_id)
76
 
+                base_branch = this_branch
77
 
+            except NoSuchRevision:
78
 
+                base_branch = other_branch
79
 
+            base_tree = get_revid_tree(base_branch, base_rev_id, tempdir, 
80
 
+                                       "base")
81
 
+            base_is_ancestor = True
82
 
+        else:
83
 
+            base_branch, base_tree = get_tree(base_revision, tempdir, "base")
84
 
+            if base_revision[1] == -1:
85
 
+                base_rev_id = base_branch.last_patch()
86
 
+            elif base_revision[1] is None:
87
 
+                base_rev_id = None
88
 
+            else:
89
 
+                base_rev_id = base_branch.lookup_revision(base_revision[1])
90
 
+            if base_rev_id is not None:
91
 
+                base_is_ancestor = is_ancestor(this_rev_id, base_rev_id, 
92
 
+                                               MultipleRevisionSources(
93
 
+                                               this_branch, 
94
 
+                                               base_branch))
95
 
+            else:
96
 
+                base_is_ancestor = False
97
 
         merge_inner(this_branch, other_tree, base_tree, tempdir, 
98
 
                     ignore_zero=ignore_zero)
99
 
+        if base_is_ancestor and other_rev_id is not None:
100
 
+            this_branch.add_pending_merge(other_rev_id)
101
 
     finally:
102
 
         shutil.rmtree(tempdir)
103
 
 
104