Mercurial > hg
changeset 27202:2226cd4f32ed
histedit: add verify() to histeditaction
This commits splits the parsing of the histedit rule from its semantic analysis.
It's necessary because sometimes we want to do first without doing the former (reading the
histedit state).
author | Mateusz Kwapich <mitrandir@fb.com> |
---|---|
date | Wed, 02 Dec 2015 12:19:01 -0800 |
parents | dcb536d2e138 |
children | b6a0f0895a25 |
files | hgext/histedit.py |
diffstat | 1 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/histedit.py Wed Dec 02 12:19:01 2015 -0800 +++ b/hgext/histedit.py Wed Dec 02 12:19:01 2015 -0800 @@ -346,13 +346,18 @@ def fromrule(cls, state, rule): """Parses the given rule, returning an instance of the histeditaction. """ - repo = state.repo rulehash = rule.strip().split(' ', 1)[0] + return cls(state, node.bin(rulehash)) + + def verify(self): + """ Verifies semantic correctness of the rule""" + repo = self.repo + ha = node.hex(self.node) try: - node = repo[rulehash].node() + self.node = repo[ha].node() except error.RepoError: - raise error.Abort(_('unknown changeset %s listed') % rulehash[:12]) - return cls(state, node) + raise error.Abort(_('unknown changeset %s listed') + % ha[:12]) def constraints(self): """Return a set of constrains that this action should be verified for @@ -1175,6 +1180,7 @@ if verb not in actiontable or verb.startswith('_'): raise error.Abort(_('unknown action "%s"') % verb) action = actiontable[verb].fromrule(state, rest) + action.verify() constraints = action.constraints() for constraint in constraints: if constraint not in _constraints.known():