Mercurial > hg
comparison hgext/rebase.py @ 37036:0ab0d94ead72
rebase: pass in "extra" itself into conclude[memory]node()
We were passing in a function instead for no clear reason (probably
historical, but I haven't bothered looking).
Differential Revision: https://phab.mercurial-scm.org/D2917
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 20 Mar 2018 21:41:53 -0700 |
parents | b7f5d03e1e54 |
children | bd0086bd3af4 |
comparison
equal
deleted
inserted
replaced
37035:b7f5d03e1e54 | 37036:0ab0d94ead72 |
---|---|
455 Return node of committed revision.''' | 455 Return node of committed revision.''' |
456 repo = self.repo | 456 repo = self.repo |
457 ctx = repo[rev] | 457 ctx = repo[rev] |
458 if commitmsg is None: | 458 if commitmsg is None: |
459 commitmsg = ctx.description() | 459 commitmsg = ctx.description() |
460 extrafn = _makeextrafn(self.extrafns) | |
461 extra = {'rebase_source': ctx.hex()} | |
462 if extrafn: | |
463 extrafn(ctx, extra) | |
460 if self.inmemory: | 464 if self.inmemory: |
461 newnode = concludememorynode(repo, ctx, p1, p2, | 465 newnode = concludememorynode(repo, ctx, p1, p2, |
462 wctx=self.wctx, | 466 wctx=self.wctx, |
463 extrafn=_makeextrafn(self.extrafns), | 467 extra=extra, |
464 commitmsg=commitmsg, | 468 commitmsg=commitmsg, |
465 editor=editor, | 469 editor=editor, |
466 keepbranches=self.keepbranchesf, | 470 keepbranches=self.keepbranchesf, |
467 date=self.date) | 471 date=self.date) |
468 mergemod.mergestate.clean(repo) | 472 mergemod.mergestate.clean(repo) |
469 else: | 473 else: |
470 newnode = concludenode(repo, ctx, p1, p2, | 474 newnode = concludenode(repo, ctx, p1, p2, |
471 extrafn=_makeextrafn(self.extrafns), | 475 extra=extra, |
472 commitmsg=commitmsg, | 476 commitmsg=commitmsg, |
473 editor=editor, | 477 editor=editor, |
474 keepbranches=self.keepbranchesf, | 478 keepbranches=self.keepbranchesf, |
475 date=self.date) | 479 date=self.date) |
476 | 480 |
1029 raise error.Abort(_('unable to collapse on top of %d, there is more ' | 1033 raise error.Abort(_('unable to collapse on top of %d, there is more ' |
1030 'than one external parent: %s') % | 1034 'than one external parent: %s') % |
1031 (max(destancestors), | 1035 (max(destancestors), |
1032 ', '.join("%d" % p for p in sorted(parents)))) | 1036 ', '.join("%d" % p for p in sorted(parents)))) |
1033 | 1037 |
1034 def concludememorynode(repo, ctx, p1, p2, wctx, editor, extrafn, keepbranches, | 1038 def concludememorynode(repo, ctx, p1, p2, wctx, editor, extra, keepbranches, |
1035 date, commitmsg): | 1039 date, commitmsg): |
1036 '''Commit the memory changes with parents p1 and p2. Reuse commit info from | 1040 '''Commit the memory changes with parents p1 and p2. Reuse commit info from |
1037 ctx but also store useful information in extra. | 1041 ctx. |
1038 Return node of committed revision.''' | 1042 Return node of committed revision.''' |
1039 keepbranch = keepbranches and repo[p1].branch() != ctx.branch() | 1043 keepbranch = keepbranches and repo[p1].branch() != ctx.branch() |
1040 extra = {'rebase_source': ctx.hex()} | |
1041 if extrafn: | |
1042 extrafn(ctx, extra) | |
1043 | 1044 |
1044 destphase = max(ctx.phase(), phases.draft) | 1045 destphase = max(ctx.phase(), phases.draft) |
1045 overrides = {('phases', 'new-commit'): destphase} | 1046 overrides = {('phases', 'new-commit'): destphase} |
1046 if keepbranch: | 1047 if keepbranch: |
1047 overrides[('ui', 'allowemptycommit')] = True | 1048 overrides[('ui', 'allowemptycommit')] = True |
1063 extra=extra, user=ctx.user(), branch=branch, editor=editor) | 1064 extra=extra, user=ctx.user(), branch=branch, editor=editor) |
1064 commitres = repo.commitctx(memctx) | 1065 commitres = repo.commitctx(memctx) |
1065 wctx.clean() # Might be reused | 1066 wctx.clean() # Might be reused |
1066 return commitres | 1067 return commitres |
1067 | 1068 |
1068 def concludenode(repo, ctx, p1, p2, editor, extrafn, keepbranches, date, | 1069 def concludenode(repo, ctx, p1, p2, editor, extra, keepbranches, date, |
1069 commitmsg): | 1070 commitmsg): |
1070 '''Commit the wd changes with parents p1 and p2. Reuse commit info from ctx | 1071 '''Commit the wd changes with parents p1 and p2. Reuse commit info from ctx. |
1071 but also store useful information in extra. | |
1072 Return node of committed revision.''' | 1072 Return node of committed revision.''' |
1073 dsguard = util.nullcontextmanager() | 1073 dsguard = util.nullcontextmanager() |
1074 if not repo.ui.configbool('rebase', 'singletransaction'): | 1074 if not repo.ui.configbool('rebase', 'singletransaction'): |
1075 dsguard = dirstateguard.dirstateguard(repo, 'rebase') | 1075 dsguard = dirstateguard.dirstateguard(repo, 'rebase') |
1076 with dsguard: | 1076 with dsguard: |
1077 repo.setparents(repo[p1].node(), repo[p2].node()) | 1077 repo.setparents(repo[p1].node(), repo[p2].node()) |
1078 keepbranch = keepbranches and repo[p1].branch() != ctx.branch() | 1078 keepbranch = keepbranches and repo[p1].branch() != ctx.branch() |
1079 extra = {'rebase_source': ctx.hex()} | |
1080 if extrafn: | |
1081 extrafn(ctx, extra) | |
1082 | 1079 |
1083 destphase = max(ctx.phase(), phases.draft) | 1080 destphase = max(ctx.phase(), phases.draft) |
1084 overrides = {('phases', 'new-commit'): destphase} | 1081 overrides = {('phases', 'new-commit'): destphase} |
1085 if keepbranch: | 1082 if keepbranch: |
1086 overrides[('ui', 'allowemptycommit')] = True | 1083 overrides[('ui', 'allowemptycommit')] = True |