# HG changeset patch # User timeless # Date 2015-12-23 23:51:29 # Node ID 1cbfeb1dc5aa5c807b6087d4954f32c831a645e7 # Parent c00924c54607bb6e261bd7f78c1f0089a9778b05 histedit: handle exceptions from node.bin in fromrule diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -356,7 +356,11 @@ class histeditaction(object): """Parses the given rule, returning an instance of the histeditaction. """ rulehash = rule.strip().split(' ', 1)[0] - return cls(state, node.bin(rulehash)) + try: + rev = node.bin(rulehash) + except TypeError: + raise error.ParseError("invalid changeset %s" % rulehash) + return cls(state, rev) def verify(self, prev): """ Verifies semantic correctness of the rule""" diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t --- a/tests/test-histedit-arguments.t +++ b/tests/test-histedit-arguments.t @@ -219,6 +219,17 @@ So one is missing and one appear twice. hg: parse error: duplicated command for changeset eb57da33312f [255] +Test bogus rev +--------------------------------------- + + $ HGEDITOR=cat hg histedit "tip^^" --commands - << EOF + > pick eb57da33312f 2 three + > pick 0 + > pick 08d98a8350f3 4 five + > EOF + hg: parse error: invalid changeset 0 + [255] + Test short version of command ---------------------------------------