changeset 28958:77e566fe31ec

ui: drop template aliases by HGPLAIN Otherwise, scripting output could be suffered from user aliases.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 27 Mar 2016 21:05:55 +0900
parents d813132ea361
children 518c3e392f75
files mercurial/help/environment.txt mercurial/ui.py tests/test-command-template.t
diffstat 3 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help/environment.txt	Sun Mar 27 20:59:36 2016 +0900
+++ b/mercurial/help/environment.txt	Sun Mar 27 21:05:55 2016 +0900
@@ -69,6 +69,8 @@
         Preserve internationalization.
     ``revsetalias``
         Don't remove revset aliases.
+    ``templatealias``
+        Don't remove template aliases.
     ``progress``
         Don't hide progress output.
 
--- a/mercurial/ui.py	Sun Mar 27 20:59:36 2016 +0900
+++ b/mercurial/ui.py	Sun Mar 27 21:05:55 2016 +0900
@@ -192,6 +192,9 @@
         if self.plain('revsetalias'):
             for k, v in cfg.items('revsetalias'):
                 del cfg['revsetalias'][k]
+        if self.plain('templatealias'):
+            for k, v in cfg.items('templatealias'):
+                del cfg['templatealias'][k]
 
         if trusted:
             self._tcfg.update(cfg)
--- a/tests/test-command-template.t	Sun Mar 27 20:59:36 2016 +0900
+++ b/tests/test-command-template.t	Sun Mar 27 21:05:55 2016 +0900
@@ -3756,6 +3756,13 @@
   default 6:d41e714fe50d
   foo     4:bbe44766e73d
 
+Aliases should honor HGPLAIN:
+
+  $ HGPLAIN= hg log -r0 -T 'nothing expanded:{rn}\n'
+  nothing expanded:
+  $ HGPLAINEXCEPT=templatealias hg log -r0 -T '{rn}\n'
+  0:1e4e1b8f71e0
+
 Unparsable alias:
 
   $ hg debugtemplate --config templatealias.bad='x(' -v '{bad}'