Patchwork revset: changed mfunc and getset to work with old style revset methods

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 19, 2014, 8:40 p.m.
Message ID <c95fce949172ed8daaba.1392842446@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3700/
State Accepted
Commit bde426f18e0a05057fb64a8aa0d29fffc9841f95
Headers show

Comments

Lucas Moscovicz - Feb. 19, 2014, 8:40 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@fb.com>
# Date 1392767686 28800
#      Tue Feb 18 15:54:46 2014 -0800
# Node ID c95fce949172ed8daababc858b1980046fb581da
# Parent  c29948fed40a2d9755ecaa01ec05bfa542f65670
revset: changed mfunc and getset to work with old style revset methods

Now extensions shouldn't break when adding new revsets.
Matt Mackall - Feb. 19, 2014, 9:59 p.m.
On Wed, 2014-02-19 at 12:40 -0800, Lucas Moscovicz wrote:
> # HG changeset patch
> # User Lucas Moscovicz <lmoscovicz@fb.com>
> # Date 1392767686 28800
> #      Tue Feb 18 15:54:46 2014 -0800
> # Node ID c95fce949172ed8daababc858b1980046fb581da
> # Parent  c29948fed40a2d9755ecaa01ec05bfa542f65670
> revset: changed mfunc and getset to work with old style revset methods
> 
> Now extensions shouldn't break when adding new revsets.

Queued for default, thanks.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -195,7 +195,10 @@ 
 def getset(repo, subset, x):
     if not x:
         raise error.ParseError(_("missing argument"))
-    return methods[x[0]](repo, subset, *x[1:])
+    s = methods[x[0]](repo, subset, *x[1:])
+    if util.safehasattr(s, 'set'):
+        return s
+    return baseset(s)
 
 def _getrevsource(repo, r):
     extra = repo[r].extra()
@@ -1919,7 +1922,9 @@ 
         tree = findaliases(ui, tree)
     weight, tree = optimize(tree, True)
     def mfunc(repo, subset):
-        return getset(repo, subset, tree)
+        if util.safehasattr(subset, 'set'):
+            return getset(repo, subset, tree)
+        return getset(repo, baseset(subset), tree)
     return mfunc
 
 def formatspec(expr, *args):