##// END OF EJS Templates
histedit: move finishfold into fold class...
Durham Goode -
r24772:8f6494eb default
parent child Browse files
Show More
@@ -546,53 +546,53 b' class fold(histeditaction):'
546 if isinstance(self, rollup):
546 if isinstance(self, rollup):
547 foldopts['rollup'] = True
547 foldopts['rollup'] = True
548
548
549 return finishfold(repo.ui, repo, parentctx, rulectx, ctx.node(),
549 return self.finishfold(repo.ui, repo, parentctx, rulectx, ctx.node(),
550 foldopts, middlecommits)
550 foldopts, middlecommits)
551
552 def finishfold(self, ui, repo, ctx, oldctx, newnode, opts, internalchanges):
553 parent = ctx.parents()[0].node()
554 hg.update(repo, parent)
555 ### prepare new commit data
556 commitopts = opts.copy()
557 commitopts['user'] = ctx.user()
558 # commit message
559 if opts.get('rollup'):
560 newmessage = ctx.description()
561 else:
562 newmessage = '\n***\n'.join(
563 [ctx.description()] +
564 [repo[r].description() for r in internalchanges] +
565 [oldctx.description()]) + '\n'
566 commitopts['message'] = newmessage
567 # date
568 commitopts['date'] = max(ctx.date(), oldctx.date())
569 extra = ctx.extra().copy()
570 # histedit_source
571 # note: ctx is likely a temporary commit but that the best we can do
572 # here. This is sufficient to solve issue3681 anyway.
573 extra['histedit_source'] = '%s,%s' % (ctx.hex(), oldctx.hex())
574 commitopts['extra'] = extra
575 phasebackup = repo.ui.backupconfig('phases', 'new-commit')
576 try:
577 phasemin = max(ctx.phase(), oldctx.phase())
578 repo.ui.setconfig('phases', 'new-commit', phasemin, 'histedit')
579 n = collapse(repo, ctx, repo[newnode], commitopts)
580 finally:
581 repo.ui.restoreconfig(phasebackup)
582 if n is None:
583 return ctx, []
584 hg.update(repo, n)
585 replacements = [(oldctx.node(), (newnode,)),
586 (ctx.node(), (n,)),
587 (newnode, (n,)),
588 ]
589 for ich in internalchanges:
590 replacements.append((ich, (n,)))
591 return repo[n], replacements
551
592
552 class rollup(fold):
593 class rollup(fold):
553 pass
594 pass
554
595
555 def finishfold(ui, repo, ctx, oldctx, newnode, opts, internalchanges):
556 parent = ctx.parents()[0].node()
557 hg.update(repo, parent)
558 ### prepare new commit data
559 commitopts = opts.copy()
560 commitopts['user'] = ctx.user()
561 # commit message
562 if opts.get('rollup'):
563 newmessage = ctx.description()
564 else:
565 newmessage = '\n***\n'.join(
566 [ctx.description()] +
567 [repo[r].description() for r in internalchanges] +
568 [oldctx.description()]) + '\n'
569 commitopts['message'] = newmessage
570 # date
571 commitopts['date'] = max(ctx.date(), oldctx.date())
572 extra = ctx.extra().copy()
573 # histedit_source
574 # note: ctx is likely a temporary commit but that the best we can do here
575 # This is sufficient to solve issue3681 anyway
576 extra['histedit_source'] = '%s,%s' % (ctx.hex(), oldctx.hex())
577 commitopts['extra'] = extra
578 phasebackup = repo.ui.backupconfig('phases', 'new-commit')
579 try:
580 phasemin = max(ctx.phase(), oldctx.phase())
581 repo.ui.setconfig('phases', 'new-commit', phasemin, 'histedit')
582 n = collapse(repo, ctx, repo[newnode], commitopts)
583 finally:
584 repo.ui.restoreconfig(phasebackup)
585 if n is None:
586 return ctx, []
587 hg.update(repo, n)
588 replacements = [(oldctx.node(), (newnode,)),
589 (ctx.node(), (n,)),
590 (newnode, (n,)),
591 ]
592 for ich in internalchanges:
593 replacements.append((ich, (n,)))
594 return repo[n], replacements
595
596 class drop(histeditaction):
596 class drop(histeditaction):
597 def run(self):
597 def run(self):
598 parentctx = self.repo[self.state.parentctxnode]
598 parentctx = self.repo[self.state.parentctxnode]
General Comments 0
You need to be logged in to leave comments. Login now