Patchwork ui: disable revsetaliases in plain mode

login
register
mail settings
Submitter Siddharth Agarwal
Date April 30, 2015, 3:10 p.m.
Message ID <35d888240f67b81b5bdb.1430406609@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8821/
State Accepted
Headers show

Comments

Siddharth Agarwal - April 30, 2015, 3:10 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1430405214 25200
#      Thu Apr 30 07:46:54 2015 -0700
# Branch stable
# Node ID 35d888240f67b81b5bdba80c9b3c1dfa85ea3b4a
# Parent  995003a324da67242e5c4e9afa18fe9d335f9985
ui: disable revsetaliases in plain mode

ui.plain() is supposed to disable config options that change the UI to the
detriment of scripts. As the test demonstrates, revset aliases can actually
override builtin ones, just like command aliases. Therefore I believe this is a
bugfix and appropriate for stable.
Matt Mackall - April 30, 2015, 4:39 p.m.
On Thu, 2015-04-30 at 08:10 -0700, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1430405214 25200
> #      Thu Apr 30 07:46:54 2015 -0700
> # Branch stable
> # Node ID 35d888240f67b81b5bdba80c9b3c1dfa85ea3b4a
> # Parent  995003a324da67242e5c4e9afa18fe9d335f9985
> ui: disable revsetaliases in plain mode

Queued for stable, thanks. I'm slapping a (BC) on this so it appears in
the release notes.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -169,6 +169,9 @@  class ui(object):
         if self.plain('alias'):
             for k, v in cfg.items('alias'):
                 del cfg['alias'][k]
+        if self.plain('revsetalias'):
+            for k, v in cfg.items('revsetalias'):
+                del cfg['revsetalias'][k]
 
         if trusted:
             self._tcfg.update(cfg)
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1049,6 +1049,8 @@  aliases:
 
   $ echo '[revsetalias]' >> .hg/hgrc
   $ echo 'm = merge()' >> .hg/hgrc
+(revset aliases can override builtin revsets)
+  $ echo 'p2($1) = p1($1)' >> .hg/hgrc
   $ echo 'sincem = descendants(m)' >> .hg/hgrc
   $ echo 'd($1) = reverse(sort($1, date))' >> .hg/hgrc
   $ echo 'rs(ARG1, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
@@ -1064,6 +1066,58 @@  aliases:
     <fullreposet+ 0:9>>
   6
 
+  $ HGPLAIN=1 try m
+  ('symbol', 'm')
+  abort: unknown revision 'm'!
+  [255]
+
+  $ HGPLAIN=1 HGPLAINEXCEPT=revsetalias try m
+  ('symbol', 'm')
+  (func
+    ('symbol', 'merge')
+    None)
+  * set:
+  <filteredset
+    <fullreposet+ 0:9>>
+  6
+
+(for some reason HGPLAIN and HGPLAINEXCEPT can carry forward)
+
+  $ unset HGPLAIN
+  $ unset HGPLAINEXCEPT
+
+  $ try 'p2(.)'
+  (func
+    ('symbol', 'p2')
+    ('symbol', '.'))
+  (func
+    ('symbol', 'p1')
+    ('symbol', '.'))
+  * set:
+  <baseset+ [8]>
+  8
+
+  $ HGPLAIN=1 try 'p2(.)'
+  (func
+    ('symbol', 'p2')
+    ('symbol', '.'))
+  * set:
+  <baseset+ []>
+
+  $ HGPLAIN=1 HGPLAINEXCEPT=revsetalias try 'p2(.)'
+  (func
+    ('symbol', 'p2')
+    ('symbol', '.'))
+  (func
+    ('symbol', 'p1')
+    ('symbol', '.'))
+  * set:
+  <baseset+ [8]>
+  8
+
+  $ unset HGPLAIN
+  $ unset HGPLAINEXCEPT
+
 test alias recursion
 
   $ try sincem