Patchwork revset: get rid of redundant error checking from match()

login
register
mail settings
Submitter Yuya Nishihara
Date June 26, 2016, 8:37 a.m.
Message ID <540243aaab2dcc4e1e78.1466930225@mimosa>
Download mbox | patch
Permalink /patch/15631/
State Accepted
Headers show

Comments

Yuya Nishihara - June 26, 2016, 8:37 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1466929017 -32400
#      Sun Jun 26 17:16:57 2016 +0900
# Node ID 540243aaab2dcc4e1e78de0936454462945c27e7
# Parent  25737d5695e2da9631e37ae304beabeb010ccf8f
revset: get rid of redundant error checking from match()

Actually there was no additional error checking. It should be caught by
"not all(specs)".
Gregory Szorc - June 26, 2016, 2:42 p.m.
On Sun, Jun 26, 2016 at 1:37 AM, Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1466929017 -32400
> #      Sun Jun 26 17:16:57 2016 +0900
> # Node ID 540243aaab2dcc4e1e78de0936454462945c27e7
> # Parent  25737d5695e2da9631e37ae304beabeb010ccf8f
> revset: get rid of redundant error checking from match()
>
> Actually there was no additional error checking. It should be caught by
> "not all(specs)".
>
>
This looks good. I had mixed the wires for the "if not specs" branch which
is a special case for returning an empty set.


> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -2529,8 +2529,6 @@ def posttreebuilthook(tree, repo):
>
>  def match(ui, spec, repo=None):
>      """Create a matcher for a single revision spec."""
> -    if not spec:
> -        raise error.ParseError(_("empty query"))
>      return matchany(ui, [spec], repo=repo)
>
>  def matchany(ui, specs, repo=None):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Augie Fackler - June 27, 2016, 5:01 p.m.
queued, thanks

> On Jun 26, 2016, at 10:42 AM, Gregory Szorc <gregory.szorc@gmail.com> wrote:
> 
> On Sun, Jun 26, 2016 at 1:37 AM, Yuya Nishihara <yuya@tcha.org <mailto:yuya@tcha.org>> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org <mailto:yuya@tcha.org>>
> # Date 1466929017 -32400
> #      Sun Jun 26 17:16:57 2016 +0900
> # Node ID 540243aaab2dcc4e1e78de0936454462945c27e7
> # Parent  25737d5695e2da9631e37ae304beabeb010ccf8f
> revset: get rid of redundant error checking from match()
> 
> Actually there was no additional error checking. It should be caught by
> "not all(specs)".
> 
> 
> This looks good. I had mixed the wires for the "if not specs" branch which is a special case for returning an empty set.
> 
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -2529,8 +2529,6 @@ def posttreebuilthook(tree, repo):
> 
>  def match(ui, spec, repo=None):
>      """Create a matcher for a single revision spec."""
> -    if not spec:
> -        raise error.ParseError(_("empty query"))
>      return matchany(ui, [spec], repo=repo)
> 
>  def matchany(ui, specs, repo=None):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org <mailto:Mercurial-devel@mercurial-scm.org>
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel <https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel>
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2529,8 +2529,6 @@  def posttreebuilthook(tree, repo):
 
 def match(ui, spec, repo=None):
     """Create a matcher for a single revision spec."""
-    if not spec:
-        raise error.ParseError(_("empty query"))
     return matchany(ui, [spec], repo=repo)
 
 def matchany(ui, specs, repo=None):