Mercurial > hg
comparison hgext/histedit.py @ 29880:a485ec066867
histedt: use inheritance to override the constraints in 'base'
All actions but one actually have the same constraints when it comes to validate
the 'action.node' value. So we actually just add this code to a method that can
be overwritten in the one action where it matters.
The now unused 'contraints' related enum and class attribute will be cleaned up
in the next changeset.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Fri, 26 Aug 2016 21:00:33 +0200 |
parents | b566c5992e07 |
children | 12f8bef59bfa |
comparison
equal
deleted
inserted
replaced
29879:b566c5992e07 | 29880:a485ec066867 |
---|---|
412 try: | 412 try: |
413 self.node = repo[ha].node() | 413 self.node = repo[ha].node() |
414 except error.RepoError: | 414 except error.RepoError: |
415 raise error.ParseError(_('unknown changeset %s listed') | 415 raise error.ParseError(_('unknown changeset %s listed') |
416 % ha[:12]) | 416 % ha[:12]) |
417 for constraint in self.constraints: | |
418 if constraint not in _constraints.known(): | |
419 raise error.ParseError(_('unknown constraint "%s"') % | |
420 constraint) | |
421 | |
422 if self.node is not None: | 417 if self.node is not None: |
423 constrs = self.constraints | 418 self._verifynodeconstraints(prev, expected, seen) |
424 if _constraints.noother in constrs and self.node not in expected: | 419 |
425 raise error.ParseError( | 420 def _verifynodeconstraints(self, prev, expected, seen): |
426 _('%s "%s" changeset was not a candidate') | 421 # by default command need a node in the edited list |
427 % (self.verb, node.short(self.node)), | 422 if self.node not in expected: |
428 hint=_('only use listed changesets')) | 423 raise error.ParseError(_('%s "%s" changeset was not a candidate') |
429 if _constraints.forceother in constrs and self.node in expected: | 424 % (self.verb, node.short(self.node)), |
430 raise error.ParseError( | 425 hint=_('only use listed changesets')) |
431 _('%s "%s" changeset was not an edited list candidate') | 426 # and only one command per node |
432 % (self.verb, node.short(self.node)), | 427 if self.node in seen: |
433 hint=_('only use listed changesets')) | 428 raise error.ParseError(_('duplicated command for changeset %s') % |
434 if _constraints.noduplicates in constrs and self.node in seen: | 429 node.short(self.node)) |
435 raise error.ParseError(_( | |
436 'duplicated command for changeset %s') % | |
437 node.short(self.node)) | |
438 | 430 |
439 def torule(self): | 431 def torule(self): |
440 """build a histedit rule line for an action | 432 """build a histedit rule line for an action |
441 | 433 |
442 by default lines are in the form: | 434 by default lines are in the form: |
807 | 799 |
808 def continueclean(self): | 800 def continueclean(self): |
809 basectx = self.repo['.'] | 801 basectx = self.repo['.'] |
810 return basectx, [] | 802 return basectx, [] |
811 | 803 |
804 def _verifynodeconstraints(self, prev, expected, seen): | |
805 # base can only be use with a node not in the edited set | |
806 if self.node in expected: | |
807 msg = _('%s "%s" changeset was not an edited list candidate') | |
808 raise error.ParseError(msg % (self.verb, node.short(self.node)), | |
809 hint=_('only use listed changesets')) | |
810 | |
812 @action(['_multifold'], | 811 @action(['_multifold'], |
813 _( | 812 _( |
814 """fold subclass used for when multiple folds happen in a row | 813 """fold subclass used for when multiple folds happen in a row |
815 | 814 |
816 We only want to fire the editor for the folded message once when | 815 We only want to fire the editor for the folded message once when |