Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
Lint Skipped |
Unit Tests Skipped |
ui.status(_('empty "base" revision set - ' | ui.status(_('empty "base" revision set - ' | ||||
"can't compute rebase set\n")) | "can't compute rebase set\n")) | ||||
return None | return None | ||||
if destf: | if destf: | ||||
# --base does not support multiple destinations | # --base does not support multiple destinations | ||||
dest = scmutil.revsingle(repo, destf) | dest = scmutil.revsingle(repo, destf) | ||||
else: | else: | ||||
dest = repo[_destrebase(repo, base, destspace=destspace)] | dest = repo[_destrebase(repo, base, destspace=destspace)] | ||||
destf = str(dest) | destf = bytes(dest) | ||||
roots = [] # selected children of branching points | roots = [] # selected children of branching points | ||||
bpbase = {} # {branchingpoint: [origbase]} | bpbase = {} # {branchingpoint: [origbase]} | ||||
for b in base: # group bases by branching points | for b in base: # group bases by branching points | ||||
bp = repo.revs('ancestor(%d, %d)', b, dest.rev()).first() | bp = repo.revs('ancestor(%d, %d)', b, dest.rev()).first() | ||||
bpbase[bp] = bpbase.get(bp, []) + [b] | bpbase[bp] = bpbase.get(bp, []) + [b] | ||||
if None in bpbase: | if None in bpbase: | ||||
# emulate the old behavior, showing "nothing to rebase" (a better | # emulate the old behavior, showing "nothing to rebase" (a better | ||||
else: | else: | ||||
ui.status(_('nothing to rebase - working directory ' | ui.status(_('nothing to rebase - working directory ' | ||||
'parent is also destination\n')) | 'parent is also destination\n')) | ||||
elif not repo.revs('%ld - ::%d', base, dest.rev()): | elif not repo.revs('%ld - ::%d', base, dest.rev()): | ||||
if basef: | if basef: | ||||
ui.status(_('nothing to rebase - "base" %s is ' | ui.status(_('nothing to rebase - "base" %s is ' | ||||
'already an ancestor of destination ' | 'already an ancestor of destination ' | ||||
'%s\n') % | '%s\n') % | ||||
('+'.join(str(repo[r]) for r in base), | ('+'.join(bytes(repo[r]) for r in base), | ||||
dest)) | dest)) | ||||
else: | else: | ||||
ui.status(_('nothing to rebase - working ' | ui.status(_('nothing to rebase - working ' | ||||
'directory parent is already an ' | 'directory parent is already an ' | ||||
'ancestor of destination %s\n') % dest) | 'ancestor of destination %s\n') % dest) | ||||
else: # can it happen? | else: # can it happen? | ||||
ui.status(_('nothing to rebase from %s to %s\n') % | ui.status(_('nothing to rebase from %s to %s\n') % | ||||
('+'.join(str(repo[r]) for r in base), dest)) | ('+'.join(bytes(repo[r]) for r in base), dest)) | ||||
return None | return None | ||||
# If rebasing the working copy parent, force in-memory merge to be off. | # If rebasing the working copy parent, force in-memory merge to be off. | ||||
# | # | ||||
# This is because the extra work of checking out the newly rebased commit | # This is because the extra work of checking out the newly rebased commit | ||||
# outweights the benefits of rebasing in-memory, and executing an extra | # outweights the benefits of rebasing in-memory, and executing an extra | ||||
# update command adds a bit of overhead, so better to just do it on disk. In | # update command adds a bit of overhead, so better to just do it on disk. In | ||||
# all other cases leave it on. | # all other cases leave it on. | ||||
# | # | ||||
# Note that there are cases where this isn't true -- e.g., rebasing large | # Note that there are cases where this isn't true -- e.g., rebasing large | ||||
# stacks that include the WCP. However, I'm not yet sure where the cutoff | # stacks that include the WCP. However, I'm not yet sure where the cutoff | ||||
# is. | # is. | ||||
rebasingwcp = repo['.'].rev() in rebaseset | rebasingwcp = repo['.'].rev() in rebaseset | ||||
ui.log("rebase", "", rebase_rebasing_wcp=rebasingwcp) | ui.log("rebase", "", rebase_rebasing_wcp=rebasingwcp) | ||||
if rbsrt.inmemory and rebasingwcp: | if rbsrt.inmemory and rebasingwcp: | ||||
rbsrt.inmemory = False | rbsrt.inmemory = False | ||||
# Check these since we did not before. | # Check these since we did not before. | ||||
cmdutil.checkunfinished(repo) | cmdutil.checkunfinished(repo) | ||||
cmdutil.bailifchanged(repo) | cmdutil.bailifchanged(repo) | ||||
if not destf: | if not destf: | ||||
dest = repo[_destrebase(repo, rebaseset, destspace=destspace)] | dest = repo[_destrebase(repo, rebaseset, destspace=destspace)] | ||||
destf = str(dest) | destf = bytes(dest) | ||||
allsrc = revsetlang.formatspec('%ld', rebaseset) | allsrc = revsetlang.formatspec('%ld', rebaseset) | ||||
alias = {'ALLSRC': allsrc} | alias = {'ALLSRC': allsrc} | ||||
if dest is None: | if dest is None: | ||||
try: | try: | ||||
# fast path: try to resolve dest without SRC alias | # fast path: try to resolve dest without SRC alias | ||||
dest = scmutil.revsingle(repo, destf, localalias=alias) | dest = scmutil.revsingle(repo, destf, localalias=alias) | ||||
parents.add(p.rev()) | parents.add(p.rev()) | ||||
if not parents: | if not parents: | ||||
return nullrev | return nullrev | ||||
if len(parents) == 1: | if len(parents) == 1: | ||||
return parents.pop() | return parents.pop() | ||||
raise error.Abort(_('unable to collapse on top of %s, there is more ' | raise error.Abort(_('unable to collapse on top of %s, there is more ' | ||||
'than one external parent: %s') % | 'than one external parent: %s') % | ||||
(max(destancestors), | (max(destancestors), | ||||
', '.join(str(p) for p in sorted(parents)))) | ', '.join("%d" % p for p in sorted(parents)))) | ||||
def concludememorynode(repo, rev, p1, p2, wctx=None, | def concludememorynode(repo, rev, p1, p2, wctx=None, | ||||
commitmsg=None, editor=None, extrafn=None, | commitmsg=None, editor=None, extrafn=None, | ||||
keepbranches=False, date=None): | keepbranches=False, date=None): | ||||
'''Commit the memory changes with parents p1 and p2. Reuse commit info from | '''Commit the memory changes with parents p1 and p2. Reuse commit info from | ||||
rev but also store useful information in extra. | rev but also store useful information in extra. | ||||
Return node of committed revision.''' | Return node of committed revision.''' | ||||
ctx = repo[rev] | ctx = repo[rev] | ||||
successors in destination or no non-obsolete successor. | successors in destination or no non-obsolete successor. | ||||
""" | """ | ||||
# Obsolete node with successors not in dest leads to divergence | # Obsolete node with successors not in dest leads to divergence | ||||
divergenceok = ui.configbool('experimental', | divergenceok = ui.configbool('experimental', | ||||
'evolution.allowdivergence') | 'evolution.allowdivergence') | ||||
divergencebasecandidates = rebaseobsrevs - rebaseobsskipped | divergencebasecandidates = rebaseobsrevs - rebaseobsskipped | ||||
if divergencebasecandidates and not divergenceok: | if divergencebasecandidates and not divergenceok: | ||||
divhashes = (str(repo[r]) | divhashes = (bytes(repo[r]) | ||||
for r in divergencebasecandidates) | for r in divergencebasecandidates) | ||||
msg = _("this rebase will cause " | msg = _("this rebase will cause " | ||||
"divergences from: %s") | "divergences from: %s") | ||||
h = _("to force the rebase please set " | h = _("to force the rebase please set " | ||||
"experimental.evolution.allowdivergence=True") | "experimental.evolution.allowdivergence=True") | ||||
raise error.Abort(msg % (",".join(divhashes),), hint=h) | raise error.Abort(msg % (",".join(divhashes),), hint=h) | ||||
def successorrevs(unfi, rev): | def successorrevs(unfi, rev): | ||||
if mqrebase: | if mqrebase: | ||||
mq.finish(repo, mqrebase.keys()) | mq.finish(repo, mqrebase.keys()) | ||||
# We must start import from the newest revision | # We must start import from the newest revision | ||||
for rev in sorted(mqrebase, reverse=True): | for rev in sorted(mqrebase, reverse=True): | ||||
if rev not in skipped: | if rev not in skipped: | ||||
name, isgit = mqrebase[rev] | name, isgit = mqrebase[rev] | ||||
repo.ui.note(_('updating mq patch %s to %s:%s\n') % | repo.ui.note(_('updating mq patch %s to %d:%s\n') % | ||||
(name, state[rev], repo[state[rev]])) | (name, state[rev], repo[state[rev]])) | ||||
mq.qimport(repo, (), patchname=name, git=isgit, | mq.qimport(repo, (), patchname=name, git=isgit, | ||||
rev=[str(state[rev])]) | rev=["%d" % state[rev]]) | ||||
else: | else: | ||||
# Rebased and skipped | # Rebased and skipped | ||||
skippedpatches.add(mqrebase[rev][0]) | skippedpatches.add(mqrebase[rev][0]) | ||||
# Patches were either applied and rebased and imported in | # Patches were either applied and rebased and imported in | ||||
# order, applied and removed or unapplied. Discard the removed | # order, applied and removed or unapplied. Discard the removed | ||||
# ones while preserving the original series order and guards. | # ones while preserving the original series order and guards. | ||||
newseries = [s for s in original_series | newseries = [s for s in original_series | ||||
# If the first commits in the rebased set get skipped during the rebase, | # If the first commits in the rebased set get skipped during the rebase, | ||||
# their values within the state mapping will be the dest rev id. The | # their values within the state mapping will be the dest rev id. The | ||||
# dstates list must must not contain the dest rev (issue4896) | # dstates list must must not contain the dest rev (issue4896) | ||||
dstates = [s for r, s in state.items() if s >= 0 and s != destmap[r]] | dstates = [s for r, s in state.items() if s >= 0 and s != destmap[r]] | ||||
immutable = [d for d in dstates if not repo[d].mutable()] | immutable = [d for d in dstates if not repo[d].mutable()] | ||||
cleanup = True | cleanup = True | ||||
if immutable: | if immutable: | ||||
repo.ui.warn(_("warning: can't clean up public changesets %s\n") | repo.ui.warn(_("warning: can't clean up public changesets %s\n") | ||||
% ', '.join(str(repo[r]) for r in immutable), | % ', '.join(bytes(repo[r]) for r in immutable), | ||||
hint=_("see 'hg help phases' for details")) | hint=_("see 'hg help phases' for details")) | ||||
cleanup = False | cleanup = False | ||||
descendants = set() | descendants = set() | ||||
if dstates: | if dstates: | ||||
descendants = set(repo.changelog.descendants(dstates)) | descendants = set(repo.changelog.descendants(dstates)) | ||||
if descendants - set(dstates): | if descendants - set(dstates): | ||||
repo.ui.warn(_("warning: new changesets detected on destination " | repo.ui.warn(_("warning: new changesets detected on destination " |