changeset 24883:09049042ab99 stable

ui: disable revsetaliases in plain mode (BC) 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.
author Siddharth Agarwal <sid0@fb.com>
date Thu, 30 Apr 2015 07:46:54 -0700
parents 995003a324da
children d7778b88838c
files mercurial/ui.py tests/test-revset.t
diffstat 2 files changed, 57 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Wed Apr 29 19:47:37 2015 +0900
+++ b/mercurial/ui.py	Thu Apr 30 07:46:54 2015 -0700
@@ -169,6 +169,9 @@
         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)
--- a/tests/test-revset.t	Wed Apr 29 19:47:37 2015 +0900
+++ b/tests/test-revset.t	Thu Apr 30 07:46:54 2015 -0700
@@ -1049,6 +1049,8 @@
 
   $ 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 @@
     <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