##// END OF EJS Templates
rebase: add concludememorynode(), and call it when rebasing in-memory...
Phil Cohen -
r35320:228916ca default
parent child Browse files
Show More
@@ -495,11 +495,21 b' class rebaseruntime(object):'
495 merging = p2 != nullrev
495 merging = p2 != nullrev
496 editform = cmdutil.mergeeditform(merging, 'rebase')
496 editform = cmdutil.mergeeditform(merging, 'rebase')
497 editor = cmdutil.getcommiteditor(editform=editform, **opts)
497 editor = cmdutil.getcommiteditor(editform=editform, **opts)
498 newnode = concludenode(repo, rev, p1, p2,
498 if self.wctx.isinmemory():
499 extrafn=_makeextrafn(self.extrafns),
499 newnode = concludememorynode(repo, rev, p1, p2,
500 editor=editor,
500 wctx=self.wctx,
501 keepbranches=self.keepbranchesf,
501 extrafn=_makeextrafn(self.extrafns),
502 date=self.date)
502 editor=editor,
503 keepbranches=self.keepbranchesf,
504 date=self.date)
505 mergemod.mergestate.clean(repo)
506 else:
507 newnode = concludenode(repo, rev, p1, p2,
508 extrafn=_makeextrafn(self.extrafns),
509 editor=editor,
510 keepbranches=self.keepbranchesf,
511 date=self.date)
512
503 if newnode is None:
513 if newnode is None:
504 # If it ended up being a no-op commit, then the normal
514 # If it ended up being a no-op commit, then the normal
505 # merge state clean-up path doesn't happen, so do it
515 # merge state clean-up path doesn't happen, so do it
@@ -552,13 +562,22 b' class rebaseruntime(object):'
552 dsguard = None
562 dsguard = None
553 if ui.configbool('rebase', 'singletransaction'):
563 if ui.configbool('rebase', 'singletransaction'):
554 dsguard = dirstateguard.dirstateguard(repo, 'rebase')
564 dsguard = dirstateguard.dirstateguard(repo, 'rebase')
555 with util.acceptintervention(dsguard):
565 if self.inmemory:
556 newnode = concludenode(repo, revtoreuse, p1, self.external,
566 newnode = concludememorynode(repo, revtoreuse, p1,
557 commitmsg=commitmsg,
567 self.external,
558 extrafn=_makeextrafn(self.extrafns),
568 commitmsg=commitmsg,
559 editor=editor,
569 extrafn=_makeextrafn(self.extrafns),
560 keepbranches=self.keepbranchesf,
570 editor=editor,
561 date=self.date)
571 keepbranches=self.keepbranchesf,
572 date=self.date, wctx=self.wctx)
573 else:
574 with util.acceptintervention(dsguard):
575 newnode = concludenode(repo, revtoreuse, p1, self.external,
576 commitmsg=commitmsg,
577 extrafn=_makeextrafn(self.extrafns),
578 editor=editor,
579 keepbranches=self.keepbranchesf,
580 date=self.date)
562 if newnode is not None:
581 if newnode is not None:
563 newrev = repo[newnode].rev()
582 newrev = repo[newnode].rev()
564 for oldrev in self.state.iterkeys():
583 for oldrev in self.state.iterkeys():
@@ -964,6 +983,44 b' def externalparent(repo, state, destance'
964 (max(destancestors),
983 (max(destancestors),
965 ', '.join(str(p) for p in sorted(parents))))
984 ', '.join(str(p) for p in sorted(parents))))
966
985
986 def concludememorynode(repo, rev, p1, p2, wctx=None,
987 commitmsg=None, editor=None, extrafn=None,
988 keepbranches=False, date=None):
989 '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
990 but also store useful information in extra.
991 Return node of committed revision.'''
992 ctx = repo[rev]
993 if commitmsg is None:
994 commitmsg = ctx.description()
995 keepbranch = keepbranches and repo[p1].branch() != ctx.branch()
996 extra = {'rebase_source': ctx.hex()}
997 if extrafn:
998 extrafn(ctx, extra)
999
1000 destphase = max(ctx.phase(), phases.draft)
1001 overrides = {('phases', 'new-commit'): destphase}
1002 with repo.ui.configoverride(overrides, 'rebase'):
1003 if keepbranch:
1004 repo.ui.setconfig('ui', 'allowemptycommit', True)
1005 # Replicates the empty check in ``repo.commit``.
1006 if wctx.isempty() and not repo.ui.configbool('ui', 'allowemptycommit'):
1007 return None
1008
1009 if date is None:
1010 date = ctx.date()
1011
1012 # By convention, ``extra['branch']`` (set by extrafn) clobbers
1013 # ``branch`` (used when passing ``--keepbranches``).
1014 branch = repo[p1].branch()
1015 if 'branch' in extra:
1016 branch = extra['branch']
1017
1018 memctx = wctx.tomemctx(commitmsg, parents=(p1, p2), date=date,
1019 extra=extra, user=ctx.user(), branch=branch, editor=editor)
1020 commitres = repo.commitctx(memctx)
1021 wctx.clean() # Might be reused
1022 return commitres
1023
967 def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None,
1024 def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None,
968 keepbranches=False, date=None):
1025 keepbranches=False, date=None):
969 '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
1026 '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
@@ -2102,6 +2102,12 b' class overlayworkingctx(workingctx):'
2102 def isdirty(self, path):
2102 def isdirty(self, path):
2103 return path in self._cache
2103 return path in self._cache
2104
2104
2105 def isempty(self):
2106 # We need to discard any keys that are actually clean before the empty
2107 # commit check.
2108 self._compact()
2109 return len(self._cache) == 0
2110
2105 def clean(self):
2111 def clean(self):
2106 self._cache = {}
2112 self._cache = {}
2107
2113
General Comments 0
You need to be logged in to leave comments. Login now