Show More
@@ -1891,7 +1891,7 b' def merge(ui, repo, node=None, force=Non' | |||||
1891 | performed before any further updates are allowed. |
|
1891 | performed before any further updates are allowed. | |
1892 |
|
1892 | |||
1893 | If no revision is specified, the working directory's parent is a |
|
1893 | If no revision is specified, the working directory's parent is a | |
1894 |
head revision, and the |
|
1894 | head revision, and the current branch contains exactly one other head, | |
1895 | the other head is merged with by default. Otherwise, an explicit |
|
1895 | the other head is merged with by default. Otherwise, an explicit | |
1896 | revision to merge with must be provided. |
|
1896 | revision to merge with must be provided. | |
1897 | """ |
|
1897 | """ | |
@@ -1902,22 +1902,28 b' def merge(ui, repo, node=None, force=Non' | |||||
1902 | node = rev |
|
1902 | node = rev | |
1903 |
|
1903 | |||
1904 | if not node: |
|
1904 | if not node: | |
1905 | heads = repo.heads() |
|
1905 | branch = repo.workingctx().branch() | |
1906 | if len(heads) > 2: |
|
1906 | bheads = repo.branchheads() | |
1907 | raise util.Abort(_('repo has %d heads - ' |
|
1907 | if len(bheads) > 2: | |
1908 | 'please merge with an explicit rev') % |
|
1908 | raise util.Abort(_("branch '%s' has %d heads - " | |
1909 |
le |
|
1909 | "please merge with an explicit rev") % | |
|
1910 | (branch, len(bheads))) | |||
|
1911 | ||||
1910 | parent = repo.dirstate.parents()[0] |
|
1912 | parent = repo.dirstate.parents()[0] | |
1911 | if len(heads) == 1: |
|
1913 | if len(bheads) == 1: | |
|
1914 | if len(repo.heads()) > 1: | |||
|
1915 | raise util.Abort(_("branch '%s' has one head - " | |||
|
1916 | "please merge with an explicit rev") % | |||
|
1917 | branch) | |||
1912 | msg = _('there is nothing to merge') |
|
1918 | msg = _('there is nothing to merge') | |
1913 | if parent != repo.lookup(repo.workingctx().branch()): |
|
1919 | if parent != repo.lookup(repo.workingctx().branch()): | |
1914 | msg = _('%s - use "hg update" instead') % msg |
|
1920 | msg = _('%s - use "hg update" instead') % msg | |
1915 | raise util.Abort(msg) |
|
1921 | raise util.Abort(msg) | |
1916 |
|
1922 | |||
1917 | if parent not in heads: |
|
1923 | if parent not in bheads: | |
1918 | raise util.Abort(_('working dir not at a head rev - ' |
|
1924 | raise util.Abort(_('working dir not at a head rev - ' | |
1919 | 'use "hg update" or merge with an explicit rev')) |
|
1925 | 'use "hg update" or merge with an explicit rev')) | |
1920 | node = parent == heads[0] and heads[-1] or heads[0] |
|
1926 | node = parent == bheads[0] and bheads[-1] or bheads[0] | |
1921 | return hg.merge(repo, node, force=force) |
|
1927 | return hg.merge(repo, node, force=force) | |
1922 |
|
1928 | |||
1923 | def outgoing(ui, repo, dest=None, **opts): |
|
1929 | def outgoing(ui, repo, dest=None, **opts): |
@@ -23,7 +23,7 b' hg co -q 3' | |||||
23 | echo other 4 >> d |
|
23 | echo other 4 >> d | |
24 | hg add d |
|
24 | hg add d | |
25 | hg commit -m 'new head' -d '1500000 0' -u 'person' |
|
25 | hg commit -m 'new head' -d '1500000 0' -u 'person' | |
26 | hg merge -q |
|
26 | hg merge -q foo | |
27 | hg commit -m 'merge' -d '1500001 0' -u 'person' |
|
27 | hg commit -m 'merge' -d '1500001 0' -u 'person' | |
28 | # second branch starting at nullrev |
|
28 | # second branch starting at nullrev | |
29 | hg update null |
|
29 | hg update null |
@@ -17,7 +17,7 b' hg branch branch0' | |||||
17 | echo b > b |
|
17 | echo b > b | |
18 | hg ci -qAm addb |
|
18 | hg ci -qAm addb | |
19 | hg up -qC |
|
19 | hg up -qC | |
20 | hg merge |
|
20 | hg merge default | |
21 | hg ci -qm mergeab |
|
21 | hg ci -qm mergeab | |
22 | hg tag -ql mergeab |
|
22 | hg tag -ql mergeab | |
23 | cd .. |
|
23 | cd .. |
@@ -5,10 +5,10 b' 1 files updated, 0 files merged, 0 files' | |||||
5 | created new head |
|
5 | created new head | |
6 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
6 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
7 | % should fail because not at a head |
|
7 | % should fail because not at a head | |
8 |
abort: |
|
8 | abort: branch 'default' has 3 heads - please merge with an explicit rev | |
9 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
9 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
10 | % should fail because > 2 heads |
|
10 | % should fail because > 2 heads | |
11 |
abort: |
|
11 | abort: branch 'default' has 3 heads - please merge with an explicit rev | |
12 | % should succeed |
|
12 | % should succeed | |
13 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
13 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
14 | (branch merge, don't forget to commit) |
|
14 | (branch merge, don't forget to commit) |
@@ -24,7 +24,7 b' hg branch' | |||||
24 | echo bleah > a |
|
24 | echo bleah > a | |
25 | hg ci -m "modify a branch" -d "1000000 0" |
|
25 | hg ci -m "modify a branch" -d "1000000 0" | |
26 |
|
26 | |||
27 | hg merge |
|
27 | hg merge default | |
28 | hg branch |
|
28 | hg branch | |
29 | hg ci -m "merge" -d "1000000 0" |
|
29 | hg ci -m "merge" -d "1000000 0" | |
30 | hg log |
|
30 | hg log | |
@@ -73,4 +73,38 b" hg commit -m'Merge ff into foo' -d '1000" | |||||
73 | hg parents |
|
73 | hg parents | |
74 | hg manifest |
|
74 | hg manifest | |
75 |
|
75 | |||
76 | exit 0 |
|
76 | echo % test merging, add 3 default heads and one test head | |
|
77 | cd .. | |||
|
78 | hg init merges | |||
|
79 | cd merges | |||
|
80 | echo a > a | |||
|
81 | hg ci -Ama | |||
|
82 | ||||
|
83 | echo b > b | |||
|
84 | hg ci -Amb | |||
|
85 | ||||
|
86 | hg up 0 | |||
|
87 | echo c > c | |||
|
88 | hg ci -Amc | |||
|
89 | ||||
|
90 | hg up 0 | |||
|
91 | echo d > d | |||
|
92 | hg ci -Amd | |||
|
93 | ||||
|
94 | hg up 0 | |||
|
95 | hg branch test | |||
|
96 | echo e >> e | |||
|
97 | hg ci -Ame | |||
|
98 | ||||
|
99 | hg log | |||
|
100 | ||||
|
101 | echo % implicit merge with test branch as parent | |||
|
102 | hg merge | |||
|
103 | hg up -C default | |||
|
104 | echo % implicit merge with default branch as parent | |||
|
105 | hg merge | |||
|
106 | echo % 3 branch heads, explicit merge required | |||
|
107 | hg merge 2 | |||
|
108 | hg ci -m merge | |||
|
109 | echo % 2 branch heads, implicit merge works | |||
|
110 | hg merge |
@@ -116,3 +116,57 b' summary: Merge ff into foo' | |||||
116 |
|
116 | |||
117 | a |
|
117 | a | |
118 | ff |
|
118 | ff | |
|
119 | % test merging, add 3 default heads and one test head | |||
|
120 | adding a | |||
|
121 | adding b | |||
|
122 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
123 | adding c | |||
|
124 | created new head | |||
|
125 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
126 | adding d | |||
|
127 | created new head | |||
|
128 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
129 | marked working directory as branch test | |||
|
130 | adding e | |||
|
131 | created new head | |||
|
132 | changeset: 4:3a1e01ed1df4 | |||
|
133 | branch: test | |||
|
134 | tag: tip | |||
|
135 | parent: 0:cb9a9f314b8b | |||
|
136 | user: test | |||
|
137 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
138 | summary: e | |||
|
139 | ||||
|
140 | changeset: 3:980f7dc84c29 | |||
|
141 | parent: 0:cb9a9f314b8b | |||
|
142 | user: test | |||
|
143 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
144 | summary: d | |||
|
145 | ||||
|
146 | changeset: 2:d36c0562f908 | |||
|
147 | parent: 0:cb9a9f314b8b | |||
|
148 | user: test | |||
|
149 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
150 | summary: c | |||
|
151 | ||||
|
152 | changeset: 1:d2ae7f538514 | |||
|
153 | user: test | |||
|
154 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
155 | summary: b | |||
|
156 | ||||
|
157 | changeset: 0:cb9a9f314b8b | |||
|
158 | user: test | |||
|
159 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
160 | summary: a | |||
|
161 | ||||
|
162 | % implicit merge with test branch as parent | |||
|
163 | abort: branch 'test' has one head - please merge with an explicit rev | |||
|
164 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
165 | % implicit merge with default branch as parent | |||
|
166 | abort: branch 'default' has 3 heads - please merge with an explicit rev | |||
|
167 | % 3 branch heads, explicit merge required | |||
|
168 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
169 | (branch merge, don't forget to commit) | |||
|
170 | % 2 branch heads, implicit merge works | |||
|
171 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
172 | (branch merge, don't forget to commit) |
General Comments 0
You need to be logged in to leave comments.
Login now