[PATCH] ui: disable revsetaliases in plain mode

Siddharth Agarwal sid0 at fb.com
Thu Apr 30 15:10:09 UTC 2015


# HG changeset patch
# User Siddharth Agarwal <sid0 at 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.

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


More information about the Mercurial-devel mailing list