##// END OF EJS Templates
rebase: properly handle unrebased revision between rebased one...
Pierre-Yves David -
r18447:7159426c default
parent child Browse files
Show More
@@ -23,6 +23,7 b' from mercurial.i18n import _'
23 import os, errno
23 import os, errno
24
24
25 nullmerge = -2
25 nullmerge = -2
26 revignored = -3
26
27
27 cmdtable = {}
28 cmdtable = {}
28 command = cmdutil.command(cmdtable)
29 command = cmdutil.command(cmdtable)
@@ -392,6 +393,15 b' def rebasenode(repo, rev, p1, state, col'
392 # have to allow merging with it.
393 # have to allow merging with it.
393 return merge.update(repo, rev, True, True, False, base, collapse)
394 return merge.update(repo, rev, True, True, False, base, collapse)
394
395
396 def nearestrebased(repo, rev, state):
397 """return the nearest ancestors of rev in the rebase result"""
398 rebased = [r for r in state if state[r] > nullmerge]
399 candidates = repo.revs('max(%ld and (::%d))', rebased, rev)
400 if candidates:
401 return state[candidates[0]]
402 else:
403 return None
404
395 def defineparents(repo, rev, target, state, targetancestors):
405 def defineparents(repo, rev, target, state, targetancestors):
396 'Return the new parent relationship of the revision that will be rebased'
406 'Return the new parent relationship of the revision that will be rebased'
397 parents = repo[rev].parents()
407 parents = repo[rev].parents()
@@ -403,6 +413,10 b' def defineparents(repo, rev, target, sta'
403 elif P1n in state:
413 elif P1n in state:
404 if state[P1n] == nullmerge:
414 if state[P1n] == nullmerge:
405 p1 = target
415 p1 = target
416 elif state[P1n] == revignored:
417 p1 = nearestrebased(repo, P1n, state)
418 if p1 is None:
419 p1 = target
406 else:
420 else:
407 p1 = state[P1n]
421 p1 = state[P1n]
408 else: # P1n external
422 else: # P1n external
@@ -415,6 +429,11 b' def defineparents(repo, rev, target, sta'
415 if P2n in state:
429 if P2n in state:
416 if p1 == target: # P1n in targetancestors or external
430 if p1 == target: # P1n in targetancestors or external
417 p1 = state[P2n]
431 p1 = state[P2n]
432 elif state[P2n] == revignored:
433 p2 = nearestrebased(repo, P2n, state)
434 if p2 is None:
435 # no ancestors rebased yet, detach
436 p2 = target
418 else:
437 else:
419 p2 = state[P2n]
438 p2 = state[P2n]
420 else: # P2n external
439 else: # P2n external
@@ -532,10 +551,10 b' def restorestatus(repo):'
532 keepbranches = bool(int(l))
551 keepbranches = bool(int(l))
533 else:
552 else:
534 oldrev, newrev = l.split(':')
553 oldrev, newrev = l.split(':')
535 if newrev != str(nullmerge):
554 if newrev in (str(nullmerge), str(revignored)):
555 state[repo[oldrev].rev()] = int(newrev)
556 else:
536 state[repo[oldrev].rev()] = repo[newrev].rev()
557 state[repo[oldrev].rev()] = repo[newrev].rev()
537 else:
538 state[repo[oldrev].rev()] = int(newrev)
539 skipped = set()
558 skipped = set()
540 # recompute the set of skipped revs
559 # recompute the set of skipped revs
541 if not collapse:
560 if not collapse:
@@ -658,6 +677,15 b' def buildstate(repo, dest, rebaseset, co'
658 for r in detachset:
677 for r in detachset:
659 if r not in state:
678 if r not in state:
660 state[r] = nullmerge
679 state[r] = nullmerge
680 if len(roots) > 1:
681 # If we have multiple roots, we may have "hole" in the rebase set.
682 # Rebase roots that descend from those "hole" should not be detached as
683 # other root are. We use the special `revignored` to inform rebase that
684 # the revision should be ignored but that `defineparent` should search
685 # a rebase destination that make sense regarding rebaset topology.
686 rebasedomain = set(repo.revs('%ld::%ld', rebaseset, rebaseset))
687 for ignored in set(rebasedomain) - set(rebaseset):
688 state[ignored] = revignored
661 return repo['.'].rev(), dest.rev(), state
689 return repo['.'].rev(), dest.rev(), state
662
690
663 def clearrebased(ui, repo, state, skipped, collapsedas=None):
691 def clearrebased(ui, repo, state, skipped, collapsedas=None):
@@ -366,11 +366,11 b' Test multiple root handling'
366
366
367 $ hg rebase --dest 4 --rev '7+11+9'
367 $ hg rebase --dest 4 --rev '7+11+9'
368 $ hg log -G
368 $ hg log -G
369 @ 14:00891d85fcfc C
369 @ 14:1e8370e38cca C
370 |
370 |
371 | o 13:102b4c1d889b D
371 | o 13:102b4c1d889b D
372 |/
372 | |
373 | o 12:bfe264faf697 H
373 o | 12:bfe264faf697 H
374 |/
374 |/
375 | o 10:7c6027df6a99 B
375 | o 10:7c6027df6a99 B
376 | |
376 | |
General Comments 0
You need to be logged in to leave comments. Login now