Show More
@@ -4168,17 +4168,43 b' def merge(ui, repo, node=None, **opts):' | |||
|
4168 | 4168 | if not node: |
|
4169 | 4169 | node = opts.get('rev') |
|
4170 | 4170 | |
|
4171 |
if |
|
|
4171 | if node: | |
|
4172 | node = scmutil.revsingle(repo, node).node() | |
|
4173 | ||
|
4174 | if not node and repo._bookmarkcurrent: | |
|
4175 | bmheads = repo.bookmarkheads(repo._bookmarkcurrent) | |
|
4176 | curhead = repo[repo._bookmarkcurrent] | |
|
4177 | if len(bmheads) == 2: | |
|
4178 | if curhead == bmheads[0]: | |
|
4179 | node = bmheads[1] | |
|
4180 | else: | |
|
4181 | node = bmheads[0] | |
|
4182 | elif len(bmheads) > 2: | |
|
4183 | raise util.Abort(_("multiple matching bookmarks to merge - " | |
|
4184 | "please merge with an explicit rev or bookmark"), | |
|
4185 | hint=_("run 'hg heads' to see all heads")) | |
|
4186 | elif len(bmheads) <= 1: | |
|
4187 | raise util.Abort(_("no matching bookmark to merge - " | |
|
4188 | "please merge with an explicit rev or bookmark"), | |
|
4189 | hint=_("run 'hg heads' to see all heads")) | |
|
4190 | ||
|
4191 | if not node and not repo._bookmarkcurrent: | |
|
4172 | 4192 | branch = repo[None].branch() |
|
4173 | 4193 | bheads = repo.branchheads(branch) |
|
4174 | if len(bheads) > 2: | |
|
4194 | nbhs = [bh for bh in bheads if not repo[bh].bookmarks()] | |
|
4195 | ||
|
4196 | if len(nbhs) > 2: | |
|
4175 | 4197 | raise util.Abort(_("branch '%s' has %d heads - " |
|
4176 | 4198 | "please merge with an explicit rev") |
|
4177 | 4199 | % (branch, len(bheads)), |
|
4178 | 4200 | hint=_("run 'hg heads .' to see heads")) |
|
4179 | 4201 | |
|
4180 | 4202 | parent = repo.dirstate.p1() |
|
4181 |
if len(bh |
|
|
4203 | if len(nbhs) == 1: | |
|
4204 | if len(bheads) > 1: | |
|
4205 | raise util.Abort(_("heads are bookmarked - " | |
|
4206 | "please merge with an explicit rev"), | |
|
4207 | hint=_("run 'hg heads' to see all heads")) | |
|
4182 | 4208 | if len(repo.heads()) > 1: |
|
4183 | 4209 | raise util.Abort(_("branch '%s' has one head - " |
|
4184 | 4210 | "please merge with an explicit rev") |
@@ -4193,9 +4219,10 b' def merge(ui, repo, node=None, **opts):' | |||
|
4193 | 4219 | raise util.Abort(_('working directory not at a head revision'), |
|
4194 | 4220 | hint=_("use 'hg update' or merge with an " |
|
4195 | 4221 | "explicit revision")) |
|
4196 | node = parent == bheads[0] and bheads[-1] or bheads[0] | |
|
4197 | else: | |
|
4198 | node = scmutil.revsingle(repo, node).node() | |
|
4222 | if parent == nbhs[0]: | |
|
4223 | node = nbhs[-1] | |
|
4224 | else: | |
|
4225 | node = nbhs[0] | |
|
4199 | 4226 | |
|
4200 | 4227 | if opts.get('preview'): |
|
4201 | 4228 | # find nodes that are ancestors of p2 but not of p1 |
@@ -29,3 +29,65 b'' | |||
|
29 | 29 | $ hg bookmarks |
|
30 | 30 | b 1:d2ae7f538514 |
|
31 | 31 | * c 3:b8f96cf4688b |
|
32 | ||
|
33 | $ hg up -C 3 | |
|
34 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
35 | $ echo d > d | |
|
36 | $ hg add d | |
|
37 | $ hg commit -m'd' | |
|
38 | ||
|
39 | $ hg up -C 3 | |
|
40 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
41 | $ echo e > e | |
|
42 | $ hg add e | |
|
43 | $ hg commit -m'e' | |
|
44 | created new head | |
|
45 | $ hg up -C 5 | |
|
46 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
47 | $ hg bookmark e | |
|
48 | $ hg bookmarks | |
|
49 | b 1:d2ae7f538514 | |
|
50 | c 3:b8f96cf4688b | |
|
51 | * e 5:26bee9c5bcf3 | |
|
52 | ||
|
53 | # the picked side is bookmarked | |
|
54 | ||
|
55 | $ hg up -C 4 | |
|
56 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
57 | $ hg merge | |
|
58 | abort: heads are bookmarked - please merge with an explicit rev | |
|
59 | (run 'hg heads' to see all heads) | |
|
60 | [255] | |
|
61 | ||
|
62 | # our revision is bookmarked | |
|
63 | ||
|
64 | $ hg up -C e | |
|
65 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
66 | $ hg merge | |
|
67 | abort: no matching bookmark to merge - please merge with an explicit rev or bookmark | |
|
68 | (run 'hg heads' to see all heads) | |
|
69 | [255] | |
|
70 | ||
|
71 | # merge bookmark heads | |
|
72 | ||
|
73 | $ hg up -C 4 | |
|
74 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
75 | $ echo f > f | |
|
76 | $ hg commit -Am "f" | |
|
77 | adding f | |
|
78 | $ hg up -C e | |
|
79 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
|
80 | $ hg bookmarks -r 4 "e@diverged" | |
|
81 | $ hg bookmarks | |
|
82 | b 1:d2ae7f538514 | |
|
83 | c 3:b8f96cf4688b | |
|
84 | * e 5:26bee9c5bcf3 | |
|
85 | e@diverged 4:a0546fcfe0fb | |
|
86 | $ hg merge | |
|
87 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
88 | (branch merge, don't forget to commit) | |
|
89 | $ hg commit -m'merge' | |
|
90 | $ hg bookmarks | |
|
91 | b 1:d2ae7f538514 | |
|
92 | c 3:b8f96cf4688b | |
|
93 | * e 7:ca784329f0ba |
@@ -19,7 +19,7 b'' | |||
|
19 | 19 | $ hg ci -m 'make bar and baz copies of foo' -d '2 0' |
|
20 | 20 | created new head |
|
21 | 21 | $ hg bookmark premerge1 |
|
22 | $ hg merge | |
|
22 | $ hg merge -r 1 | |
|
23 | 23 | merging baz and foo to baz |
|
24 | 24 | 1 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
25 | 25 | (branch merge, don't forget to commit) |
General Comments 0
You need to be logged in to leave comments.
Login now