##// 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 405 raise error.ParseError("invalid changeset %s" % rulehash)
406 406 return cls(state, rev)
407 407
408 def verify(self, prev):
408 def verify(self, prev, expected, seen):
409 409 """ Verifies semantic correctness of the rule"""
410 410 repo = self.repo
411 411 ha = node.hex(self.node)
@@ -414,6 +414,27 b' class histeditaction(object):'
414 414 except error.RepoError:
415 415 raise error.ParseError(_('unknown changeset %s listed')
416 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 439 def torule(self):
419 440 """build a histedit rule line for an action
@@ -661,9 +682,9 b' class edit(histeditaction):'
661 682 @action(['fold', 'f'],
662 683 _('use commit, but combine it with the one above'))
663 684 class fold(histeditaction):
664 def verify(self, prev):
685 def verify(self, prev, expected, seen):
665 686 """ Verifies semantic correctness of the fold rule"""
666 super(fold, self).verify(prev)
687 super(fold, self).verify(prev, expected, seen)
667 688 repo = self.repo
668 689 if not prev:
669 690 c = repo[self.node].parents()[0]
@@ -1377,29 +1398,9 b' def verifyactions(actions, state, ctxs):'
1377 1398 seen = set()
1378 1399 prev = None
1379 1400 for action in actions:
1380 action.verify(prev)
1401 action.verify(prev, expected, seen)
1381 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 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 1404 seen.add(action.node)
1404 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