Patchwork [9,of,9] ui: drop template aliases by HGPLAIN

login
register
mail settings
Submitter Yuya Nishihara
Date April 15, 2016, 1:15 p.m.
Message ID <1b182b6e357ccc59fc30.1460726148@mimosa>
Download mbox | patch
Permalink /patch/14648/
State Accepted
Headers show

Comments

Yuya Nishihara - April 15, 2016, 1:15 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1459080355 -32400
#      Sun Mar 27 21:05:55 2016 +0900
# Node ID 1b182b6e357ccc59fc30967630d4b150e038d2e7
# Parent  2c175aa76db0df4ecfd89861215d6dbd226329eb
ui: drop template aliases by HGPLAIN

Otherwise, scripting output could be suffered from user aliases.
Sean Farley - April 16, 2016, 6:53 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1459080355 -32400
> #      Sun Mar 27 21:05:55 2016 +0900
> # Node ID 1b182b6e357ccc59fc30967630d4b150e038d2e7
> # Parent  2c175aa76db0df4ecfd89861215d6dbd226329eb
> ui: drop template aliases by HGPLAIN
>
> Otherwise, scripting output could be suffered from user aliases.

I have no opinion on the BC of patches 1 and 2 since they don't really
affect things I use. Making aliases work like this is great. Reading
over the code, I didn't see any grave mistakes so this series looks fine
to me.
Matt Mackall - April 16, 2016, 9:09 p.m.
On Fri, 2016-04-15 at 22:15 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1459080355 -32400
> #      Sun Mar 27 21:05:55 2016 +0900
> # Node ID 1b182b6e357ccc59fc30967630d4b150e038d2e7
> # Parent  2c175aa76db0df4ecfd89861215d6dbd226329eb
> ui: drop template aliases by HGPLAIN

These are queued for default, thanks.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/mercurial/help/environment.txt b/mercurial/help/environment.txt
--- a/mercurial/help/environment.txt
+++ b/mercurial/help/environment.txt
@@ -69,6 +69,8 @@  HGPLAINEXCEPT
         Preserve internationalization.
     ``revsetalias``
         Don't remove revset aliases.
+    ``templatealias``
+        Don't remove template aliases.
     ``progress``
         Don't hide progress output.
 
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -192,6 +192,9 @@  class ui(object):
         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)
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -3756,6 +3756,13 @@  Aliases in formatter:
   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}'