Details
Details
- Reviewers
phillco indygreg - Group Reviewers
hg-reviewers - Commits
- rHGb8d305bd12ca: rebase: move config override out of conclude[memory]node()
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
phillco | |
indygreg |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/rebase.py (91 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
extra = {'rebase_source': ctx.hex()} | extra = {'rebase_source': ctx.hex()} | ||||
for c in self.extrafns: | for c in self.extrafns: | ||||
c(ctx, extra) | c(ctx, extra) | ||||
keepbranch = self.keepbranchesf and repo[p1].branch() != ctx.branch() | keepbranch = self.keepbranchesf and repo[p1].branch() != ctx.branch() | ||||
destphase = max(ctx.phase(), phases.draft) | destphase = max(ctx.phase(), phases.draft) | ||||
overrides = {('phases', 'new-commit'): destphase} | overrides = {('phases', 'new-commit'): destphase} | ||||
if keepbranch: | if keepbranch: | ||||
overrides[('ui', 'allowemptycommit')] = True | overrides[('ui', 'allowemptycommit')] = True | ||||
with repo.ui.configoverride(overrides, 'rebase'): | |||||
if self.inmemory: | if self.inmemory: | ||||
newnode = concludememorynode(repo, ctx, p1, p2, | newnode = concludememorynode(repo, ctx, p1, p2, | ||||
wctx=self.wctx, | wctx=self.wctx, | ||||
extra=extra, | extra=extra, | ||||
commitmsg=commitmsg, | commitmsg=commitmsg, | ||||
editor=editor, | editor=editor, | ||||
overrides=overrides, | |||||
date=self.date) | date=self.date) | ||||
mergemod.mergestate.clean(repo) | mergemod.mergestate.clean(repo) | ||||
else: | else: | ||||
newnode = concludenode(repo, ctx, p1, p2, | newnode = concludenode(repo, ctx, p1, p2, | ||||
extra=extra, | extra=extra, | ||||
commitmsg=commitmsg, | commitmsg=commitmsg, | ||||
editor=editor, | editor=editor, | ||||
overrides=overrides, | |||||
date=self.date) | date=self.date) | ||||
if newnode is None: | if newnode is None: | ||||
# If it ended up being a no-op commit, then the normal | # If it ended up being a no-op commit, then the normal | ||||
# merge state clean-up path doesn't happen, so do it | # merge state clean-up path doesn't happen, so do it | ||||
# here. Fix issue5494 | # here. Fix issue5494 | ||||
mergemod.mergestate.clean(repo) | mergemod.mergestate.clean(repo) | ||||
return newnode | return newnode | ||||
def _rebasenode(self, tr, rev, allowdivergence, progressfn): | def _rebasenode(self, tr, rev, allowdivergence, progressfn): | ||||
repo, ui, opts = self.repo, self.ui, self.opts | repo, ui, opts = self.repo, self.ui, self.opts | ||||
dest = self.destmap[rev] | dest = self.destmap[rev] | ||||
ctx = repo[rev] | ctx = repo[rev] | ||||
desc = _ctxdesc(ctx) | desc = _ctxdesc(ctx) | ||||
if self.state[rev] == rev: | if self.state[rev] == rev: | ||||
ui.status(_('already rebased %s\n') % desc) | ui.status(_('already rebased %s\n') % desc) | ||||
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 %d, there is more ' | raise error.Abort(_('unable to collapse on top of %d, there is more ' | ||||
'than one external parent: %s') % | 'than one external parent: %s') % | ||||
(max(destancestors), | (max(destancestors), | ||||
', '.join("%d" % p for p in sorted(parents)))) | ', '.join("%d" % p for p in sorted(parents)))) | ||||
def concludememorynode(repo, ctx, p1, p2, wctx, editor, extra, overrides, date, | def concludememorynode(repo, ctx, p1, p2, wctx, editor, extra, date, commitmsg): | ||||
commitmsg): | |||||
'''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 | ||||
ctx. | ctx. | ||||
Return node of committed revision.''' | Return node of committed revision.''' | ||||
with repo.ui.configoverride(overrides, 'rebase'): | |||||
# Replicates the empty check in ``repo.commit``. | # Replicates the empty check in ``repo.commit``. | ||||
if wctx.isempty() and not repo.ui.configbool('ui', 'allowemptycommit'): | if wctx.isempty() and not repo.ui.configbool('ui', 'allowemptycommit'): | ||||
return None | return None | ||||
if date is None: | if date is None: | ||||
date = ctx.date() | date = ctx.date() | ||||
# By convention, ``extra['branch']`` (set by extrafn) clobbers | # By convention, ``extra['branch']`` (set by extrafn) clobbers | ||||
# ``branch`` (used when passing ``--keepbranches``). | # ``branch`` (used when passing ``--keepbranches``). | ||||
branch = repo[p1].branch() | branch = repo[p1].branch() | ||||
if 'branch' in extra: | if 'branch' in extra: | ||||
branch = extra['branch'] | branch = extra['branch'] | ||||
memctx = wctx.tomemctx(commitmsg, parents=(p1, p2), date=date, | memctx = wctx.tomemctx(commitmsg, parents=(p1, p2), date=date, | ||||
extra=extra, user=ctx.user(), branch=branch, editor=editor) | extra=extra, user=ctx.user(), branch=branch, editor=editor) | ||||
commitres = repo.commitctx(memctx) | commitres = repo.commitctx(memctx) | ||||
wctx.clean() # Might be reused | wctx.clean() # Might be reused | ||||
return commitres | return commitres | ||||
def concludenode(repo, ctx, p1, p2, editor, extra, overrides, date, | def concludenode(repo, ctx, p1, p2, editor, extra, date, commitmsg): | ||||
commitmsg): | |||||
'''Commit the wd changes with parents p1 and p2. Reuse commit info from ctx. | '''Commit the wd changes with parents p1 and p2. Reuse commit info from ctx. | ||||
Return node of committed revision.''' | Return node of committed revision.''' | ||||
dsguard = util.nullcontextmanager() | dsguard = util.nullcontextmanager() | ||||
if not repo.ui.configbool('rebase', 'singletransaction'): | if not repo.ui.configbool('rebase', 'singletransaction'): | ||||
dsguard = dirstateguard.dirstateguard(repo, 'rebase') | dsguard = dirstateguard.dirstateguard(repo, 'rebase') | ||||
with dsguard: | with dsguard: | ||||
repo.setparents(repo[p1].node(), repo[p2].node()) | repo.setparents(repo[p1].node(), repo[p2].node()) | ||||
with repo.ui.configoverride(overrides, 'rebase'): | |||||
# Commit might fail if unresolved files exist | # Commit might fail if unresolved files exist | ||||
if date is None: | if date is None: | ||||
date = ctx.date() | date = ctx.date() | ||||
newnode = repo.commit(text=commitmsg, user=ctx.user(), | newnode = repo.commit(text=commitmsg, user=ctx.user(), | ||||
date=date, extra=extra, editor=editor) | date=date, extra=extra, editor=editor) | ||||
repo.dirstate.setbranch(repo[newnode].branch()) | repo.dirstate.setbranch(repo[newnode].branch()) | ||||
return newnode | return newnode | ||||
def rebasenode(repo, rev, p1, base, collapse, dest, wctx): | def rebasenode(repo, rev, p1, base, collapse, dest, wctx): | ||||
'Rebase a single revision rev on top of p1 using base as merge ancestor' | 'Rebase a single revision rev on top of p1 using base as merge ancestor' | ||||
# Merge phase | # Merge phase | ||||
# Update to destination and merge it with local | # Update to destination and merge it with local |