Patchwork [7,of,7] histedit: handle exceptions from node.bin in fromrule

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 28, 2015, 11:29 p.m.
Message ID <dd764f65509c8683b409.1451345358@waste.org>
Download mbox | patch
Permalink /patch/12387/
State Accepted
Headers show

Comments

timeless@mozdev.org - Dec. 28, 2015, 11:29 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1450914689 0
#      Wed Dec 23 23:51:29 2015 +0000
# Node ID dd764f65509c8683b4096974bf11f878a6c7cbde
# Parent  8b8f2d84ebca1f211671edb329ef867203f290bc
histedit: handle exceptions from node.bin in fromrule
Augie Fackler - Dec. 29, 2015, 10:06 p.m.
On Mon, Dec 28, 2015 at 05:29:18PM -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1450914689 0
> #      Wed Dec 23 23:51:29 2015 +0000
> # Node ID dd764f65509c8683b4096974bf11f878a6c7cbde
> # Parent  8b8f2d84ebca1f211671edb329ef867203f290bc
> histedit: handle exceptions from node.bin in fromrule

These are queued, thanks!

>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -356,7 +356,11 @@
>          """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 @@
>    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
>  ---------------------------------------
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -356,7 +356,11 @@ 
         """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 @@ 
   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
 ---------------------------------------