##// END OF EJS Templates
destutil: provide hint on rebase+merge for how to specify destination/rev...
Kyle Lippincott -
r43384:8197b395 default
parent child Browse files
Show More
@@ -1,490 +1,490 b''
1 1 # destutil.py - Mercurial utility function for command destination
2 2 #
3 3 # Copyright Matt Mackall <mpm@selenic.com> and other
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 from .i18n import _
11 11 from . import bookmarks, error, obsutil, scmutil, stack
12 12
13 13
14 14 def orphanpossibledestination(repo, rev):
15 15 """Return all changesets that may be a new parent for orphan `rev`.
16 16
17 17 This function works fine on non-orphan revisions, it's just silly
18 18 because there's no destination implied by obsolete markers, so
19 19 it'll return nothing.
20 20 """
21 21 tonode = repo.changelog.node
22 22 parents = repo.changelog.parentrevs
23 23 torev = repo.changelog.rev
24 24 dest = set()
25 25 tovisit = list(parents(rev))
26 26 while tovisit:
27 27 r = tovisit.pop()
28 28 succsets = obsutil.successorssets(repo, tonode(r))
29 29 if not succsets:
30 30 # if there are no successors for r, r was probably pruned
31 31 # and we should walk up to r's parents to try and find
32 32 # some successors.
33 33 tovisit.extend(parents(r))
34 34 else:
35 35 # We should probably pick only one destination from split
36 36 # (case where '1 < len(ss)'), This could be the currently
37 37 # tipmost, but the correct result is less clear when
38 38 # results of the split have been moved such that they
39 39 # reside on multiple branches.
40 40 for ss in succsets:
41 41 for n in ss:
42 42 dr = torev(n)
43 43 if dr != -1:
44 44 dest.add(dr)
45 45 return dest
46 46
47 47
48 48 def _destupdateobs(repo, clean):
49 49 """decide of an update destination from obsolescence markers"""
50 50 node = None
51 51 wc = repo[None]
52 52 p1 = wc.p1()
53 53 movemark = None
54 54
55 55 if p1.obsolete() and not p1.children():
56 56 # allow updating to successors
57 57 successors = obsutil.successorssets(repo, p1.node())
58 58
59 59 # behavior of certain cases is as follows,
60 60 #
61 61 # divergent changesets: update to highest rev, similar to what
62 62 # is currently done when there are more than one head
63 63 # (i.e. 'tip')
64 64 #
65 65 # replaced changesets: same as divergent except we know there
66 66 # is no conflict
67 67 #
68 68 # pruned changeset: no update is done; though, we could
69 69 # consider updating to the first non-obsolete parent,
70 70 # similar to what is current done for 'hg prune'
71 71
72 72 if successors:
73 73 # flatten the list here handles both divergent (len > 1)
74 74 # and the usual case (len = 1)
75 75 successors = [n for sub in successors for n in sub]
76 76
77 77 # get the max revision for the given successors set,
78 78 # i.e. the 'tip' of a set
79 79 node = repo.revs(b'max(%ln)', successors).first()
80 80 if bookmarks.isactivewdirparent(repo):
81 81 movemark = repo[b'.'].node()
82 82 return node, movemark, None
83 83
84 84
85 85 def _destupdatebook(repo, clean):
86 86 """decide on an update destination from active bookmark"""
87 87 # we also move the active bookmark, if any
88 88 node = None
89 89 activemark, movemark = bookmarks.calculateupdate(repo.ui, repo)
90 90 if activemark is not None:
91 91 node = repo._bookmarks[activemark]
92 92 return node, movemark, activemark
93 93
94 94
95 95 def _destupdatebranch(repo, clean):
96 96 """decide on an update destination from current branch
97 97
98 98 This ignores closed branch heads.
99 99 """
100 100 wc = repo[None]
101 101 movemark = node = None
102 102 currentbranch = wc.branch()
103 103
104 104 if clean:
105 105 currentbranch = repo[b'.'].branch()
106 106
107 107 if currentbranch in repo.branchmap():
108 108 heads = repo.branchheads(currentbranch)
109 109 if heads:
110 110 node = repo.revs(b'max(.::(%ln))', heads).first()
111 111 if bookmarks.isactivewdirparent(repo):
112 112 movemark = repo[b'.'].node()
113 113 elif currentbranch == b'default' and not wc.p1():
114 114 # "null" parent belongs to "default" branch, but it doesn't exist, so
115 115 # update to the tipmost non-closed branch head
116 116 node = repo.revs(b'max(head() and not closed())').first()
117 117 else:
118 118 node = repo[b'.'].node()
119 119 return node, movemark, None
120 120
121 121
122 122 def _destupdatebranchfallback(repo, clean):
123 123 """decide on an update destination from closed heads in current branch"""
124 124 wc = repo[None]
125 125 currentbranch = wc.branch()
126 126 movemark = None
127 127 if currentbranch in repo.branchmap():
128 128 # here, all descendant branch heads are closed
129 129 heads = repo.branchheads(currentbranch, closed=True)
130 130 assert heads, b"any branch has at least one head"
131 131 node = repo.revs(b'max(.::(%ln))', heads).first()
132 132 assert node is not None, (
133 133 b"any revision has at least " b"one descendant branch head"
134 134 )
135 135 if bookmarks.isactivewdirparent(repo):
136 136 movemark = repo[b'.'].node()
137 137 else:
138 138 # here, no "default" branch, and all branches are closed
139 139 node = repo.lookup(b'tip')
140 140 assert node is not None, b"'tip' exists even in empty repository"
141 141 return node, movemark, None
142 142
143 143
144 144 # order in which each step should be evaluated
145 145 # steps are run until one finds a destination
146 146 destupdatesteps = [b'evolution', b'bookmark', b'branch', b'branchfallback']
147 147 # mapping to ease extension overriding steps.
148 148 destupdatestepmap = {
149 149 b'evolution': _destupdateobs,
150 150 b'bookmark': _destupdatebook,
151 151 b'branch': _destupdatebranch,
152 152 b'branchfallback': _destupdatebranchfallback,
153 153 }
154 154
155 155
156 156 def destupdate(repo, clean=False):
157 157 """destination for bare update operation
158 158
159 159 return (rev, movemark, activemark)
160 160
161 161 - rev: the revision to update to,
162 162 - movemark: node to move the active bookmark from
163 163 (cf bookmark.calculate update),
164 164 - activemark: a bookmark to activate at the end of the update.
165 165 """
166 166 node = movemark = activemark = None
167 167
168 168 for step in destupdatesteps:
169 169 node, movemark, activemark = destupdatestepmap[step](repo, clean)
170 170 if node is not None:
171 171 break
172 172 rev = repo[node].rev()
173 173
174 174 return rev, movemark, activemark
175 175
176 176
177 177 msgdestmerge = {
178 178 # too many matching divergent bookmark
179 179 b'toomanybookmarks': {
180 180 b'merge': (
181 181 _(
182 182 b"multiple matching bookmarks to merge -"
183 183 b" please merge with an explicit rev or bookmark"
184 184 ),
185 _(b"run 'hg heads' to see all heads"),
185 _(b"run 'hg heads' to see all heads, specify rev with -r"),
186 186 ),
187 187 b'rebase': (
188 188 _(
189 189 b"multiple matching bookmarks to rebase -"
190 190 b" please rebase to an explicit rev or bookmark"
191 191 ),
192 _(b"run 'hg heads' to see all heads"),
192 _(b"run 'hg heads' to see all heads, specify destination with -d"),
193 193 ),
194 194 },
195 195 # no other matching divergent bookmark
196 196 b'nootherbookmarks': {
197 197 b'merge': (
198 198 _(
199 199 b"no matching bookmark to merge - "
200 200 b"please merge with an explicit rev or bookmark"
201 201 ),
202 _(b"run 'hg heads' to see all heads"),
202 _(b"run 'hg heads' to see all heads, specify rev with -r"),
203 203 ),
204 204 b'rebase': (
205 205 _(
206 206 b"no matching bookmark to rebase - "
207 207 b"please rebase to an explicit rev or bookmark"
208 208 ),
209 _(b"run 'hg heads' to see all heads"),
209 _(b"run 'hg heads' to see all heads, specify destination with -d"),
210 210 ),
211 211 },
212 212 # branch have too many unbookmarked heads, no obvious destination
213 213 b'toomanyheads': {
214 214 b'merge': (
215 215 _(b"branch '%s' has %d heads - please merge with an explicit rev"),
216 _(b"run 'hg heads .' to see heads"),
216 _(b"run 'hg heads .' to see heads, specify rev with -r"),
217 217 ),
218 218 b'rebase': (
219 219 _(b"branch '%s' has %d heads - please rebase to an explicit rev"),
220 _(b"run 'hg heads .' to see heads"),
220 _(b"run 'hg heads .' to see heads, specify destination with -d"),
221 221 ),
222 222 },
223 223 # branch have no other unbookmarked heads
224 224 b'bookmarkedheads': {
225 225 b'merge': (
226 226 _(b"heads are bookmarked - please merge with an explicit rev"),
227 _(b"run 'hg heads' to see all heads"),
227 _(b"run 'hg heads' to see all heads, specify rev with -r"),
228 228 ),
229 229 b'rebase': (
230 230 _(b"heads are bookmarked - please rebase to an explicit rev"),
231 _(b"run 'hg heads' to see all heads"),
231 _(b"run 'hg heads' to see all heads, specify destination with -d"),
232 232 ),
233 233 },
234 234 # branch have just a single heads, but there is other branches
235 235 b'nootherbranchheads': {
236 236 b'merge': (
237 237 _(b"branch '%s' has one head - please merge with an explicit rev"),
238 _(b"run 'hg heads' to see all heads"),
238 _(b"run 'hg heads' to see all heads, specify rev with -r"),
239 239 ),
240 240 b'rebase': (
241 241 _(b"branch '%s' has one head - please rebase to an explicit rev"),
242 _(b"run 'hg heads' to see all heads"),
242 _(b"run 'hg heads' to see all heads, specify destination with -d"),
243 243 ),
244 244 },
245 245 # repository have a single head
246 246 b'nootherheads': {
247 247 b'merge': (_(b'nothing to merge'), None),
248 248 b'rebase': (_(b'nothing to rebase'), None),
249 249 },
250 250 # repository have a single head and we are not on it
251 251 b'nootherheadsbehind': {
252 252 b'merge': (_(b'nothing to merge'), _(b"use 'hg update' instead")),
253 253 b'rebase': (_(b'nothing to rebase'), _(b"use 'hg update' instead")),
254 254 },
255 255 # We are not on a head
256 256 b'notatheads': {
257 257 b'merge': (
258 258 _(b'working directory not at a head revision'),
259 259 _(b"use 'hg update' or merge with an explicit revision"),
260 260 ),
261 261 b'rebase': (
262 262 _(b'working directory not at a head revision'),
263 263 _(b"use 'hg update' or rebase to an explicit revision"),
264 264 ),
265 265 },
266 266 b'emptysourceset': {
267 267 b'merge': (_(b'source set is empty'), None),
268 268 b'rebase': (_(b'source set is empty'), None),
269 269 },
270 270 b'multiplebranchessourceset': {
271 271 b'merge': (_(b'source set is rooted in multiple branches'), None),
272 272 b'rebase': (
273 273 _(b'rebaseset is rooted in multiple named branches'),
274 274 _(b'specify an explicit destination with --dest'),
275 275 ),
276 276 },
277 277 }
278 278
279 279
280 280 def _destmergebook(repo, action=b'merge', sourceset=None, destspace=None):
281 281 """find merge destination in the active bookmark case"""
282 282 node = None
283 283 bmheads = bookmarks.headsforactive(repo)
284 284 curhead = repo._bookmarks[repo._activebookmark]
285 285 if len(bmheads) == 2:
286 286 if curhead == bmheads[0]:
287 287 node = bmheads[1]
288 288 else:
289 289 node = bmheads[0]
290 290 elif len(bmheads) > 2:
291 291 msg, hint = msgdestmerge[b'toomanybookmarks'][action]
292 292 raise error.ManyMergeDestAbort(msg, hint=hint)
293 293 elif len(bmheads) <= 1:
294 294 msg, hint = msgdestmerge[b'nootherbookmarks'][action]
295 295 raise error.NoMergeDestAbort(msg, hint=hint)
296 296 assert node is not None
297 297 return node
298 298
299 299
300 300 def _destmergebranch(
301 301 repo, action=b'merge', sourceset=None, onheadcheck=True, destspace=None
302 302 ):
303 303 """find merge destination based on branch heads"""
304 304 node = None
305 305
306 306 if sourceset is None:
307 307 sourceset = [repo[repo.dirstate.p1()].rev()]
308 308 branch = repo.dirstate.branch()
309 309 elif not sourceset:
310 310 msg, hint = msgdestmerge[b'emptysourceset'][action]
311 311 raise error.NoMergeDestAbort(msg, hint=hint)
312 312 else:
313 313 branch = None
314 314 for ctx in repo.set(b'roots(%ld::%ld)', sourceset, sourceset):
315 315 if branch is not None and ctx.branch() != branch:
316 316 msg, hint = msgdestmerge[b'multiplebranchessourceset'][action]
317 317 raise error.ManyMergeDestAbort(msg, hint=hint)
318 318 branch = ctx.branch()
319 319
320 320 bheads = repo.branchheads(branch)
321 321 onhead = repo.revs(b'%ld and %ln', sourceset, bheads)
322 322 if onheadcheck and not onhead:
323 323 # Case A: working copy if not on a head. (merge only)
324 324 #
325 325 # This is probably a user mistake We bailout pointing at 'hg update'
326 326 if len(repo.heads()) <= 1:
327 327 msg, hint = msgdestmerge[b'nootherheadsbehind'][action]
328 328 else:
329 329 msg, hint = msgdestmerge[b'notatheads'][action]
330 330 raise error.Abort(msg, hint=hint)
331 331 # remove heads descendants of source from the set
332 332 bheads = list(repo.revs(b'%ln - (%ld::)', bheads, sourceset))
333 333 # filters out bookmarked heads
334 334 nbhs = list(repo.revs(b'%ld - bookmark()', bheads))
335 335
336 336 if destspace is not None:
337 337 # restrict search space
338 338 # used in the 'hg pull --rebase' case, see issue 5214.
339 339 nbhs = list(repo.revs(b'%ld and %ld', destspace, nbhs))
340 340
341 341 if len(nbhs) > 1:
342 342 # Case B: There is more than 1 other anonymous heads
343 343 #
344 344 # This means that there will be more than 1 candidate. This is
345 345 # ambiguous. We abort asking the user to pick as explicit destination
346 346 # instead.
347 347 msg, hint = msgdestmerge[b'toomanyheads'][action]
348 348 msg %= (branch, len(bheads) + 1)
349 349 raise error.ManyMergeDestAbort(msg, hint=hint)
350 350 elif not nbhs:
351 351 # Case B: There is no other anonymous heads
352 352 #
353 353 # This means that there is no natural candidate to merge with.
354 354 # We abort, with various messages for various cases.
355 355 if bheads:
356 356 msg, hint = msgdestmerge[b'bookmarkedheads'][action]
357 357 elif len(repo.heads()) > 1:
358 358 msg, hint = msgdestmerge[b'nootherbranchheads'][action]
359 359 msg %= branch
360 360 elif not onhead:
361 361 # if 'onheadcheck == False' (rebase case),
362 362 # this was not caught in Case A.
363 363 msg, hint = msgdestmerge[b'nootherheadsbehind'][action]
364 364 else:
365 365 msg, hint = msgdestmerge[b'nootherheads'][action]
366 366 raise error.NoMergeDestAbort(msg, hint=hint)
367 367 else:
368 368 node = nbhs[0]
369 369 assert node is not None
370 370 return node
371 371
372 372
373 373 def destmerge(
374 374 repo, action=b'merge', sourceset=None, onheadcheck=True, destspace=None
375 375 ):
376 376 """return the default destination for a merge
377 377
378 378 (or raise exception about why it can't pick one)
379 379
380 380 :action: the action being performed, controls emitted error message
381 381 """
382 382 # destspace is here to work around issues with `hg pull --rebase` see
383 383 # issue5214 for details
384 384 if repo._activebookmark:
385 385 node = _destmergebook(
386 386 repo, action=action, sourceset=sourceset, destspace=destspace
387 387 )
388 388 else:
389 389 node = _destmergebranch(
390 390 repo,
391 391 action=action,
392 392 sourceset=sourceset,
393 393 onheadcheck=onheadcheck,
394 394 destspace=destspace,
395 395 )
396 396 return repo[node].rev()
397 397
398 398
399 399 def desthistedit(ui, repo):
400 400 """Default base revision to edit for `hg histedit`."""
401 401 default = ui.config(b'histedit', b'defaultrev')
402 402
403 403 if default is None:
404 404 revs = stack.getstack(repo)
405 405 elif default:
406 406 revs = scmutil.revrange(repo, [default])
407 407 else:
408 408 raise error.Abort(
409 409 _(b"config option histedit.defaultrev can't be empty")
410 410 )
411 411
412 412 if revs:
413 413 # Take the first revision of the revset as the root
414 414 return revs.min()
415 415
416 416 return None
417 417
418 418
419 419 def stackbase(ui, repo):
420 420 revs = stack.getstack(repo)
421 421 return revs.first() if revs else None
422 422
423 423
424 424 def _statusotherbook(ui, repo):
425 425 bmheads = bookmarks.headsforactive(repo)
426 426 curhead = repo._bookmarks[repo._activebookmark]
427 427 if repo.revs(b'%n and parents()', curhead):
428 428 # we are on the active bookmark
429 429 bmheads = [b for b in bmheads if curhead != b]
430 430 if bmheads:
431 431 msg = _(b'%i other divergent bookmarks for "%s"\n')
432 432 ui.status(msg % (len(bmheads), repo._activebookmark))
433 433
434 434
435 435 def _statusotherbranchheads(ui, repo):
436 436 currentbranch = repo.dirstate.branch()
437 437 allheads = repo.branchheads(currentbranch, closed=True)
438 438 heads = repo.branchheads(currentbranch)
439 439 if repo.revs(b'%ln and parents()', allheads):
440 440 # we are on a head, even though it might be closed
441 441 #
442 442 # on closed otherheads
443 443 # ========= ==========
444 444 # o 0 all heads for current branch are closed
445 445 # N only descendant branch heads are closed
446 446 # x 0 there is only one non-closed branch head
447 447 # N there are some non-closed branch heads
448 448 # ========= ==========
449 449 otherheads = repo.revs(b'%ln - parents()', heads)
450 450 if repo[b'.'].closesbranch():
451 451 ui.warn(
452 452 _(
453 453 b'no open descendant heads on branch "%s", '
454 454 b'updating to a closed head\n'
455 455 )
456 456 % currentbranch
457 457 )
458 458 if otherheads:
459 459 ui.warn(
460 460 _(
461 461 b"(committing will reopen the head, "
462 462 b"use 'hg heads .' to see %i other heads)\n"
463 463 )
464 464 % (len(otherheads))
465 465 )
466 466 else:
467 467 ui.warn(
468 468 _(b'(committing will reopen branch "%s")\n') % currentbranch
469 469 )
470 470 elif otherheads:
471 471 curhead = repo[b'.']
472 472 ui.status(
473 473 _(b'updated to "%s: %s"\n')
474 474 % (curhead, curhead.description().split(b'\n')[0])
475 475 )
476 476 ui.status(
477 477 _(b'%i other heads for branch "%s"\n')
478 478 % (len(otherheads), currentbranch)
479 479 )
480 480
481 481
482 482 def statusotherdests(ui, repo):
483 483 """Print message about other head"""
484 484 # XXX we should probably include a hint:
485 485 # - about what to do
486 486 # - how to see such heads
487 487 if repo._activebookmark:
488 488 _statusotherbook(ui, repo)
489 489 else:
490 490 _statusotherbranchheads(ui, repo)
@@ -1,152 +1,152 b''
1 1 # init
2 2
3 3 $ hg init
4 4 $ echo a > a
5 5 $ hg add a
6 6 $ hg commit -m'a'
7 7 $ echo b > b
8 8 $ hg add b
9 9 $ hg commit -m'b'
10 10 $ hg up -C 0
11 11 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
12 12 $ echo c > c
13 13 $ hg add c
14 14 $ hg commit -m'c'
15 15 created new head
16 16
17 17 # test merging of diverged bookmarks
18 18 $ hg bookmark -r 1 "c@diverge"
19 19 $ hg bookmark -r 1 b
20 20 $ hg bookmark c
21 21 $ hg bookmarks
22 22 b 1:d2ae7f538514
23 23 * c 2:d36c0562f908
24 24 c@diverge 1:d2ae7f538514
25 25 $ hg merge "c@diverge"
26 26 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
27 27 (branch merge, don't forget to commit)
28 28 $ hg commit -m'merge'
29 29 $ hg bookmarks
30 30 b 1:d2ae7f538514
31 31 * c 3:b8f96cf4688b
32 32
33 33 $ hg up -C 3
34 34 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
35 35 (leaving bookmark c)
36 36 $ echo d > d
37 37 $ hg add d
38 38 $ hg commit -m'd'
39 39
40 40 $ hg up -C 3
41 41 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
42 42 $ echo e > e
43 43 $ hg add e
44 44 $ hg commit -m'e'
45 45 created new head
46 46 $ hg up -C 5
47 47 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
48 48 $ hg bookmark e
49 49 $ hg bookmarks
50 50 b 1:d2ae7f538514
51 51 c 3:b8f96cf4688b
52 52 * e 5:26bee9c5bcf3
53 53
54 54 # the picked side is bookmarked
55 55
56 56 $ hg up -C 4
57 57 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
58 58 (leaving bookmark e)
59 59 $ hg merge
60 60 abort: heads are bookmarked - please merge with an explicit rev
61 (run 'hg heads' to see all heads)
61 (run 'hg heads' to see all heads, specify rev with -r)
62 62 [255]
63 63
64 64 # our revision is bookmarked
65 65
66 66 $ hg up -C e
67 67 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
68 68 (activating bookmark e)
69 69 $ hg merge
70 70 abort: no matching bookmark to merge - please merge with an explicit rev or bookmark
71 (run 'hg heads' to see all heads)
71 (run 'hg heads' to see all heads, specify rev with -r)
72 72 [255]
73 73
74 74 # merge bookmark heads
75 75
76 76 $ hg up -C 4
77 77 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
78 78 (leaving bookmark e)
79 79 $ echo f > f
80 80 $ hg commit -Am "f"
81 81 adding f
82 82 $ hg bookmarks -r 4 "e@diverged"
83 83 $ hg up -q -C "e@diverged"
84 84 $ hg merge
85 85 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
86 86 (branch merge, don't forget to commit)
87 87 $ hg parents
88 88 changeset: 4:a0546fcfe0fb
89 89 bookmark: e@diverged
90 90 user: test
91 91 date: Thu Jan 01 00:00:00 1970 +0000
92 92 summary: d
93 93
94 94 changeset: 5:26bee9c5bcf3
95 95 bookmark: e
96 96 parent: 3:b8f96cf4688b
97 97 user: test
98 98 date: Thu Jan 01 00:00:00 1970 +0000
99 99 summary: e
100 100
101 101 $ hg up -C e
102 102 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
103 103 (activating bookmark e)
104 104 $ hg bookmarks
105 105 b 1:d2ae7f538514
106 106 c 3:b8f96cf4688b
107 107 * e 5:26bee9c5bcf3
108 108 e@diverged 4:a0546fcfe0fb
109 109 $ hg merge
110 110 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
111 111 (branch merge, don't forget to commit)
112 112 $ hg commit -m'merge'
113 113 $ hg bookmarks
114 114 b 1:d2ae7f538514
115 115 c 3:b8f96cf4688b
116 116 * e 7:ca784329f0ba
117 117
118 118 # test warning when all heads are inactive bookmarks
119 119
120 120 $ hg up -C 6
121 121 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
122 122 (leaving bookmark e)
123 123 $ echo g > g
124 124 $ hg commit -Am 'g'
125 125 adding g
126 126 $ hg bookmark -i g
127 127 $ hg bookmarks
128 128 b 1:d2ae7f538514
129 129 c 3:b8f96cf4688b
130 130 e 7:ca784329f0ba
131 131 g 8:04dd21731d95
132 132 $ hg heads
133 133 changeset: 8:04dd21731d95
134 134 bookmark: g
135 135 tag: tip
136 136 parent: 6:be381d1126a0
137 137 user: test
138 138 date: Thu Jan 01 00:00:00 1970 +0000
139 139 summary: g
140 140
141 141 changeset: 7:ca784329f0ba
142 142 bookmark: e
143 143 parent: 5:26bee9c5bcf3
144 144 parent: 4:a0546fcfe0fb
145 145 user: test
146 146 date: Thu Jan 01 00:00:00 1970 +0000
147 147 summary: merge
148 148
149 149 $ hg merge
150 150 abort: heads are bookmarked - please merge with an explicit rev
151 (run 'hg heads' to see all heads)
151 (run 'hg heads' to see all heads, specify rev with -r)
152 152 [255]
@@ -1,87 +1,87 b''
1 1 $ hgcommit() {
2 2 > hg commit -u user "$@"
3 3 > }
4 4
5 5 $ hg init clhead
6 6 $ cd clhead
7 7
8 8 $ touch foo && hg add && hgcommit -m 'foo'
9 9 adding foo
10 10 $ touch bar && hg add && hgcommit -m 'bar'
11 11 adding bar
12 12 $ touch baz && hg add && hgcommit -m 'baz'
13 13 adding baz
14 14
15 15 $ echo "flub" > foo
16 16 $ hgcommit -m "flub"
17 17 $ echo "nub" > foo
18 18 $ hgcommit -m "nub"
19 19
20 20 $ hg up -C 2
21 21 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
22 22
23 23 $ echo "c1" > c1
24 24 $ hg add c1
25 25 $ hgcommit -m "c1"
26 26 created new head
27 27 $ echo "c2" > c1
28 28 $ hgcommit -m "c2"
29 29
30 30 $ hg up -C 2
31 31 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
32 32
33 33 $ echo "d1" > d1
34 34 $ hg add d1
35 35 $ hgcommit -m "d1"
36 36 created new head
37 37 $ echo "d2" > d1
38 38 $ hgcommit -m "d2"
39 39 $ hg tag -l good
40 40
41 41 fail with three heads
42 42 $ hg up -C good
43 43 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
44 44 $ hg merge
45 45 abort: branch 'default' has 3 heads - please merge with an explicit rev
46 (run 'hg heads .' to see heads)
46 (run 'hg heads .' to see heads, specify rev with -r)
47 47 [255]
48 48
49 49 close one of the heads
50 50 $ hg up -C 6
51 51 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
52 52 $ hgcommit -m 'close this head' --close-branch
53 53
54 54 succeed with two open heads
55 55 $ hg up -C good
56 56 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
57 57 $ hg up -C good
58 58 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
59 59 $ hg merge
60 60 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
61 61 (branch merge, don't forget to commit)
62 62 $ hgcommit -m 'merged heads'
63 63
64 64 hg update -C 8
65 65 $ hg update -C 8
66 66 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
67 67
68 68 hg branch some-branch
69 69 $ hg branch some-branch
70 70 marked working directory as branch some-branch
71 71 (branches are permanent and global, did you want a bookmark?)
72 72 hg commit
73 73 $ hgcommit -m 'started some-branch'
74 74 hg commit --close-branch
75 75 $ hgcommit --close-branch -m 'closed some-branch'
76 76
77 77 hg update default
78 78 $ hg update default
79 79 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
80 80 hg merge some-branch
81 81 $ hg merge some-branch
82 82 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
83 83 (branch merge, don't forget to commit)
84 84 hg commit (no reopening of some-branch)
85 85 $ hgcommit -m 'merge with closed branch'
86 86
87 87 $ cd ..
@@ -1,175 +1,175 b''
1 1 $ hg init
2 2 $ echo a > a
3 3 $ hg commit -A -ma
4 4 adding a
5 5
6 6 $ echo b >> a
7 7 $ hg commit -mb
8 8
9 9 $ echo c >> a
10 10 $ hg commit -mc
11 11
12 12 $ hg up 1
13 13 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
14 14 $ echo d >> a
15 15 $ hg commit -md
16 16 created new head
17 17
18 18 $ hg up 1
19 19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
20 20 $ echo e >> a
21 21 $ hg commit -me
22 22 created new head
23 23
24 24 $ hg up 1
25 25 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
26 26
27 27 Should fail because not at a head:
28 28
29 29 $ hg merge
30 30 abort: working directory not at a head revision
31 31 (use 'hg update' or merge with an explicit revision)
32 32 [255]
33 33
34 34 $ hg up
35 35 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
36 36 updated to "f25cbe84d8b3: e"
37 37 2 other heads for branch "default"
38 38
39 39 Should fail because > 2 heads:
40 40
41 41 $ HGMERGE=internal:other; export HGMERGE
42 42 $ hg merge
43 43 abort: branch 'default' has 3 heads - please merge with an explicit rev
44 (run 'hg heads .' to see heads)
44 (run 'hg heads .' to see heads, specify rev with -r)
45 45 [255]
46 46
47 47 Should succeed:
48 48
49 49 $ hg merge 2
50 50 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
51 51 (branch merge, don't forget to commit)
52 52 $ hg id -Tjson
53 53 [
54 54 {
55 55 "bookmarks": [],
56 56 "branch": "default",
57 57 "dirty": "+",
58 58 "id": "f25cbe84d8b320e298e7703f18a25a3959518c23+2d95304fed5d89bc9d70b2a0d02f0d567469c3ab+",
59 59 "node": "ffffffffffffffffffffffffffffffffffffffff",
60 60 "parents": ["f25cbe84d8b320e298e7703f18a25a3959518c23", "2d95304fed5d89bc9d70b2a0d02f0d567469c3ab"],
61 61 "tags": ["tip"]
62 62 }
63 63 ]
64 64 $ hg commit -mm1
65 65
66 66 Should succeed - 2 heads:
67 67
68 68 $ hg merge -P
69 69 changeset: 3:ea9ff125ff88
70 70 parent: 1:1846eede8b68
71 71 user: test
72 72 date: Thu Jan 01 00:00:00 1970 +0000
73 73 summary: d
74 74
75 75 $ hg merge
76 76 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
77 77 (branch merge, don't forget to commit)
78 78 $ hg commit -mm2
79 79
80 80 $ hg id -r 1 -Tjson
81 81 [
82 82 {
83 83 "bookmarks": [],
84 84 "branch": "default",
85 85 "id": "1846eede8b6886d8cc8a88c96a687b7fe8f3b9d1",
86 86 "node": "1846eede8b6886d8cc8a88c96a687b7fe8f3b9d1",
87 87 "tags": []
88 88 }
89 89 ]
90 90
91 91 Should fail because at tip:
92 92
93 93 $ hg merge
94 94 abort: nothing to merge
95 95 [255]
96 96
97 97 $ hg up 0
98 98 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
99 99
100 100 Should fail because there is only one head:
101 101
102 102 $ hg merge
103 103 abort: nothing to merge
104 104 (use 'hg update' instead)
105 105 [255]
106 106
107 107 $ hg up 3
108 108 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
109 109
110 110 $ echo f >> a
111 111 $ hg branch foobranch
112 112 marked working directory as branch foobranch
113 113 (branches are permanent and global, did you want a bookmark?)
114 114 $ hg commit -mf
115 115
116 116 Should fail because merge with other branch:
117 117
118 118 $ hg merge
119 119 abort: branch 'foobranch' has one head - please merge with an explicit rev
120 (run 'hg heads' to see all heads)
120 (run 'hg heads' to see all heads, specify rev with -r)
121 121 [255]
122 122
123 123
124 124 Test for issue2043: ensure that 'merge -P' shows ancestors of 6 that
125 125 are not ancestors of 7, regardless of where their common ancestors are.
126 126
127 127 Merge preview not affected by common ancestor:
128 128
129 129 $ hg up -q 7
130 130 $ hg merge -q -P 6
131 131 2:2d95304fed5d
132 132 4:f25cbe84d8b3
133 133 5:a431fabd6039
134 134 6:e88e33f3bf62
135 135
136 136 Test experimental destination revset
137 137
138 138 $ hg log -r '_destmerge()'
139 139 abort: branch 'foobranch' has one head - please merge with an explicit rev
140 (run 'hg heads' to see all heads)
140 (run 'hg heads' to see all heads, specify rev with -r)
141 141 [255]
142 142
143 143 (on a branch with a two heads)
144 144
145 145 $ hg up 5
146 146 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
147 147 $ echo f >> a
148 148 $ hg commit -mf
149 149 created new head
150 150 $ hg log -r '_destmerge()'
151 151 changeset: 6:e88e33f3bf62
152 152 parent: 5:a431fabd6039
153 153 parent: 3:ea9ff125ff88
154 154 user: test
155 155 date: Thu Jan 01 00:00:00 1970 +0000
156 156 summary: m2
157 157
158 158
159 159 (from the other head)
160 160
161 161 $ hg log -r '_destmerge(e88e33f3bf62)'
162 162 changeset: 8:b613918999e2
163 163 tag: tip
164 164 parent: 5:a431fabd6039
165 165 user: test
166 166 date: Thu Jan 01 00:00:00 1970 +0000
167 167 summary: f
168 168
169 169
170 170 (from unrelated branch)
171 171
172 172 $ hg log -r '_destmerge(foobranch)'
173 173 abort: branch 'foobranch' has one head - please merge with an explicit rev
174 (run 'hg heads' to see all heads)
174 (run 'hg heads' to see all heads, specify rev with -r)
175 175 [255]
@@ -1,534 +1,534 b''
1 1 $ branchcache=.hg/cache/branch2
2 2
3 3 $ listbranchcaches() {
4 4 > for f in .hg/cache/branch2*;
5 5 > do echo === $f ===;
6 6 > cat $f;
7 7 > done;
8 8 > }
9 9 $ purgebranchcaches() {
10 10 > rm .hg/cache/branch2*
11 11 > }
12 12
13 13 $ hg init t
14 14 $ cd t
15 15
16 16 $ hg branches
17 17 $ echo foo > a
18 18 $ hg add a
19 19 $ hg ci -m "initial"
20 20 $ hg branch foo
21 21 marked working directory as branch foo
22 22 (branches are permanent and global, did you want a bookmark?)
23 23 $ hg branch
24 24 foo
25 25 $ hg ci -m "add branch name"
26 26 $ hg branch bar
27 27 marked working directory as branch bar
28 28 $ hg ci -m "change branch name"
29 29
30 30 Branch shadowing:
31 31
32 32 $ hg branch default
33 33 abort: a branch of the same name already exists
34 34 (use 'hg update' to switch to it)
35 35 [255]
36 36
37 37 $ hg branch -f default
38 38 marked working directory as branch default
39 39
40 40 $ hg ci -m "clear branch name"
41 41 created new head
42 42
43 43 There should be only one default branch head
44 44
45 45 $ hg heads .
46 46 changeset: 3:1c28f494dae6
47 47 tag: tip
48 48 user: test
49 49 date: Thu Jan 01 00:00:00 1970 +0000
50 50 summary: clear branch name
51 51
52 52 Merging and branches
53 53
54 54 $ hg co foo
55 55 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
56 56 $ hg branch
57 57 foo
58 58
59 59 set existing branch name fails unless force - setting existing parent branch works without force:
60 60
61 61 $ hg branch bar
62 62 abort: a branch of the same name already exists
63 63 (use 'hg update' to switch to it)
64 64 [255]
65 65
66 66 $ hg branch -f bar
67 67 marked working directory as branch bar
68 68
69 69 $ hg branch foo
70 70 marked working directory as branch foo
71 71
72 72 $ echo bleah > a
73 73 $ hg ci -m "modify a branch"
74 74
75 75 $ hg merge default
76 76 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
77 77 (branch merge, don't forget to commit)
78 78
79 79 $ hg branch
80 80 foo
81 81
82 82 set existing branch name where branch head is ancestor:
83 83
84 84 $ hg branch bar
85 85 abort: a branch of the same name already exists
86 86 (use 'hg update' to switch to it)
87 87 [255]
88 88
89 89 set (other) parent branch as branch name
90 90
91 91 $ hg branch default
92 92 marked working directory as branch default
93 93
94 94 set (first) parent branch as branch name
95 95
96 96 $ hg branch foo
97 97 marked working directory as branch foo
98 98
99 99 $ hg ci -m "merge"
100 100
101 101 $ hg log -G -T '{rev}:{node|short} {branch} {desc}\n'
102 102 @ 5:530046499edf foo merge
103 103 |\
104 104 | o 4:adf1a74a7f7b foo modify a branch
105 105 | |
106 106 o | 3:1c28f494dae6 default clear branch name
107 107 | |
108 108 o | 2:c21617b13b22 bar change branch name
109 109 |/
110 110 o 1:6c0e42da283a foo add branch name
111 111 |
112 112 o 0:db01e8ea3388 default initial
113 113
114 114 $ hg branches
115 115 foo 5:530046499edf
116 116 default 3:1c28f494dae6 (inactive)
117 117 bar 2:c21617b13b22 (inactive)
118 118
119 119 $ hg branches -q
120 120 foo
121 121 default
122 122 bar
123 123
124 124 Test for invalid branch cache:
125 125
126 126 $ hg rollback
127 127 repository tip rolled back to revision 4 (undo commit)
128 128 working directory now based on revisions 4 and 3
129 129
130 130 $ cp ${branchcache}-served .hg/bc-invalid
131 131
132 132 $ hg log -r foo
133 133 changeset: 4:adf1a74a7f7b
134 134 branch: foo
135 135 tag: tip
136 136 parent: 1:6c0e42da283a
137 137 user: test
138 138 date: Thu Jan 01 00:00:00 1970 +0000
139 139 summary: modify a branch
140 140
141 141 $ cp .hg/bc-invalid $branchcache
142 142
143 143 $ hg --debug log -r foo
144 144 changeset: 4:adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6
145 145 branch: foo
146 146 tag: tip
147 147 phase: draft
148 148 parent: 1:6c0e42da283a56b5edc5b4fadb491365ec7f5fa8
149 149 parent: -1:0000000000000000000000000000000000000000
150 150 manifest: 1:8c342a37dfba0b3d3ce073562a00d8a813c54ffe
151 151 user: test
152 152 date: Thu Jan 01 00:00:00 1970 +0000
153 153 files: a
154 154 extra: branch=foo
155 155 description:
156 156 modify a branch
157 157
158 158
159 159 $ purgebranchcaches
160 160 $ echo corrupted > $branchcache
161 161
162 162 $ hg log -qr foo
163 163 4:adf1a74a7f7b
164 164
165 165 $ listbranchcaches
166 166 === .hg/cache/branch2 ===
167 167 corrupted
168 168 === .hg/cache/branch2-served ===
169 169 adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 4
170 170 c21617b13b220988e7a2e26290fbe4325ffa7139 o bar
171 171 1c28f494dae69a2f8fc815059d257eccf3fcfe75 o default
172 172 adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 o foo
173 173
174 174 Push should update the branch cache:
175 175
176 176 $ hg init ../target
177 177
178 178 Pushing just rev 0:
179 179
180 180 $ hg push -qr 0 ../target
181 181
182 182 $ (cd ../target/; listbranchcaches)
183 183 === .hg/cache/branch2-base ===
184 184 db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 0
185 185 db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 o default
186 186
187 187 Pushing everything:
188 188
189 189 $ hg push -qf ../target
190 190
191 191 $ (cd ../target/; listbranchcaches)
192 192 === .hg/cache/branch2-base ===
193 193 adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 4
194 194 c21617b13b220988e7a2e26290fbe4325ffa7139 o bar
195 195 1c28f494dae69a2f8fc815059d257eccf3fcfe75 o default
196 196 adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 o foo
197 197
198 198 Update with no arguments: tipmost revision of the current branch:
199 199
200 200 $ hg up -q -C 0
201 201 $ hg up -q
202 202 $ hg id
203 203 1c28f494dae6
204 204
205 205 $ hg up -q 1
206 206 $ hg up -q
207 207 $ hg id
208 208 adf1a74a7f7b (foo) tip
209 209
210 210 $ hg branch foobar
211 211 marked working directory as branch foobar
212 212
213 213 $ hg up
214 214 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
215 215
216 216 Fast-forward merge:
217 217
218 218 $ hg branch ff
219 219 marked working directory as branch ff
220 220
221 221 $ echo ff > ff
222 222 $ hg ci -Am'fast forward'
223 223 adding ff
224 224
225 225 $ hg up foo
226 226 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
227 227
228 228 $ hg merge ff
229 229 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
230 230 (branch merge, don't forget to commit)
231 231
232 232 $ hg branch
233 233 foo
234 234 $ hg commit -m'Merge ff into foo'
235 235 $ hg parents
236 236 changeset: 6:185ffbfefa30
237 237 branch: foo
238 238 tag: tip
239 239 parent: 4:adf1a74a7f7b
240 240 parent: 5:1a3c27dc5e11
241 241 user: test
242 242 date: Thu Jan 01 00:00:00 1970 +0000
243 243 summary: Merge ff into foo
244 244
245 245 $ hg manifest
246 246 a
247 247 ff
248 248
249 249
250 250 Test merging, add 3 default heads and one test head:
251 251
252 252 $ cd ..
253 253 $ hg init merges
254 254 $ cd merges
255 255 $ echo a > a
256 256 $ hg ci -Ama
257 257 adding a
258 258
259 259 $ echo b > b
260 260 $ hg ci -Amb
261 261 adding b
262 262
263 263 $ hg up 0
264 264 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
265 265 $ echo c > c
266 266 $ hg ci -Amc
267 267 adding c
268 268 created new head
269 269
270 270 $ hg up 0
271 271 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
272 272 $ echo d > d
273 273 $ hg ci -Amd
274 274 adding d
275 275 created new head
276 276
277 277 $ hg up 0
278 278 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
279 279 $ hg branch test
280 280 marked working directory as branch test
281 281 (branches are permanent and global, did you want a bookmark?)
282 282 $ echo e >> e
283 283 $ hg ci -Ame
284 284 adding e
285 285
286 286 $ hg log
287 287 changeset: 4:3a1e01ed1df4
288 288 branch: test
289 289 tag: tip
290 290 parent: 0:cb9a9f314b8b
291 291 user: test
292 292 date: Thu Jan 01 00:00:00 1970 +0000
293 293 summary: e
294 294
295 295 changeset: 3:980f7dc84c29
296 296 parent: 0:cb9a9f314b8b
297 297 user: test
298 298 date: Thu Jan 01 00:00:00 1970 +0000
299 299 summary: d
300 300
301 301 changeset: 2:d36c0562f908
302 302 parent: 0:cb9a9f314b8b
303 303 user: test
304 304 date: Thu Jan 01 00:00:00 1970 +0000
305 305 summary: c
306 306
307 307 changeset: 1:d2ae7f538514
308 308 user: test
309 309 date: Thu Jan 01 00:00:00 1970 +0000
310 310 summary: b
311 311
312 312 changeset: 0:cb9a9f314b8b
313 313 user: test
314 314 date: Thu Jan 01 00:00:00 1970 +0000
315 315 summary: a
316 316
317 317 Implicit merge with test branch as parent:
318 318
319 319 $ hg merge
320 320 abort: branch 'test' has one head - please merge with an explicit rev
321 (run 'hg heads' to see all heads)
321 (run 'hg heads' to see all heads, specify rev with -r)
322 322 [255]
323 323 $ hg up -C default
324 324 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
325 325
326 326 Implicit merge with default branch as parent:
327 327
328 328 $ hg merge
329 329 abort: branch 'default' has 3 heads - please merge with an explicit rev
330 (run 'hg heads .' to see heads)
330 (run 'hg heads .' to see heads, specify rev with -r)
331 331 [255]
332 332
333 333 3 branch heads, explicit merge required:
334 334
335 335 $ hg merge 2
336 336 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
337 337 (branch merge, don't forget to commit)
338 338 $ hg ci -m merge
339 339
340 340 2 branch heads, implicit merge works:
341 341
342 342 $ hg merge
343 343 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
344 344 (branch merge, don't forget to commit)
345 345
346 346 $ cd ..
347 347
348 348 We expect that bare update on new branch, updates to parent
349 349
350 350 $ hg init bareupdateonnewbranch
351 351 $ cd bareupdateonnewbranch
352 352 $ hg update
353 353 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
354 354 $ touch a
355 355 $ hg commit -A -m "a"
356 356 adding a
357 357 $ touch b
358 358 $ hg commit -A -m "b"
359 359 adding b
360 360 $ touch c
361 361 $ hg commit -A -m "c"
362 362 adding c
363 363 $ hg update -r 1
364 364 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
365 365 $ hg log -G
366 366 o changeset: 2:991a3460af53
367 367 | tag: tip
368 368 | user: test
369 369 | date: Thu Jan 01 00:00:00 1970 +0000
370 370 | summary: c
371 371 |
372 372 @ changeset: 1:0e067c57feba
373 373 | user: test
374 374 | date: Thu Jan 01 00:00:00 1970 +0000
375 375 | summary: b
376 376 |
377 377 o changeset: 0:3903775176ed
378 378 user: test
379 379 date: Thu Jan 01 00:00:00 1970 +0000
380 380 summary: a
381 381
382 382 $ hg branch dev
383 383 marked working directory as branch dev
384 384 (branches are permanent and global, did you want a bookmark?)
385 385 $ hg update
386 386 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
387 387 $ hg summary
388 388 parent: 1:0e067c57feba
389 389 b
390 390 branch: dev
391 391 commit: (new branch)
392 392 update: (current)
393 393 phases: 3 draft
394 394
395 395 $ cd ..
396 396
397 397 We need special handling for repositories with no "default" branch because
398 398 "null" revision belongs to non-existent "default" branch.
399 399
400 400 $ hg init nodefault
401 401 $ cd nodefault
402 402 $ hg branch -q foo
403 403 $ touch 0
404 404 $ hg ci -Aqm0
405 405 $ touch 1
406 406 $ hg ci -Aqm1
407 407 $ hg update -qr0
408 408 $ hg branch -q bar
409 409 $ touch 2
410 410 $ hg ci -Aqm2
411 411 $ hg update -qr0
412 412 $ hg branch -q baz
413 413 $ touch 3
414 414 $ hg ci -Aqm3
415 415 $ hg ci --close-branch -m 'close baz'
416 416 $ hg update -q null
417 417 $ hg log -GT'{rev} {branch}\n'
418 418 _ 4 baz
419 419 |
420 420 o 3 baz
421 421 |
422 422 | o 2 bar
423 423 |/
424 424 | o 1 foo
425 425 |/
426 426 o 0 foo
427 427
428 428
429 429 a) updating from "null" should bring us to the tip-most branch head as
430 430 there is no "default" branch:
431 431
432 432 $ hg update -q null
433 433 $ hg id -bn
434 434 -1 default
435 435 $ hg update
436 436 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
437 437 $ hg id -bn
438 438 2 bar
439 439
440 440 b) but if we are at uncommitted "default" branch, we should stick to the
441 441 current revision:
442 442
443 443 $ hg update -q 0
444 444 $ hg branch default
445 445 marked working directory as branch default
446 446 $ hg id -bn
447 447 0 default
448 448 $ hg update
449 449 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
450 450 $ hg id -bn
451 451 0 default
452 452
453 453 c) also, if we have uncommitted branch at "null", we should stick to it:
454 454
455 455 $ hg update -q null
456 456 $ hg branch new
457 457 marked working directory as branch new
458 458 $ hg id -bn
459 459 -1 new
460 460 $ hg update
461 461 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
462 462 $ hg id -bn
463 463 -1 new
464 464
465 465 $ cd ..
466 466
467 467 We expect that update --clean discard changes in working directory,
468 468 and updates to the head of parent branch.
469 469
470 470 $ hg init updatebareclean
471 471 $ cd updatebareclean
472 472 $ hg update --clean
473 473 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
474 474 $ touch a
475 475 $ hg commit -A -m "a"
476 476 adding a
477 477 $ touch b
478 478 $ hg commit -A -m "b"
479 479 adding b
480 480 $ touch c
481 481 $ hg commit -A -m "c"
482 482 adding c
483 483 $ hg log
484 484 changeset: 2:991a3460af53
485 485 tag: tip
486 486 user: test
487 487 date: Thu Jan 01 00:00:00 1970 +0000
488 488 summary: c
489 489
490 490 changeset: 1:0e067c57feba
491 491 user: test
492 492 date: Thu Jan 01 00:00:00 1970 +0000
493 493 summary: b
494 494
495 495 changeset: 0:3903775176ed
496 496 user: test
497 497 date: Thu Jan 01 00:00:00 1970 +0000
498 498 summary: a
499 499
500 500 $ hg update -r 1
501 501 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
502 502 $ hg branch new-branch
503 503 marked working directory as branch new-branch
504 504 (branches are permanent and global, did you want a bookmark?)
505 505 $ echo "aa" >> a
506 506 $ hg update --clean
507 507 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
508 508 $ hg status
509 509 $ hg branch
510 510 default
511 511 $ hg parent
512 512 changeset: 2:991a3460af53
513 513 tag: tip
514 514 user: test
515 515 date: Thu Jan 01 00:00:00 1970 +0000
516 516 summary: c
517 517
518 518 We expect that update --clean on non existing parent discards a new branch
519 519 and updates to the tipmost non-closed branch head
520 520
521 521 $ hg update null
522 522 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
523 523 $ hg branch newbranch
524 524 marked working directory as branch newbranch
525 525 (branches are permanent and global, did you want a bookmark?)
526 526 $ hg update -C
527 527 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
528 528 $ hg summary
529 529 parent: 2:991a3460af53 tip
530 530 c
531 531 branch: default
532 532 commit: (clean)
533 533 update: (current)
534 534 phases: 3 draft
@@ -1,410 +1,410 b''
1 1 $ cat >> $HGRCPATH <<EOF
2 2 > [extensions]
3 3 > rebase=
4 4 >
5 5 > [phases]
6 6 > publish=False
7 7 >
8 8 > [alias]
9 9 > tglog = log -G --template "{rev}: {node|short} '{desc}' {branches}\n"
10 10 > EOF
11 11
12 12 $ hg init a
13 13 $ cd a
14 14 $ hg unbundle "$TESTDIR/bundles/rebase.hg"
15 15 adding changesets
16 16 adding manifests
17 17 adding file changes
18 18 added 8 changesets with 7 changes to 7 files (+2 heads)
19 19 new changesets cd010b8cd998:02de42196ebe (8 drafts)
20 20 (run 'hg heads' to see heads, 'hg merge' to merge)
21 21 $ hg up tip
22 22 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
23 23 $ cd ..
24 24
25 25 $ hg clone -q -u . a a1
26 26
27 27 $ cd a1
28 28
29 29 $ hg update 3
30 30 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
31 31 $ hg branch dev-one
32 32 marked working directory as branch dev-one
33 33 (branches are permanent and global, did you want a bookmark?)
34 34 $ hg ci -m 'dev-one named branch'
35 35
36 36 $ hg update 7
37 37 2 files updated, 0 files merged, 3 files removed, 0 files unresolved
38 38 $ hg branch dev-two
39 39 marked working directory as branch dev-two
40 40
41 41 $ echo x > x
42 42
43 43 $ hg add x
44 44
45 45 $ hg ci -m 'dev-two named branch'
46 46
47 47 $ hg tglog
48 48 @ 9: cb039b7cae8e 'dev-two named branch' dev-two
49 49 |
50 50 | o 8: 643fc9128048 'dev-one named branch' dev-one
51 51 | |
52 52 o | 7: 02de42196ebe 'H'
53 53 | |
54 54 +---o 6: eea13746799a 'G'
55 55 | | |
56 56 o | | 5: 24b6387c8c8c 'F'
57 57 | | |
58 58 +---o 4: 9520eea781bc 'E'
59 59 | |
60 60 | o 3: 32af7686d403 'D'
61 61 | |
62 62 | o 2: 5fddd98957c8 'C'
63 63 | |
64 64 | o 1: 42ccdea3bb16 'B'
65 65 |/
66 66 o 0: cd010b8cd998 'A'
67 67
68 68
69 69 Branch name containing a dash (issue3181)
70 70
71 71 $ hg rebase -b dev-two -d dev-one --keepbranches
72 72 rebasing 5:24b6387c8c8c "F"
73 73 rebasing 6:eea13746799a "G"
74 74 rebasing 7:02de42196ebe "H"
75 75 rebasing 9:cb039b7cae8e "dev-two named branch" (tip)
76 76 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/24b6387c8c8c-24cb8001-rebase.hg
77 77
78 78 $ hg tglog
79 79 @ 9: 9e70cd31750f 'dev-two named branch' dev-two
80 80 |
81 81 o 8: 31d0e4ba75e6 'H'
82 82 |
83 83 | o 7: 4b988a958030 'G'
84 84 |/|
85 85 o | 6: 24de4aff8e28 'F'
86 86 | |
87 87 o | 5: 643fc9128048 'dev-one named branch' dev-one
88 88 | |
89 89 | o 4: 9520eea781bc 'E'
90 90 | |
91 91 o | 3: 32af7686d403 'D'
92 92 | |
93 93 o | 2: 5fddd98957c8 'C'
94 94 | |
95 95 o | 1: 42ccdea3bb16 'B'
96 96 |/
97 97 o 0: cd010b8cd998 'A'
98 98
99 99 $ hg rebase -s dev-one -d 0 --keepbranches
100 100 rebasing 5:643fc9128048 "dev-one named branch"
101 101 rebasing 6:24de4aff8e28 "F"
102 102 rebasing 7:4b988a958030 "G"
103 103 rebasing 8:31d0e4ba75e6 "H"
104 104 rebasing 9:9e70cd31750f "dev-two named branch" (tip)
105 105 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/643fc9128048-c4ee9ef5-rebase.hg
106 106
107 107 $ hg tglog
108 108 @ 9: 59c2e59309fe 'dev-two named branch' dev-two
109 109 |
110 110 o 8: 904590360559 'H'
111 111 |
112 112 | o 7: 1a1e6f72ec38 'G'
113 113 |/|
114 114 o | 6: 42aa3cf0fa7a 'F'
115 115 | |
116 116 o | 5: bc8139ee757c 'dev-one named branch' dev-one
117 117 | |
118 118 | o 4: 9520eea781bc 'E'
119 119 |/
120 120 | o 3: 32af7686d403 'D'
121 121 | |
122 122 | o 2: 5fddd98957c8 'C'
123 123 | |
124 124 | o 1: 42ccdea3bb16 'B'
125 125 |/
126 126 o 0: cd010b8cd998 'A'
127 127
128 128 $ hg update 3
129 129 3 files updated, 0 files merged, 3 files removed, 0 files unresolved
130 130 $ hg branch -f dev-one
131 131 marked working directory as branch dev-one
132 132 $ hg ci -m 'dev-one named branch'
133 133 created new head
134 134
135 135 $ hg tglog
136 136 @ 10: 643fc9128048 'dev-one named branch' dev-one
137 137 |
138 138 | o 9: 59c2e59309fe 'dev-two named branch' dev-two
139 139 | |
140 140 | o 8: 904590360559 'H'
141 141 | |
142 142 | | o 7: 1a1e6f72ec38 'G'
143 143 | |/|
144 144 | o | 6: 42aa3cf0fa7a 'F'
145 145 | | |
146 146 | o | 5: bc8139ee757c 'dev-one named branch' dev-one
147 147 | | |
148 148 | | o 4: 9520eea781bc 'E'
149 149 | |/
150 150 o | 3: 32af7686d403 'D'
151 151 | |
152 152 o | 2: 5fddd98957c8 'C'
153 153 | |
154 154 o | 1: 42ccdea3bb16 'B'
155 155 |/
156 156 o 0: cd010b8cd998 'A'
157 157
158 158 $ hg rebase -b 'max(branch("dev-two"))' -d dev-one --keepbranches
159 159 rebasing 5:bc8139ee757c "dev-one named branch"
160 160 note: not rebasing 5:bc8139ee757c "dev-one named branch", its destination already has all its changes
161 161 rebasing 6:42aa3cf0fa7a "F"
162 162 rebasing 7:1a1e6f72ec38 "G"
163 163 rebasing 8:904590360559 "H"
164 164 rebasing 9:59c2e59309fe "dev-two named branch"
165 165 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/bc8139ee757c-f11c1080-rebase.hg
166 166
167 167 $ hg tglog
168 168 o 9: 71325f8bc082 'dev-two named branch' dev-two
169 169 |
170 170 o 8: 12b2bc666e20 'H'
171 171 |
172 172 | o 7: 549f007a9f5f 'G'
173 173 |/|
174 174 o | 6: 679f28760620 'F'
175 175 | |
176 176 @ | 5: 643fc9128048 'dev-one named branch' dev-one
177 177 | |
178 178 | o 4: 9520eea781bc 'E'
179 179 | |
180 180 o | 3: 32af7686d403 'D'
181 181 | |
182 182 o | 2: 5fddd98957c8 'C'
183 183 | |
184 184 o | 1: 42ccdea3bb16 'B'
185 185 |/
186 186 o 0: cd010b8cd998 'A'
187 187
188 188 $ hg rebase -s 'max(branch("dev-one"))' -d 0 --keepbranches
189 189 rebasing 5:643fc9128048 "dev-one named branch"
190 190 rebasing 6:679f28760620 "F"
191 191 rebasing 7:549f007a9f5f "G"
192 192 rebasing 8:12b2bc666e20 "H"
193 193 rebasing 9:71325f8bc082 "dev-two named branch" (tip)
194 194 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/643fc9128048-6cdd1a52-rebase.hg
195 195
196 196 $ hg tglog
197 197 o 9: 3944801ae4ea 'dev-two named branch' dev-two
198 198 |
199 199 o 8: 8e279d293175 'H'
200 200 |
201 201 | o 7: aeefee77ab01 'G'
202 202 |/|
203 203 o | 6: e908b85f3729 'F'
204 204 | |
205 205 @ | 5: bc8139ee757c 'dev-one named branch' dev-one
206 206 | |
207 207 | o 4: 9520eea781bc 'E'
208 208 |/
209 209 | o 3: 32af7686d403 'D'
210 210 | |
211 211 | o 2: 5fddd98957c8 'C'
212 212 | |
213 213 | o 1: 42ccdea3bb16 'B'
214 214 |/
215 215 o 0: cd010b8cd998 'A'
216 216
217 217 $ hg up -r 0 > /dev/null
218 218
219 219 Rebasing descendant onto ancestor across different named branches
220 220
221 221 $ hg rebase -s 1 -d 9 --keepbranches
222 222 rebasing 1:42ccdea3bb16 "B"
223 223 rebasing 2:5fddd98957c8 "C"
224 224 rebasing 3:32af7686d403 "D"
225 225 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/42ccdea3bb16-3cb021d3-rebase.hg
226 226
227 227 $ hg tglog
228 228 o 9: e9f862ce8bad 'D'
229 229 |
230 230 o 8: a0d543090fa4 'C'
231 231 |
232 232 o 7: 3bdb949809d9 'B'
233 233 |
234 234 o 6: 3944801ae4ea 'dev-two named branch' dev-two
235 235 |
236 236 o 5: 8e279d293175 'H'
237 237 |
238 238 | o 4: aeefee77ab01 'G'
239 239 |/|
240 240 o | 3: e908b85f3729 'F'
241 241 | |
242 242 o | 2: bc8139ee757c 'dev-one named branch' dev-one
243 243 | |
244 244 | o 1: 9520eea781bc 'E'
245 245 |/
246 246 @ 0: cd010b8cd998 'A'
247 247
248 248 $ hg rebase -s 5 -d 6
249 249 abort: source and destination form a cycle
250 250 [255]
251 251
252 252 $ hg rebase -s 6 -d 5
253 253 rebasing 6:3944801ae4ea "dev-two named branch"
254 254 rebasing 7:3bdb949809d9 "B"
255 255 rebasing 8:a0d543090fa4 "C"
256 256 rebasing 9:e9f862ce8bad "D" (tip)
257 257 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/3944801ae4ea-fb46ed74-rebase.hg
258 258
259 259 $ hg tglog
260 260 o 9: e522577ccdbd 'D'
261 261 |
262 262 o 8: 810110211f50 'C'
263 263 |
264 264 o 7: 160b0930ccc6 'B'
265 265 |
266 266 o 6: c57724c84928 'dev-two named branch'
267 267 |
268 268 o 5: 8e279d293175 'H'
269 269 |
270 270 | o 4: aeefee77ab01 'G'
271 271 |/|
272 272 o | 3: e908b85f3729 'F'
273 273 | |
274 274 o | 2: bc8139ee757c 'dev-one named branch' dev-one
275 275 | |
276 276 | o 1: 9520eea781bc 'E'
277 277 |/
278 278 @ 0: cd010b8cd998 'A'
279 279
280 280
281 281 Reopen branch by rebase
282 282
283 283 $ hg up -qr3
284 284 $ hg branch -q b
285 285 $ hg ci -m 'create b'
286 286 $ hg ci -m 'close b' --close
287 287 $ hg rebase -b 8 -d b
288 288 reopening closed branch head 2b586e70108d
289 289 rebasing 5:8e279d293175 "H"
290 290 rebasing 6:c57724c84928 "dev-two named branch"
291 291 rebasing 7:160b0930ccc6 "B"
292 292 rebasing 8:810110211f50 "C"
293 293 rebasing 9:e522577ccdbd "D"
294 294 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/8e279d293175-b023e27c-rebase.hg
295 295
296 296 $ cd ..
297 297
298 298 Rebase to other head on branch
299 299
300 300 Set up a case:
301 301
302 302 $ hg init case1
303 303 $ cd case1
304 304 $ touch f
305 305 $ hg ci -qAm0
306 306 $ hg branch -q b
307 307 $ echo >> f
308 308 $ hg ci -qAm 'b1'
309 309 $ hg up -qr -2
310 310 $ hg branch -qf b
311 311 $ hg ci -qm 'b2'
312 312 $ hg up -qr -3
313 313 $ hg branch -q c
314 314 $ hg ci -m 'c1'
315 315
316 316 $ hg tglog
317 317 @ 3: c062e3ecd6c6 'c1' c
318 318 |
319 319 | o 2: 792845bb77ee 'b2' b
320 320 |/
321 321 | o 1: 40039acb7ca5 'b1' b
322 322 |/
323 323 o 0: d681519c3ea7 '0'
324 324
325 325 $ hg clone -q . ../case2
326 326
327 327 rebase 'b2' to another lower branch head
328 328
329 329 $ hg up -qr 2
330 330 $ hg rebase
331 331 rebasing 2:792845bb77ee "b2"
332 332 note: not rebasing 2:792845bb77ee "b2", its destination already has all its changes
333 333 saved backup bundle to $TESTTMP/case1/.hg/strip-backup/792845bb77ee-627120ee-rebase.hg
334 334 $ hg tglog
335 335 o 2: c062e3ecd6c6 'c1' c
336 336 |
337 337 | @ 1: 40039acb7ca5 'b1' b
338 338 |/
339 339 o 0: d681519c3ea7 '0'
340 340
341 341
342 342 rebase 'b1' on top of the tip of the branch ('b2') - ignoring the tip branch ('c1')
343 343
344 344 $ cd ../case2
345 345 $ hg up -qr 1
346 346 $ hg rebase
347 347 rebasing 1:40039acb7ca5 "b1"
348 348 saved backup bundle to $TESTTMP/case2/.hg/strip-backup/40039acb7ca5-342b72d1-rebase.hg
349 349 $ hg tglog
350 350 @ 3: 76abc1c6f8c7 'b1' b
351 351 |
352 352 | o 2: c062e3ecd6c6 'c1' c
353 353 | |
354 354 o | 1: 792845bb77ee 'b2' b
355 355 |/
356 356 o 0: d681519c3ea7 '0'
357 357
358 358
359 359 rebase 'c1' to the branch head 'c2' that is closed
360 360
361 361 $ hg branch -qf c
362 362 $ hg ci -qm 'c2 closed' --close
363 363 $ hg up -qr 2
364 364 $ hg tglog
365 365 _ 4: 8427af5d86f2 'c2 closed' c
366 366 |
367 367 o 3: 76abc1c6f8c7 'b1' b
368 368 |
369 369 | @ 2: c062e3ecd6c6 'c1' c
370 370 | |
371 371 o | 1: 792845bb77ee 'b2' b
372 372 |/
373 373 o 0: d681519c3ea7 '0'
374 374
375 375 $ hg rebase
376 376 abort: branch 'c' has one head - please rebase to an explicit rev
377 (run 'hg heads' to see all heads)
377 (run 'hg heads' to see all heads, specify destination with -d)
378 378 [255]
379 379 $ hg tglog
380 380 _ 4: 8427af5d86f2 'c2 closed' c
381 381 |
382 382 o 3: 76abc1c6f8c7 'b1' b
383 383 |
384 384 | @ 2: c062e3ecd6c6 'c1' c
385 385 | |
386 386 o | 1: 792845bb77ee 'b2' b
387 387 |/
388 388 o 0: d681519c3ea7 '0'
389 389
390 390
391 391 $ hg up -cr 1
392 392 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
393 393 $ hg branch x
394 394 marked working directory as branch x
395 395 $ hg rebase -r 3:: -d .
396 396 rebasing 3:76abc1c6f8c7 "b1"
397 397 rebasing 4:8427af5d86f2 "c2 closed" (tip)
398 398 note: not rebasing 4:8427af5d86f2 "c2 closed" (tip), its destination already has all its changes
399 399 saved backup bundle to $TESTTMP/case2/.hg/strip-backup/76abc1c6f8c7-cd698d13-rebase.hg
400 400 $ hg tglog
401 401 o 3: 117b0ed08075 'b1' x
402 402 |
403 403 | o 2: c062e3ecd6c6 'c1' c
404 404 | |
405 405 @ | 1: 792845bb77ee 'b2' b
406 406 |/
407 407 o 0: d681519c3ea7 '0'
408 408
409 409
410 410 $ cd ..
@@ -1,521 +1,521 b''
1 1 $ cat >> $HGRCPATH <<EOF
2 2 > [extensions]
3 3 > rebase=
4 4 >
5 5 > [phases]
6 6 > publish=False
7 7 >
8 8 > [alias]
9 9 > tglog = log -G --template "{rev}: {node|short} '{desc}' {branches}\n"
10 10 > EOF
11 11
12 12
13 13 $ hg init a
14 14 $ cd a
15 15 $ hg unbundle "$TESTDIR/bundles/rebase.hg"
16 16 adding changesets
17 17 adding manifests
18 18 adding file changes
19 19 added 8 changesets with 7 changes to 7 files (+2 heads)
20 20 new changesets cd010b8cd998:02de42196ebe (8 drafts)
21 21 (run 'hg heads' to see heads, 'hg merge' to merge)
22 22 $ hg up tip
23 23 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
24 24
25 25 $ echo I > I
26 26 $ hg ci -AmI
27 27 adding I
28 28
29 29 $ hg tglog
30 30 @ 8: e7ec4e813ba6 'I'
31 31 |
32 32 o 7: 02de42196ebe 'H'
33 33 |
34 34 | o 6: eea13746799a 'G'
35 35 |/|
36 36 o | 5: 24b6387c8c8c 'F'
37 37 | |
38 38 | o 4: 9520eea781bc 'E'
39 39 |/
40 40 | o 3: 32af7686d403 'D'
41 41 | |
42 42 | o 2: 5fddd98957c8 'C'
43 43 | |
44 44 | o 1: 42ccdea3bb16 'B'
45 45 |/
46 46 o 0: cd010b8cd998 'A'
47 47
48 48 $ cd ..
49 49
50 50 Version with only two heads (to allow default destination to work)
51 51
52 52 $ hg clone -q -u . a a2heads -r 3 -r 8
53 53
54 54 These fail:
55 55
56 56 $ hg clone -q -u . a a0
57 57 $ cd a0
58 58
59 59 $ hg rebase -s 8 -d 7
60 60 nothing to rebase
61 61 [1]
62 62
63 63 $ hg rebase --continue --abort
64 64 abort: cannot use --abort with --continue
65 65 [255]
66 66
67 67 $ hg rebase --continue --collapse
68 68 abort: cannot use collapse with continue or abort
69 69 [255]
70 70
71 71 $ hg rebase --continue --dest 4
72 72 abort: abort and continue do not allow specifying revisions
73 73 [255]
74 74
75 75 $ hg rebase --base 5 --source 4
76 76 abort: cannot specify both a source and a base
77 77 [255]
78 78
79 79 $ hg rebase --rev 5 --source 4
80 80 abort: cannot specify both a revision and a source
81 81 [255]
82 82 $ hg rebase --base 5 --rev 4
83 83 abort: cannot specify both a revision and a base
84 84 [255]
85 85
86 86 $ hg rebase --base 6
87 87 abort: branch 'default' has 3 heads - please rebase to an explicit rev
88 (run 'hg heads .' to see heads)
88 (run 'hg heads .' to see heads, specify destination with -d)
89 89 [255]
90 90
91 91 $ hg rebase --rev '1 & !1' --dest 8
92 92 empty "rev" revision set - nothing to rebase
93 93 [1]
94 94
95 95 $ hg rebase --source '1 & !1' --dest 8
96 96 empty "source" revision set - nothing to rebase
97 97 [1]
98 98
99 99 $ hg rebase --base '1 & !1' --dest 8
100 100 empty "base" revision set - can't compute rebase set
101 101 [1]
102 102
103 103 $ hg rebase --dest 8
104 104 nothing to rebase - working directory parent is also destination
105 105 [1]
106 106
107 107 $ hg rebase -b . --dest 8
108 108 nothing to rebase - e7ec4e813ba6 is both "base" and destination
109 109 [1]
110 110
111 111 $ hg up -q 7
112 112
113 113 $ hg rebase --dest 8 --traceback
114 114 nothing to rebase - working directory parent is already an ancestor of destination e7ec4e813ba6
115 115 [1]
116 116
117 117 $ hg rebase --dest 8 -b.
118 118 nothing to rebase - "base" 02de42196ebe is already an ancestor of destination e7ec4e813ba6
119 119 [1]
120 120
121 121 $ hg rebase --dest '1 & !1'
122 122 abort: empty revision set
123 123 [255]
124 124
125 125 These work:
126 126
127 127 Rebase with no arguments (from 3 onto 8):
128 128
129 129 $ cd ..
130 130 $ hg clone -q -u . a2heads a1
131 131 $ cd a1
132 132 $ hg up -q -C 3
133 133
134 134 $ hg rebase
135 135 rebasing 1:42ccdea3bb16 "B"
136 136 rebasing 2:5fddd98957c8 "C"
137 137 rebasing 3:32af7686d403 "D"
138 138 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/42ccdea3bb16-3cb021d3-rebase.hg
139 139
140 140 $ hg tglog
141 141 @ 6: ed65089c18f8 'D'
142 142 |
143 143 o 5: 7621bf1a2f17 'C'
144 144 |
145 145 o 4: 9430a62369c6 'B'
146 146 |
147 147 o 3: e7ec4e813ba6 'I'
148 148 |
149 149 o 2: 02de42196ebe 'H'
150 150 |
151 151 o 1: 24b6387c8c8c 'F'
152 152 |
153 153 o 0: cd010b8cd998 'A'
154 154
155 155 Try to rollback after a rebase (fail):
156 156
157 157 $ hg rollback
158 158 no rollback information available
159 159 [1]
160 160
161 161 $ cd ..
162 162
163 163 Rebase with base == '.' => same as no arguments (from 3 onto 8):
164 164
165 165 $ hg clone -q -u 3 a2heads a2
166 166 $ cd a2
167 167
168 168 $ hg rebase --base .
169 169 rebasing 1:42ccdea3bb16 "B"
170 170 rebasing 2:5fddd98957c8 "C"
171 171 rebasing 3:32af7686d403 "D"
172 172 saved backup bundle to $TESTTMP/a2/.hg/strip-backup/42ccdea3bb16-3cb021d3-rebase.hg
173 173
174 174 $ hg tglog
175 175 @ 6: ed65089c18f8 'D'
176 176 |
177 177 o 5: 7621bf1a2f17 'C'
178 178 |
179 179 o 4: 9430a62369c6 'B'
180 180 |
181 181 o 3: e7ec4e813ba6 'I'
182 182 |
183 183 o 2: 02de42196ebe 'H'
184 184 |
185 185 o 1: 24b6387c8c8c 'F'
186 186 |
187 187 o 0: cd010b8cd998 'A'
188 188
189 189 $ cd ..
190 190
191 191
192 192 Rebase with dest == branch(.) => same as no arguments (from 3 onto 8):
193 193
194 194 $ hg clone -q -u 3 a a3
195 195 $ cd a3
196 196
197 197 $ hg rebase --dest 'branch(.)'
198 198 rebasing 1:42ccdea3bb16 "B"
199 199 rebasing 2:5fddd98957c8 "C"
200 200 rebasing 3:32af7686d403 "D"
201 201 saved backup bundle to $TESTTMP/a3/.hg/strip-backup/42ccdea3bb16-3cb021d3-rebase.hg
202 202
203 203 $ hg tglog
204 204 @ 8: ed65089c18f8 'D'
205 205 |
206 206 o 7: 7621bf1a2f17 'C'
207 207 |
208 208 o 6: 9430a62369c6 'B'
209 209 |
210 210 o 5: e7ec4e813ba6 'I'
211 211 |
212 212 o 4: 02de42196ebe 'H'
213 213 |
214 214 | o 3: eea13746799a 'G'
215 215 |/|
216 216 o | 2: 24b6387c8c8c 'F'
217 217 | |
218 218 | o 1: 9520eea781bc 'E'
219 219 |/
220 220 o 0: cd010b8cd998 'A'
221 221
222 222 $ cd ..
223 223
224 224
225 225 Specify only source (from 2 onto 8):
226 226
227 227 $ hg clone -q -u . a2heads a4
228 228 $ cd a4
229 229
230 230 $ hg rebase --source 'desc("C")'
231 231 rebasing 2:5fddd98957c8 "C"
232 232 rebasing 3:32af7686d403 "D"
233 233 saved backup bundle to $TESTTMP/a4/.hg/strip-backup/5fddd98957c8-f9244fa1-rebase.hg
234 234
235 235 $ hg tglog
236 236 o 6: 7726e9fd58f7 'D'
237 237 |
238 238 o 5: 72c8333623d0 'C'
239 239 |
240 240 @ 4: e7ec4e813ba6 'I'
241 241 |
242 242 o 3: 02de42196ebe 'H'
243 243 |
244 244 o 2: 24b6387c8c8c 'F'
245 245 |
246 246 | o 1: 42ccdea3bb16 'B'
247 247 |/
248 248 o 0: cd010b8cd998 'A'
249 249
250 250 $ cd ..
251 251
252 252
253 253 Specify only dest (from 3 onto 6):
254 254
255 255 $ hg clone -q -u 3 a a5
256 256 $ cd a5
257 257
258 258 $ hg rebase --dest 6
259 259 rebasing 1:42ccdea3bb16 "B"
260 260 rebasing 2:5fddd98957c8 "C"
261 261 rebasing 3:32af7686d403 "D"
262 262 saved backup bundle to $TESTTMP/a5/.hg/strip-backup/42ccdea3bb16-3cb021d3-rebase.hg
263 263
264 264 $ hg tglog
265 265 @ 8: 8eeb3c33ad33 'D'
266 266 |
267 267 o 7: 2327fea05063 'C'
268 268 |
269 269 o 6: e4e5be0395b2 'B'
270 270 |
271 271 | o 5: e7ec4e813ba6 'I'
272 272 | |
273 273 | o 4: 02de42196ebe 'H'
274 274 | |
275 275 o | 3: eea13746799a 'G'
276 276 |\|
277 277 | o 2: 24b6387c8c8c 'F'
278 278 | |
279 279 o | 1: 9520eea781bc 'E'
280 280 |/
281 281 o 0: cd010b8cd998 'A'
282 282
283 283 $ cd ..
284 284
285 285
286 286 Specify only base (from 1 onto 8):
287 287
288 288 $ hg clone -q -u . a2heads a6
289 289 $ cd a6
290 290
291 291 $ hg rebase --base 'desc("D")'
292 292 rebasing 1:42ccdea3bb16 "B"
293 293 rebasing 2:5fddd98957c8 "C"
294 294 rebasing 3:32af7686d403 "D"
295 295 saved backup bundle to $TESTTMP/a6/.hg/strip-backup/42ccdea3bb16-3cb021d3-rebase.hg
296 296
297 297 $ hg tglog
298 298 o 6: ed65089c18f8 'D'
299 299 |
300 300 o 5: 7621bf1a2f17 'C'
301 301 |
302 302 o 4: 9430a62369c6 'B'
303 303 |
304 304 @ 3: e7ec4e813ba6 'I'
305 305 |
306 306 o 2: 02de42196ebe 'H'
307 307 |
308 308 o 1: 24b6387c8c8c 'F'
309 309 |
310 310 o 0: cd010b8cd998 'A'
311 311
312 312 $ cd ..
313 313
314 314
315 315 Specify source and dest (from 2 onto 7):
316 316
317 317 $ hg clone -q -u . a a7
318 318 $ cd a7
319 319
320 320 $ hg rebase --source 2 --dest 7
321 321 rebasing 2:5fddd98957c8 "C"
322 322 rebasing 3:32af7686d403 "D"
323 323 saved backup bundle to $TESTTMP/a7/.hg/strip-backup/5fddd98957c8-f9244fa1-rebase.hg
324 324
325 325 $ hg tglog
326 326 o 8: 668acadedd30 'D'
327 327 |
328 328 o 7: 09eb682ba906 'C'
329 329 |
330 330 | @ 6: e7ec4e813ba6 'I'
331 331 |/
332 332 o 5: 02de42196ebe 'H'
333 333 |
334 334 | o 4: eea13746799a 'G'
335 335 |/|
336 336 o | 3: 24b6387c8c8c 'F'
337 337 | |
338 338 | o 2: 9520eea781bc 'E'
339 339 |/
340 340 | o 1: 42ccdea3bb16 'B'
341 341 |/
342 342 o 0: cd010b8cd998 'A'
343 343
344 344 $ cd ..
345 345
346 346
347 347 Specify base and dest (from 1 onto 7):
348 348
349 349 $ hg clone -q -u . a a8
350 350 $ cd a8
351 351
352 352 $ hg rebase --base 3 --dest 7
353 353 rebasing 1:42ccdea3bb16 "B"
354 354 rebasing 2:5fddd98957c8 "C"
355 355 rebasing 3:32af7686d403 "D"
356 356 saved backup bundle to $TESTTMP/a8/.hg/strip-backup/42ccdea3bb16-3cb021d3-rebase.hg
357 357
358 358 $ hg tglog
359 359 o 8: 287cc92ba5a4 'D'
360 360 |
361 361 o 7: 6824f610a250 'C'
362 362 |
363 363 o 6: 7c6027df6a99 'B'
364 364 |
365 365 | @ 5: e7ec4e813ba6 'I'
366 366 |/
367 367 o 4: 02de42196ebe 'H'
368 368 |
369 369 | o 3: eea13746799a 'G'
370 370 |/|
371 371 o | 2: 24b6387c8c8c 'F'
372 372 | |
373 373 | o 1: 9520eea781bc 'E'
374 374 |/
375 375 o 0: cd010b8cd998 'A'
376 376
377 377 $ cd ..
378 378
379 379
380 380 Specify only revs (from 2 onto 8)
381 381
382 382 $ hg clone -q -u . a2heads a9
383 383 $ cd a9
384 384
385 385 $ hg rebase --rev 'desc("C")::'
386 386 rebasing 2:5fddd98957c8 "C"
387 387 rebasing 3:32af7686d403 "D"
388 388 saved backup bundle to $TESTTMP/a9/.hg/strip-backup/5fddd98957c8-f9244fa1-rebase.hg
389 389
390 390 $ hg tglog
391 391 o 6: 7726e9fd58f7 'D'
392 392 |
393 393 o 5: 72c8333623d0 'C'
394 394 |
395 395 @ 4: e7ec4e813ba6 'I'
396 396 |
397 397 o 3: 02de42196ebe 'H'
398 398 |
399 399 o 2: 24b6387c8c8c 'F'
400 400 |
401 401 | o 1: 42ccdea3bb16 'B'
402 402 |/
403 403 o 0: cd010b8cd998 'A'
404 404
405 405 $ cd ..
406 406
407 407 Rebasing both a single revision and a merge in one command
408 408
409 409 $ hg clone -q -u . a aX
410 410 $ cd aX
411 411 $ hg rebase -r 3 -r 6 --dest 8
412 412 rebasing 3:32af7686d403 "D"
413 413 rebasing 6:eea13746799a "G"
414 414 saved backup bundle to $TESTTMP/aX/.hg/strip-backup/eea13746799a-ad273fd6-rebase.hg
415 415 $ cd ..
416 416
417 417 Test --tool parameter:
418 418
419 419 $ hg init b
420 420 $ cd b
421 421
422 422 $ echo c1 > c1
423 423 $ hg ci -Am c1
424 424 adding c1
425 425
426 426 $ echo c2 > c2
427 427 $ hg ci -Am c2
428 428 adding c2
429 429
430 430 $ hg up -q 0
431 431 $ echo c2b > c2
432 432 $ hg ci -Am c2b
433 433 adding c2
434 434 created new head
435 435
436 436 $ cd ..
437 437
438 438 $ hg clone -q -u . b b1
439 439 $ cd b1
440 440
441 441 $ hg rebase -s 2 -d 1 --tool internal:local
442 442 rebasing 2:e4e3f3546619 "c2b" (tip)
443 443 note: not rebasing 2:e4e3f3546619 "c2b" (tip), its destination already has all its changes
444 444 saved backup bundle to $TESTTMP/b1/.hg/strip-backup/e4e3f3546619-b0841178-rebase.hg
445 445
446 446 $ hg cat c2
447 447 c2
448 448
449 449 $ cd ..
450 450
451 451
452 452 $ hg clone -q -u . b b2
453 453 $ cd b2
454 454
455 455 $ hg rebase -s 2 -d 1 --tool internal:other
456 456 rebasing 2:e4e3f3546619 "c2b" (tip)
457 457 saved backup bundle to $TESTTMP/b2/.hg/strip-backup/e4e3f3546619-b0841178-rebase.hg
458 458
459 459 $ hg cat c2
460 460 c2b
461 461
462 462 $ cd ..
463 463
464 464
465 465 $ hg clone -q -u . b b3
466 466 $ cd b3
467 467
468 468 $ hg rebase -s 2 -d 1 --tool internal:fail
469 469 rebasing 2:e4e3f3546619 "c2b" (tip)
470 470 unresolved conflicts (see hg resolve, then hg rebase --continue)
471 471 [1]
472 472
473 473 $ hg summary
474 474 parent: 1:56daeba07f4b
475 475 c2
476 476 parent: 2:e4e3f3546619 tip
477 477 c2b
478 478 branch: default
479 479 commit: 1 modified, 1 unresolved (merge)
480 480 update: (current)
481 481 phases: 3 draft
482 482 rebase: 0 rebased, 1 remaining (rebase --continue)
483 483
484 484 $ hg resolve -l
485 485 U c2
486 486
487 487 $ hg resolve -m c2
488 488 (no more unresolved files)
489 489 continue: hg rebase --continue
490 490 $ hg graft --continue
491 491 abort: no graft in progress
492 492 (continue: hg rebase --continue)
493 493 [255]
494 494 $ hg rebase -c --tool internal:fail
495 495 rebasing 2:e4e3f3546619 "c2b" (tip)
496 496 note: not rebasing 2:e4e3f3546619 "c2b" (tip), its destination already has all its changes
497 497 saved backup bundle to $TESTTMP/b3/.hg/strip-backup/e4e3f3546619-b0841178-rebase.hg
498 498
499 499 $ hg rebase -i
500 500 abort: interactive history editing is supported by the 'histedit' extension (see "hg --config extensions.histedit= help -e histedit")
501 501 [255]
502 502
503 503 $ hg rebase --interactive
504 504 abort: interactive history editing is supported by the 'histedit' extension (see "hg --config extensions.histedit= help -e histedit")
505 505 [255]
506 506
507 507 $ cd ..
508 508
509 509 No common ancestor
510 510
511 511 $ hg init separaterepo
512 512 $ cd separaterepo
513 513 $ touch a
514 514 $ hg commit -Aqm a
515 515 $ hg up -q null
516 516 $ touch b
517 517 $ hg commit -Aqm b
518 518 $ hg rebase -d 0
519 519 nothing to rebase from d7486e00c6f1 to 3903775176ed
520 520 [1]
521 521 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now