Patchwork [1,of,4] stack: use repo.revs() instead of revsetlang.formatspec() + scmutil.revrange()

login
register
mail settings
Submitter Anton Shestakov
Date Sept. 23, 2019, 3:39 a.m.
Message ID <d81e537a421f78d9f1bf.1569209989@df1>
Download mbox | patch
Permalink /patch/41731/
State Accepted
Headers show

Comments

Anton Shestakov - Sept. 23, 2019, 3:39 a.m.
# HG changeset patch
# User Anton Shestakov <av6@dwimlabs.net>
# Date 1569137636 -25200
#      Sun Sep 22 14:33:56 2019 +0700
# Node ID d81e537a421f78d9f1bf6b3bdf736977ad126f68
# Parent  44be33cf7a5720f681fe902c83d8cc4aa1c26127
# EXP-Topic stack-object
stack: use repo.revs() instead of revsetlang.formatspec() + scmutil.revrange()

Using scmutil.revrange() it's possible to use multiple revsets at the same
time, but we're not using that functionality in stack.

I thought maybe that function could be used to make stack definition
customizable (by combining various parts into one set), but scmutil.revrange()
gives the union of all provided revsets, which is not very useful in stack's
case (we want "and" between parts, not "or").
Yuya Nishihara - Sept. 23, 2019, 12:53 p.m.
On Mon, 23 Sep 2019 10:39:49 +0700, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov <av6@dwimlabs.net>
> # Date 1569137636 -25200
> #      Sun Sep 22 14:33:56 2019 +0700
> # Node ID d81e537a421f78d9f1bf6b3bdf736977ad126f68
> # Parent  44be33cf7a5720f681fe902c83d8cc4aa1c26127
> # EXP-Topic stack-object
> stack: use repo.revs() instead of revsetlang.formatspec() + scmutil.revrange()

Queued this patch, thanks.

> diff --git a/mercurial/stack.py b/mercurial/stack.py
> --- a/mercurial/stack.py
> +++ b/mercurial/stack.py
> @@ -8,8 +8,6 @@
>  from __future__ import absolute_import
>  
>  from . import (
> -    revsetlang,
> -    scmutil,
>  )

Dropped an empty import, which is syntactically invalid.

Patch

diff --git a/mercurial/stack.py b/mercurial/stack.py
--- a/mercurial/stack.py
+++ b/mercurial/stack.py
@@ -8,8 +8,6 @@ 
 from __future__ import absolute_import
 
 from . import (
-    revsetlang,
-    scmutil,
 )
 
 def getstack(repo, rev=None):
@@ -23,7 +21,6 @@  def getstack(repo, rev=None):
         rev = '.'
 
     revspec = 'only(%s) and not public() and not ::merge()'
-    revset = revsetlang.formatspec(revspec, rev)
-    revisions = scmutil.revrange(repo, [revset])
+    revisions = repo.revs(revspec, rev)
     revisions.sort()
     return revisions