Mercurial > hg
comparison hgext/rebase.py @ 37042:8ff5772711fa
rebase: pass in "user" instead of "ctx" to conclude[memory]node()
This was the only remaining part of the context object that was
needed.
Differential Revision: https://phab.mercurial-scm.org/D2923
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 20 Mar 2018 22:11:10 -0700 |
parents | 0b1230a5a958 |
children | a8d8cdafe29c |
comparison
equal
deleted
inserted
replaced
37041:0b1230a5a958 | 37042:8ff5772711fa |
---|---|
457 overrides = {('phases', 'new-commit'): destphase} | 457 overrides = {('phases', 'new-commit'): destphase} |
458 if keepbranch: | 458 if keepbranch: |
459 overrides[('ui', 'allowemptycommit')] = True | 459 overrides[('ui', 'allowemptycommit')] = True |
460 with repo.ui.configoverride(overrides, 'rebase'): | 460 with repo.ui.configoverride(overrides, 'rebase'): |
461 if self.inmemory: | 461 if self.inmemory: |
462 newnode = concludememorynode(repo, ctx, p1, p2, | 462 newnode = concludememorynode(repo, p1, p2, |
463 wctx=self.wctx, | 463 wctx=self.wctx, |
464 extra=extra, | 464 extra=extra, |
465 commitmsg=commitmsg, | 465 commitmsg=commitmsg, |
466 editor=editor, | 466 editor=editor, |
467 user=ctx.user(), | |
467 date=date) | 468 date=date) |
468 mergemod.mergestate.clean(repo) | 469 mergemod.mergestate.clean(repo) |
469 else: | 470 else: |
470 newnode = concludenode(repo, ctx, p1, p2, | 471 newnode = concludenode(repo, p1, p2, |
471 extra=extra, | 472 extra=extra, |
472 commitmsg=commitmsg, | 473 commitmsg=commitmsg, |
473 editor=editor, | 474 editor=editor, |
475 user=ctx.user(), | |
474 date=date) | 476 date=date) |
475 | 477 |
476 if newnode is None: | 478 if newnode is None: |
477 # If it ended up being a no-op commit, then the normal | 479 # If it ended up being a no-op commit, then the normal |
478 # merge state clean-up path doesn't happen, so do it | 480 # merge state clean-up path doesn't happen, so do it |
1028 raise error.Abort(_('unable to collapse on top of %d, there is more ' | 1030 raise error.Abort(_('unable to collapse on top of %d, there is more ' |
1029 'than one external parent: %s') % | 1031 'than one external parent: %s') % |
1030 (max(destancestors), | 1032 (max(destancestors), |
1031 ', '.join("%d" % p for p in sorted(parents)))) | 1033 ', '.join("%d" % p for p in sorted(parents)))) |
1032 | 1034 |
1033 def concludememorynode(repo, ctx, p1, p2, wctx, editor, extra, date, commitmsg): | 1035 def concludememorynode(repo, p1, p2, wctx, editor, extra, user, date, |
1034 '''Commit the memory changes with parents p1 and p2. Reuse commit info from | 1036 commitmsg): |
1035 ctx. | 1037 '''Commit the memory changes with parents p1 and p2. |
1036 Return node of committed revision.''' | 1038 Return node of committed revision.''' |
1037 # Replicates the empty check in ``repo.commit``. | 1039 # Replicates the empty check in ``repo.commit``. |
1038 if wctx.isempty() and not repo.ui.configbool('ui', 'allowemptycommit'): | 1040 if wctx.isempty() and not repo.ui.configbool('ui', 'allowemptycommit'): |
1039 return None | 1041 return None |
1040 | 1042 |
1043 branch = repo[p1].branch() | 1045 branch = repo[p1].branch() |
1044 if 'branch' in extra: | 1046 if 'branch' in extra: |
1045 branch = extra['branch'] | 1047 branch = extra['branch'] |
1046 | 1048 |
1047 memctx = wctx.tomemctx(commitmsg, parents=(p1, p2), date=date, | 1049 memctx = wctx.tomemctx(commitmsg, parents=(p1, p2), date=date, |
1048 extra=extra, user=ctx.user(), branch=branch, editor=editor) | 1050 extra=extra, user=user, branch=branch, editor=editor) |
1049 commitres = repo.commitctx(memctx) | 1051 commitres = repo.commitctx(memctx) |
1050 wctx.clean() # Might be reused | 1052 wctx.clean() # Might be reused |
1051 return commitres | 1053 return commitres |
1052 | 1054 |
1053 def concludenode(repo, ctx, p1, p2, editor, extra, date, commitmsg): | 1055 def concludenode(repo, p1, p2, editor, extra, user, date, commitmsg): |
1054 '''Commit the wd changes with parents p1 and p2. Reuse commit info from ctx. | 1056 '''Commit the wd changes with parents p1 and p2. |
1055 Return node of committed revision.''' | 1057 Return node of committed revision.''' |
1056 dsguard = util.nullcontextmanager() | 1058 dsguard = util.nullcontextmanager() |
1057 if not repo.ui.configbool('rebase', 'singletransaction'): | 1059 if not repo.ui.configbool('rebase', 'singletransaction'): |
1058 dsguard = dirstateguard.dirstateguard(repo, 'rebase') | 1060 dsguard = dirstateguard.dirstateguard(repo, 'rebase') |
1059 with dsguard: | 1061 with dsguard: |
1060 repo.setparents(repo[p1].node(), repo[p2].node()) | 1062 repo.setparents(repo[p1].node(), repo[p2].node()) |
1061 | 1063 |
1062 # Commit might fail if unresolved files exist | 1064 # Commit might fail if unresolved files exist |
1063 newnode = repo.commit(text=commitmsg, user=ctx.user(), | 1065 newnode = repo.commit(text=commitmsg, user=user, date=date, |
1064 date=date, extra=extra, editor=editor) | 1066 extra=extra, editor=editor) |
1065 | 1067 |
1066 repo.dirstate.setbranch(repo[newnode].branch()) | 1068 repo.dirstate.setbranch(repo[newnode].branch()) |
1067 return newnode | 1069 return newnode |
1068 | 1070 |
1069 def rebasenode(repo, rev, p1, base, collapse, dest, wctx): | 1071 def rebasenode(repo, rev, p1, base, collapse, dest, wctx): |