comparison hgext/histedit.py @ 24773:090da03361c5

histedit: improve roll action integration with fold Previously the fold action would inspect it's class to figure out if it was a rollup or not. This was hacky. Now that finishfold is inside the fold class, let's modify it to check a function (which roll can override) to determine if it should be prompting for a commit message.
author Durham Goode <durham@fb.com>
date Sat, 04 Apr 2015 02:12:53 -0700
parents 8f6494eb16eb
children a9d63d87b837
comparison
equal deleted inserted replaced
24772:8f6494eb16eb 24773:090da03361c5
540 return ctx, [(self.node, (ctx.node(),))] 540 return ctx, [(self.node, (ctx.node(),))]
541 541
542 middlecommits = newcommits.copy() 542 middlecommits = newcommits.copy()
543 middlecommits.discard(ctx.node()) 543 middlecommits.discard(ctx.node())
544 544
545 foldopts = {}
546 if isinstance(self, rollup):
547 foldopts['rollup'] = True
548
549 return self.finishfold(repo.ui, repo, parentctx, rulectx, ctx.node(), 545 return self.finishfold(repo.ui, repo, parentctx, rulectx, ctx.node(),
550 foldopts, middlecommits) 546 middlecommits)
551 547
552 def finishfold(self, ui, repo, ctx, oldctx, newnode, opts, internalchanges): 548 def skipprompt(self):
549 return False
550
551 def finishfold(self, ui, repo, ctx, oldctx, newnode, internalchanges):
553 parent = ctx.parents()[0].node() 552 parent = ctx.parents()[0].node()
554 hg.update(repo, parent) 553 hg.update(repo, parent)
555 ### prepare new commit data 554 ### prepare new commit data
556 commitopts = opts.copy() 555 commitopts = {}
557 commitopts['user'] = ctx.user() 556 commitopts['user'] = ctx.user()
558 # commit message 557 # commit message
559 if opts.get('rollup'): 558 if self.skipprompt():
560 newmessage = ctx.description() 559 newmessage = ctx.description()
561 else: 560 else:
562 newmessage = '\n***\n'.join( 561 newmessage = '\n***\n'.join(
563 [ctx.description()] + 562 [ctx.description()] +
564 [repo[r].description() for r in internalchanges] + 563 [repo[r].description() for r in internalchanges] +
589 for ich in internalchanges: 588 for ich in internalchanges:
590 replacements.append((ich, (n,))) 589 replacements.append((ich, (n,)))
591 return repo[n], replacements 590 return repo[n], replacements
592 591
593 class rollup(fold): 592 class rollup(fold):
594 pass 593 def skipprompt(self):
594 return True
595 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]
599 return parentctx, [(self.node, tuple())] 599 return parentctx, [(self.node, tuple())]