##// END OF EJS Templates
histedit: move constraint verification to the 'action.verify' method...
Pierre-Yves David -
r29879:b566c599 default
parent child Browse files
Show More
@@ -405,7 +405,7 b' class histeditaction(object):'
405 raise error.ParseError("invalid changeset %s" % rulehash)
405 raise error.ParseError("invalid changeset %s" % rulehash)
406 return cls(state, rev)
406 return cls(state, rev)
407
407
408 def verify(self, prev):
408 def verify(self, prev, expected, seen):
409 """ Verifies semantic correctness of the rule"""
409 """ Verifies semantic correctness of the rule"""
410 repo = self.repo
410 repo = self.repo
411 ha = node.hex(self.node)
411 ha = node.hex(self.node)
@@ -414,6 +414,27 b' class histeditaction(object):'
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:
423 constrs = self.constraints
424 if _constraints.noother in constrs and self.node not in expected:
425 raise error.ParseError(
426 _('%s "%s" changeset was not a candidate')
427 % (self.verb, node.short(self.node)),
428 hint=_('only use listed changesets'))
429 if _constraints.forceother in constrs and self.node in expected:
430 raise error.ParseError(
431 _('%s "%s" changeset was not an edited list candidate')
432 % (self.verb, node.short(self.node)),
433 hint=_('only use listed changesets'))
434 if _constraints.noduplicates in constrs and self.node in seen:
435 raise error.ParseError(_(
436 'duplicated command for changeset %s') %
437 node.short(self.node))
417
438
418 def torule(self):
439 def torule(self):
419 """build a histedit rule line for an action
440 """build a histedit rule line for an action
@@ -661,9 +682,9 b' class edit(histeditaction):'
661 @action(['fold', 'f'],
682 @action(['fold', 'f'],
662 _('use commit, but combine it with the one above'))
683 _('use commit, but combine it with the one above'))
663 class fold(histeditaction):
684 class fold(histeditaction):
664 def verify(self, prev):
685 def verify(self, prev, expected, seen):
665 """ Verifies semantic correctness of the fold rule"""
686 """ Verifies semantic correctness of the fold rule"""
666 super(fold, self).verify(prev)
687 super(fold, self).verify(prev, expected, seen)
667 repo = self.repo
688 repo = self.repo
668 if not prev:
689 if not prev:
669 c = repo[self.node].parents()[0]
690 c = repo[self.node].parents()[0]
@@ -1377,29 +1398,9 b' def verifyactions(actions, state, ctxs):'
1377 seen = set()
1398 seen = set()
1378 prev = None
1399 prev = None
1379 for action in actions:
1400 for action in actions:
1380 action.verify(prev)
1401 action.verify(prev, expected, seen)
1381 prev = action
1402 prev = action
1382 constrs = action.constraints
1383 for constraint in constrs:
1384 if constraint not in _constraints.known():
1385 raise error.ParseError(_('unknown constraint "%s"') %
1386 constraint)
1387
1388 if action.node is not None:
1403 if action.node is not None:
1389 if _constraints.noother in constrs and action.node not in expected:
1390 raise error.ParseError(
1391 _('%s "%s" changeset was not a candidate')
1392 % (action.verb, node.short(action.node)),
1393 hint=_('only use listed changesets'))
1394 if _constraints.forceother in constrs and action.node in expected:
1395 raise error.ParseError(
1396 _('%s "%s" changeset was not an edited list candidate')
1397 % (action.verb, node.short(action.node)),
1398 hint=_('only use listed changesets'))
1399 if _constraints.noduplicates in constrs and action.node in seen:
1400 raise error.ParseError(_(
1401 'duplicated command for changeset %s') %
1402 node.short(action.node))
1403 seen.add(action.node)
1404 seen.add(action.node)
1404 missing = sorted(expected - seen) # sort to stabilize output
1405 missing = sorted(expected - seen) # sort to stabilize output
1405
1406
General Comments 0
You need to be logged in to leave comments. Login now