Patchwork [6,of,8] revset: implement match() in terms of matchany()

login
register
mail settings
Submitter Pulkit Goyal
Date June 27, 2016, 1:43 p.m.
Message ID <25737d5695e2da9631e3.1467034997@pulkit-goyal>
Download mbox | patch
Permalink /patch/15641/
State Not Applicable
Headers show

Comments

Pulkit Goyal - June 27, 2016, 1:43 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1466907046 25200
#      Sat Jun 25 19:10:46 2016 -0700
# Node ID 25737d5695e2da9631e37ae304beabeb010ccf8f
# Parent  8362c2e98584b12f4925580dfe80853179f755b7
revset: implement match() in terms of matchany()

match() is the special case of a single element list being passed
to matchany() with the additional error checking that the revset
spec is defined. Change the implementation to remove the redundant
code and have match() call matchany().

Patch

diff -r 8362c2e98584 -r 25737d5695e2 mercurial/revset.py
--- a/mercurial/revset.py	Sat Jun 25 19:12:20 2016 -0700
+++ b/mercurial/revset.py	Sat Jun 25 19:10:46 2016 -0700
@@ -2528,13 +2528,10 @@ 
     pass
 
 def match(ui, spec, repo=None):
+    """Create a matcher for a single revision spec."""
     if not spec:
         raise error.ParseError(_("empty query"))
-    lookup = None
-    if repo:
-        lookup = repo.__contains__
-    tree = parse(spec, lookup)
-    return _makematcher(ui, tree, repo)
+    return matchany(ui, [spec], repo=repo)
 
 def matchany(ui, specs, repo=None):
     """Create a matcher that will include any revisions matching one of the