D1248: rebase: add concludememorynode(), and call it when rebasing in-memory
phillco (Phil Cohen)
phabricator at mercurial-scm.org
Thu Dec 7 21:23:32 UTC 2017
phillco updated this revision to Diff 4194.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D1248?vs=3121&id=4194
REVISION DETAIL
https://phab.mercurial-scm.org/D1248
AFFECTED FILES
hgext/rebase.py
CHANGE DETAILS
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -495,11 +495,22 @@
merging = p2 != nullrev
editform = cmdutil.mergeeditform(merging, 'rebase')
editor = cmdutil.getcommiteditor(editform=editform, **opts)
- newnode = concludenode(repo, rev, p1, p2,
- extrafn=_makeextrafn(self.extrafns),
- editor=editor,
- keepbranches=self.keepbranchesf,
- date=self.date)
+ if self.wctx.isinmemory():
+ newnode = concludememorynode(repo, rev, p1, p2,
+ wctx=self.wctx,
+ extrafn=_makeextrafn(self.extrafns),
+ editor=editor,
+ keepbranches=self.keepbranchesf,
+ date=self.date)
+ mergemod.mergestate.clean(repo)
+ else:
+ newnode = concludenode(repo, rev, p1, p2,
+ extrafn=_makeextrafn(
+ self.extrafns),
+ editor=editor,
+ keepbranches=self.keepbranchesf,
+ date=self.date)
+
if newnode is None:
# If it ended up being a no-op commit, then the normal
# merge state clean-up path doesn't happen, so do it
@@ -552,13 +563,21 @@
dsguard = None
if ui.configbool('rebase', 'singletransaction'):
dsguard = dirstateguard.dirstateguard(repo, 'rebase')
- with util.acceptintervention(dsguard):
- newnode = concludenode(repo, revtoreuse, p1, self.external,
- commitmsg=commitmsg,
- extrafn=_makeextrafn(self.extrafns),
- editor=editor,
- keepbranches=self.keepbranchesf,
- date=self.date)
+ if self.inmemory:
+ newnode = concludememorynode(repo, revtoreuse, p1, self.external,
+ commitmsg=commitmsg,
+ extrafn=_makeextrafn(self.extrafns),
+ editor=editor,
+ keepbranches=self.keepbranchesf,
+ date=self.date, wctx=self.wctx)
+ else:
+ with util.acceptintervention(dsguard):
+ newnode = concludenode(repo, revtoreuse, p1, self.external,
+ commitmsg=commitmsg,
+ extrafn=_makeextrafn(self.extrafns),
+ editor=editor,
+ keepbranches=self.keepbranchesf,
+ date=self.date)
if newnode is not None:
newrev = repo[newnode].rev()
for oldrev in self.state.iterkeys():
@@ -964,6 +983,34 @@
(max(destancestors),
', '.join(str(p) for p in sorted(parents))))
+def concludememorynode(repo, rev, p1, p2, wctx=None,
+ commitmsg=None, editor=None, extrafn=None,
+ keepbranches=False, date=None):
+ '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
+ but also store useful information in extra.
+ Return node of committed revision.'''
+ ctx = repo[rev]
+ if commitmsg is None:
+ commitmsg = ctx.description()
+ keepbranch = keepbranches and repo[p1].branch() != ctx.branch()
+ extra = {'rebase_source': ctx.hex()}
+ if extrafn:
+ extrafn(ctx, extra)
+
+ destphase = max(ctx.phase(), phases.draft)
+ overrides = {('phases', 'new-commit'): destphase}
+ with repo.ui.configoverride(overrides, 'rebase'):
+ if keepbranch:
+ repo.ui.setconfig('ui', 'allowemptycommit', True)
+ if date is None:
+ date = ctx.date()
+
+ res = wctx.commit(text=commitmsg, user=ctx.user(),
+ date=date, extra=extra, branch=repo[p1].branch(),
+ editor=editor, parents=(p1, p2))
+ wctx.clean()
+ return res
+
def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None,
keepbranches=False, date=None):
'''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
To: phillco, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list