##// END OF EJS Templates
histedit: add addhisteditaction decorator...
Mateusz Kwapich -
r27201:dcb536d2 default
parent child Browse files
Show More
@@ -544,6 +544,20 b' def abortdirty():'
544 '--continue, or abort with histedit --abort'))
544 '--continue, or abort with histedit --abort'))
545
545
546
546
547 actiontable = {}
548 actionlist = []
549
550 def addhisteditaction(verbs):
551 def wrap(cls):
552 cls.verb = verbs[0]
553 for verb in verbs:
554 actiontable[verb] = cls
555 actionlist.append(cls)
556 return cls
557 return wrap
558
559
560 @addhisteditaction(['pick', 'p'])
547 class pick(histeditaction):
561 class pick(histeditaction):
548 def run(self):
562 def run(self):
549 rulectx = self.repo[self.node]
563 rulectx = self.repo[self.node]
@@ -553,6 +567,7 b' class pick(histeditaction):'
553
567
554 return super(pick, self).run()
568 return super(pick, self).run()
555
569
570 @addhisteditaction(['edit', 'e'])
556 class edit(histeditaction):
571 class edit(histeditaction):
557 def run(self):
572 def run(self):
558 repo = self.repo
573 repo = self.repo
@@ -567,6 +582,7 b' class edit(histeditaction):'
567 def commiteditor(self):
582 def commiteditor(self):
568 return cmdutil.getcommiteditor(edit=True, editform='histedit.edit')
583 return cmdutil.getcommiteditor(edit=True, editform='histedit.edit')
569
584
585 @addhisteditaction(['fold', 'f'])
570 class fold(histeditaction):
586 class fold(histeditaction):
571 def continuedirty(self):
587 def continuedirty(self):
572 repo = self.repo
588 repo = self.repo
@@ -677,6 +693,7 b' class base(histeditaction):'
677 basectx = self.repo['.']
693 basectx = self.repo['.']
678 return basectx, []
694 return basectx, []
679
695
696 @addhisteditaction(['_multifold'])
680 class _multifold(fold):
697 class _multifold(fold):
681 """fold subclass used for when multiple folds happen in a row
698 """fold subclass used for when multiple folds happen in a row
682
699
@@ -689,6 +706,7 b' class _multifold(fold):'
689 def skipprompt(self):
706 def skipprompt(self):
690 return True
707 return True
691
708
709 @addhisteditaction(["roll", "r"])
692 class rollup(fold):
710 class rollup(fold):
693 def mergedescs(self):
711 def mergedescs(self):
694 return False
712 return False
@@ -696,11 +714,13 b' class rollup(fold):'
696 def skipprompt(self):
714 def skipprompt(self):
697 return True
715 return True
698
716
717 @addhisteditaction(["drop", "d"])
699 class drop(histeditaction):
718 class drop(histeditaction):
700 def run(self):
719 def run(self):
701 parentctx = self.repo[self.state.parentctxnode]
720 parentctx = self.repo[self.state.parentctxnode]
702 return parentctx, [(self.node, tuple())]
721 return parentctx, [(self.node, tuple())]
703
722
723 @addhisteditaction(["mess", "m"])
704 class message(histeditaction):
724 class message(histeditaction):
705 def commiteditor(self):
725 def commiteditor(self):
706 return cmdutil.getcommiteditor(edit=True, editform='histedit.mess')
726 return cmdutil.getcommiteditor(edit=True, editform='histedit.mess')
@@ -731,20 +751,6 b' def findoutgoing(ui, repo, remote=None, '
731 raise error.Abort(msg, hint=hint)
751 raise error.Abort(msg, hint=hint)
732 return repo.lookup(roots[0])
752 return repo.lookup(roots[0])
733
753
734 actiontable = {'p': pick,
735 'pick': pick,
736 'e': edit,
737 'edit': edit,
738 'f': fold,
739 'fold': fold,
740 '_multifold': _multifold,
741 'r': rollup,
742 'roll': rollup,
743 'd': drop,
744 'drop': drop,
745 'm': message,
746 'mess': message,
747 }
748
754
749 @command('histedit',
755 @command('histedit',
750 [('', 'commands', '',
756 [('', 'commands', '',
@@ -1379,4 +1385,4 b' def extsetup(ui):'
1379 ['histedit-state', False, True, _('histedit in progress'),
1385 ['histedit-state', False, True, _('histedit in progress'),
1380 _("use 'hg histedit --continue' or 'hg histedit --abort'")])
1386 _("use 'hg histedit --continue' or 'hg histedit --abort'")])
1381 if ui.configbool("experimental", "histeditng"):
1387 if ui.configbool("experimental", "histeditng"):
1382 actiontable.update({'b': base, 'base': base})
1388 globals()['base'] = addhisteditaction(['base', 'b'])(base)
General Comments 0
You need to be logged in to leave comments. Login now