comparison mercurial/stack.py @ 42960:763028fc6a69

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").
author Anton Shestakov <av6@dwimlabs.net>
date Sun, 22 Sep 2019 14:33:56 +0700
parents 77c52ce50e6a
children 57875cf423c9
comparison
equal deleted inserted replaced
42959:af2b5562fcaf 42960:763028fc6a69
4 # 4 #
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9
10 from . import (
11 revsetlang,
12 scmutil,
13 )
14 9
15 def getstack(repo, rev=None): 10 def getstack(repo, rev=None):
16 """return a sorted smartrev of the stack containing either rev if it is 11 """return a sorted smartrev of the stack containing either rev if it is
17 not None or the current working directory parent. 12 not None or the current working directory parent.
18 13
21 """ 16 """
22 if rev is None: 17 if rev is None:
23 rev = '.' 18 rev = '.'
24 19
25 revspec = 'only(%s) and not public() and not ::merge()' 20 revspec = 'only(%s) and not public() and not ::merge()'
26 revset = revsetlang.formatspec(revspec, rev) 21 revisions = repo.revs(revspec, rev)
27 revisions = scmutil.revrange(repo, [revset])
28 revisions.sort() 22 revisions.sort()
29 return revisions 23 return revisions