comparison hgext/rebase.py @ 37039:7616073a4cf1

rebase: pass in entire "overrides" dict to conclude[memory]node() As with previous patches, this was done the same way in both functions, so let's make the caller do it instead. Differential Revision: https://phab.mercurial-scm.org/D2920
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 20 Mar 2018 21:53:36 -0700
parents 7db86856f27f
children b8d305bd12ca
comparison
equal deleted inserted replaced
37038:7db86856f27f 37039:7616073a4cf1
448 commitmsg = ctx.description() 448 commitmsg = ctx.description()
449 extra = {'rebase_source': ctx.hex()} 449 extra = {'rebase_source': ctx.hex()}
450 for c in self.extrafns: 450 for c in self.extrafns:
451 c(ctx, extra) 451 c(ctx, extra)
452 keepbranch = self.keepbranchesf and repo[p1].branch() != ctx.branch() 452 keepbranch = self.keepbranchesf and repo[p1].branch() != ctx.branch()
453 destphase = max(ctx.phase(), phases.draft)
454 overrides = {('phases', 'new-commit'): destphase}
455 if keepbranch:
456 overrides[('ui', 'allowemptycommit')] = True
453 if self.inmemory: 457 if self.inmemory:
454 newnode = concludememorynode(repo, ctx, p1, p2, 458 newnode = concludememorynode(repo, ctx, p1, p2,
455 wctx=self.wctx, 459 wctx=self.wctx,
456 extra=extra, 460 extra=extra,
457 commitmsg=commitmsg, 461 commitmsg=commitmsg,
458 editor=editor, 462 editor=editor,
459 keepbranch=keepbranch, 463 overrides=overrides,
460 date=self.date) 464 date=self.date)
461 mergemod.mergestate.clean(repo) 465 mergemod.mergestate.clean(repo)
462 else: 466 else:
463 newnode = concludenode(repo, ctx, p1, p2, 467 newnode = concludenode(repo, ctx, p1, p2,
464 extra=extra, 468 extra=extra,
465 commitmsg=commitmsg, 469 commitmsg=commitmsg,
466 editor=editor, 470 editor=editor,
467 keepbranch=keepbranch, 471 overrides=overrides,
468 date=self.date) 472 date=self.date)
469 473
470 if newnode is None: 474 if newnode is None:
471 # If it ended up being a no-op commit, then the normal 475 # If it ended up being a no-op commit, then the normal
472 # merge state clean-up path doesn't happen, so do it 476 # merge state clean-up path doesn't happen, so do it
1022 raise error.Abort(_('unable to collapse on top of %d, there is more ' 1026 raise error.Abort(_('unable to collapse on top of %d, there is more '
1023 'than one external parent: %s') % 1027 'than one external parent: %s') %
1024 (max(destancestors), 1028 (max(destancestors),
1025 ', '.join("%d" % p for p in sorted(parents)))) 1029 ', '.join("%d" % p for p in sorted(parents))))
1026 1030
1027 def concludememorynode(repo, ctx, p1, p2, wctx, editor, extra, keepbranch, 1031 def concludememorynode(repo, ctx, p1, p2, wctx, editor, extra, overrides, date,
1028 date, commitmsg): 1032 commitmsg):
1029 '''Commit the memory changes with parents p1 and p2. Reuse commit info from 1033 '''Commit the memory changes with parents p1 and p2. Reuse commit info from
1030 ctx. 1034 ctx.
1031 Return node of committed revision.''' 1035 Return node of committed revision.'''
1032 destphase = max(ctx.phase(), phases.draft)
1033 overrides = {('phases', 'new-commit'): destphase}
1034 if keepbranch:
1035 overrides[('ui', 'allowemptycommit')] = True
1036 with repo.ui.configoverride(overrides, 'rebase'): 1036 with repo.ui.configoverride(overrides, 'rebase'):
1037 # Replicates the empty check in ``repo.commit``. 1037 # Replicates the empty check in ``repo.commit``.
1038 if wctx.isempty() and not repo.ui.configbool('ui', 'allowemptycommit'): 1038 if wctx.isempty() and not repo.ui.configbool('ui', 'allowemptycommit'):
1039 return None 1039 return None
1040 1040
1051 extra=extra, user=ctx.user(), branch=branch, editor=editor) 1051 extra=extra, user=ctx.user(), branch=branch, editor=editor)
1052 commitres = repo.commitctx(memctx) 1052 commitres = repo.commitctx(memctx)
1053 wctx.clean() # Might be reused 1053 wctx.clean() # Might be reused
1054 return commitres 1054 return commitres
1055 1055
1056 def concludenode(repo, ctx, p1, p2, editor, extra, keepbranch, date, 1056 def concludenode(repo, ctx, p1, p2, editor, extra, overrides, date,
1057 commitmsg): 1057 commitmsg):
1058 '''Commit the wd changes with parents p1 and p2. Reuse commit info from ctx. 1058 '''Commit the wd changes with parents p1 and p2. Reuse commit info from ctx.
1059 Return node of committed revision.''' 1059 Return node of committed revision.'''
1060 dsguard = util.nullcontextmanager() 1060 dsguard = util.nullcontextmanager()
1061 if not repo.ui.configbool('rebase', 'singletransaction'): 1061 if not repo.ui.configbool('rebase', 'singletransaction'):
1062 dsguard = dirstateguard.dirstateguard(repo, 'rebase') 1062 dsguard = dirstateguard.dirstateguard(repo, 'rebase')
1063 with dsguard: 1063 with dsguard:
1064 repo.setparents(repo[p1].node(), repo[p2].node()) 1064 repo.setparents(repo[p1].node(), repo[p2].node())
1065 1065
1066 destphase = max(ctx.phase(), phases.draft)
1067 overrides = {('phases', 'new-commit'): destphase}
1068 if keepbranch:
1069 overrides[('ui', 'allowemptycommit')] = True
1070 with repo.ui.configoverride(overrides, 'rebase'): 1066 with repo.ui.configoverride(overrides, 'rebase'):
1071 # Commit might fail if unresolved files exist 1067 # Commit might fail if unresolved files exist
1072 if date is None: 1068 if date is None:
1073 date = ctx.date() 1069 date = ctx.date()
1074 newnode = repo.commit(text=commitmsg, user=ctx.user(), 1070 newnode = repo.commit(text=commitmsg, user=ctx.user(),