Patchwork [2,of,8] changeset_templater: do not enable verbosity postfix for [templates] section

login
register
mail settings
Submitter Yuya Nishihara
Date June 20, 2017, 3:57 p.m.
Message ID <9107c695a656eaec6ccc.1497974244@mimosa>
Download mbox | patch
Permalink /patch/21534/
State Accepted
Headers show

Comments

Yuya Nishihara - June 20, 2017, 3:57 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1492862947 -32400
#      Sat Apr 22 21:09:07 2017 +0900
# Node ID 9107c695a656eaec6ccc02416660236e912a455c
# Parent  504f31ba18b5336a0c463462be8e382f26a9b8ec
changeset_templater: do not enable verbosity postfix for [templates] section

Since this postfix hack exists only for backward compatibility, we don't need
it for new [templates] section. This isn't a BC as templates defined in
[templates] section weren't loaded until recently.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1584,23 +1584,24 @@  class changeset_templater(changeset_prin
         self._counter = itertools.count()
         self.cache = {}
 
-        # find correct templates for current mode
-        tmplmodes = [
-            (True, ''),
-            (self.ui.verbose, '_verbose'),
-            (self.ui.quiet, '_quiet'),
-            (self.ui.debugflag, '_debug'),
-        ]
-
         self._tref = tmplspec.ref
         self._parts = {'header': '', 'footer': '',
                        tmplspec.ref: tmplspec.ref,
                        'docheader': '', 'docfooter': ''}
-        for mode, postfix in tmplmodes:
-            for t in self._parts:
-                cur = t + postfix
-                if mode and cur in self.t:
-                    self._parts[t] = cur
+        if tmplspec.mapfile:
+            # find correct templates for current mode, for backward
+            # compatibility with 'log -v/-q/--debug' using a mapfile
+            tmplmodes = [
+                (True, ''),
+                (self.ui.verbose, '_verbose'),
+                (self.ui.quiet, '_quiet'),
+                (self.ui.debugflag, '_debug'),
+            ]
+            for mode, postfix in tmplmodes:
+                for t in self._parts:
+                    cur = t + postfix
+                    if mode and cur in self.t:
+                        self._parts[t] = cur
 
         if self._parts['docheader']:
             self.ui.write(templater.stringify(self.t(self._parts['docheader'])))