##// END OF EJS Templates
rebase: don't rebase obsolete commits with no successor...
Laurent Charignon -
r27012:5eac7ab5 default
parent child Browse files
Show More
@@ -32,6 +32,7 b' nullmerge = -2'
32 revignored = -3
32 revignored = -3
33 # To do with obsolescence
33 # To do with obsolescence
34 revprecursor = -4
34 revprecursor = -4
35 revpruned = -5
35
36
36 cmdtable = {}
37 cmdtable = {}
37 command = cmdutil.command(cmdtable)
38 command = cmdutil.command(cmdtable)
@@ -487,6 +488,9 b' def rebase(ui, repo, **opts):'
487 targetctx.description().split('\n', 1)[0])
488 targetctx.description().split('\n', 1)[0])
488 msg = _('note: not rebasing %s, already in destination as %s\n')
489 msg = _('note: not rebasing %s, already in destination as %s\n')
489 ui.status(msg % (desc, desctarget))
490 ui.status(msg % (desc, desctarget))
491 elif state[rev] == revpruned:
492 msg = _('note: not rebasing %s, it has no successor\n')
493 ui.status(msg % desc)
490 else:
494 else:
491 ui.status(_('already rebased %s as %s\n') %
495 ui.status(_('already rebased %s as %s\n') %
492 (desc, repo[state[rev]]))
496 (desc, repo[state[rev]]))
@@ -676,7 +680,7 b' def defineparents(repo, rev, target, sta'
676 elif p1n in state:
680 elif p1n in state:
677 if state[p1n] == nullmerge:
681 if state[p1n] == nullmerge:
678 p1 = target
682 p1 = target
679 elif state[p1n] in (revignored, revprecursor):
683 elif state[p1n] in (revignored, revprecursor, revpruned):
680 p1 = nearestrebased(repo, p1n, state)
684 p1 = nearestrebased(repo, p1n, state)
681 if p1 is None:
685 if p1 is None:
682 p1 = target
686 p1 = target
@@ -692,7 +696,7 b' def defineparents(repo, rev, target, sta'
692 if p2n in state:
696 if p2n in state:
693 if p1 == target: # p1n in targetancestors or external
697 if p1 == target: # p1n in targetancestors or external
694 p1 = state[p2n]
698 p1 = state[p2n]
695 elif state[p2n] in (revignored, revprecursor):
699 elif state[p2n] in (revignored, revprecursor, revpruned):
696 p2 = nearestrebased(repo, p2n, state)
700 p2 = nearestrebased(repo, p2n, state)
697 if p2 is None:
701 if p2 is None:
698 # no ancestors rebased yet, detach
702 # no ancestors rebased yet, detach
@@ -882,7 +886,7 b' def restorestatus(repo):'
882 else:
886 else:
883 oldrev, newrev = l.split(':')
887 oldrev, newrev = l.split(':')
884 if newrev in (str(nullmerge), str(revignored),
888 if newrev in (str(nullmerge), str(revignored),
885 str(revprecursor)):
889 str(revprecursor), str(revpruned)):
886 state[repo[oldrev].rev()] = int(newrev)
890 state[repo[oldrev].rev()] = int(newrev)
887 elif newrev == nullid:
891 elif newrev == nullid:
888 state[repo[oldrev].rev()] = revtodo
892 state[repo[oldrev].rev()] = revtodo
@@ -1066,7 +1070,10 b' def buildstate(repo, dest, rebaseset, co'
1066 for ignored in set(rebasedomain) - set(rebaseset):
1070 for ignored in set(rebasedomain) - set(rebaseset):
1067 state[ignored] = revignored
1071 state[ignored] = revignored
1068 for r in obsoletenotrebased:
1072 for r in obsoletenotrebased:
1069 state[r] = revprecursor
1073 if obsoletenotrebased[r] is None:
1074 state[r] = revpruned
1075 else:
1076 state[r] = revprecursor
1070 return repo['.'].rev(), dest.rev(), state
1077 return repo['.'].rev(), dest.rev(), state
1071
1078
1072 def clearrebased(ui, repo, state, skipped, collapsedas=None):
1079 def clearrebased(ui, repo, state, skipped, collapsedas=None):
@@ -1180,7 +1187,9 b' def _rebasedvisible(orig, repo):'
1180
1187
1181 def _computeobsoletenotrebased(repo, rebasesetrevs, dest):
1188 def _computeobsoletenotrebased(repo, rebasesetrevs, dest):
1182 """return a mapping obsolete => successor for all obsolete nodes to be
1189 """return a mapping obsolete => successor for all obsolete nodes to be
1183 rebased that have a successors in the destination"""
1190 rebased that have a successors in the destination
1191
1192 obsolete => None entries in the mapping indicate nodes with no succesor"""
1184 obsoletenotrebased = {}
1193 obsoletenotrebased = {}
1185
1194
1186 # Build a mapping successor => obsolete nodes for the obsolete
1195 # Build a mapping successor => obsolete nodes for the obsolete
@@ -1206,6 +1215,11 b' def _computeobsoletenotrebased(repo, reb'
1206 for s in allsuccessors:
1215 for s in allsuccessors:
1207 if s in ancs:
1216 if s in ancs:
1208 obsoletenotrebased[allsuccessors[s]] = s
1217 obsoletenotrebased[allsuccessors[s]] = s
1218 elif (s == allsuccessors[s] and
1219 allsuccessors.values().count(s) == 1):
1220 # plain prune
1221 obsoletenotrebased[s] = None
1222
1209 return obsoletenotrebased
1223 return obsoletenotrebased
1210
1224
1211 def summaryhook(ui, repo):
1225 def summaryhook(ui, repo):
@@ -659,3 +659,29 b' Even when the chain include missing node'
659 $ hg rebase -d 'desc(B2)'
659 $ hg rebase -d 'desc(B2)'
660 note: not rebasing 1:a8b11f55fb19 "B0", already in destination as 2:261e70097290 "B2"
660 note: not rebasing 1:a8b11f55fb19 "B0", already in destination as 2:261e70097290 "B2"
661 rebasing 5:1a79b7535141 "D" (tip)
661 rebasing 5:1a79b7535141 "D" (tip)
662 $ hg up 4
663 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
664 $ echo "O" > O
665 $ hg add O
666 $ hg commit -m O
667 $ echo "P" > P
668 $ hg add P
669 $ hg commit -m P
670 $ hg log -G
671 @ 8:8d47583e023f P
672 |
673 o 7:360bbaa7d3ce O
674 |
675 | o 6:9c48361117de D
676 | |
677 o | 4:ff2c4d47b71d C
678 |/
679 o 2:261e70097290 B2
680 |
681 o 0:4a2df7238c3b A
682
683 $ hg debugobsolete `hg log -r 7 -T '{node}\n'` --config experimental.evolution=all
684 $ hg rebase -d 6 -r "4::"
685 rebasing 4:ff2c4d47b71d "C"
686 note: not rebasing 7:360bbaa7d3ce "O", it has no successor
687 rebasing 8:8d47583e023f "P" (tip)
General Comments 0
You need to be logged in to leave comments. Login now