Patchwork D2400: stack: begin to make the stack revset configurable

login
register
mail settings
Submitter phabricator
Date Feb. 28, 2018, 11:59 p.m.
Message ID <9e759f8f8afe43cfa45780e958aa9c5e@localhost.localdomain>
Download mbox | patch
Permalink /patch/28516/
State Not Applicable
Headers show

Comments

phabricator - Feb. 28, 2018, 11:59 p.m.
lothiraldan updated this revision to Diff 6216.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2400?vs=6014&id=6216

REVISION DETAIL
  https://phab.mercurial-scm.org/D2400

AFFECTED FILES
  mercurial/configitems.py
  mercurial/stack.py

CHANGE DETAILS




To: lothiraldan, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/stack.py b/mercurial/stack.py
--- a/mercurial/stack.py
+++ b/mercurial/stack.py
@@ -12,18 +12,34 @@ 
     scmutil,
 )
 
+baserevspec = "only(%s) and not public()"
+
 def getstack(repo, rev=None):
     """return a sorted smartrev of the stack containing either rev if it is
     not None or the current working directory parent.
 
     The stack will always contain all drafts changesets which are ancestors to
-    the revision and are not merges.
+    the revision.
+
+    There are several config options to restrict the changesets that will be
+    part of the stack:
+
+    [stack]
+    not-merge = (boolean) # The stack will contains only non-merge changesets
+                          # if set to True (default: True)
     """
     if rev is None:
         rev = '.'
 
-    revspec = 'reverse(only(%s) and not public() and not ::merge())'
-    revset = revsetlang.formatspec(revspec, rev)
+    revspecargs = [revsetlang.formatspec(baserevspec, rev)]
+    revspec = ["%r"]
+
+    if repo.ui.configbool("stack", "not-merge"):
+        revspecargs.append("not ::merge()")
+        revspec.append("%r")
+
+    finalrevspec = " and ".join(revspec)
+    revset = revsetlang.formatspec(finalrevspec, *revspecargs)
     revisions = scmutil.revrange(repo, [revset])
     revisions.sort()
     return revisions
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -947,6 +947,9 @@ 
 coreconfigitem('sparse', 'missingwarning',
     default=True,
 )
+coreconfigitem('stack', 'not-merge',
+    default=True,
+)
 coreconfigitem('subrepos', 'allowed',
     default=dynamicdefault,  # to make backporting simpler
 )