diff hgext/bugzilla.py @ 28950:9e1c9f016b72

bugzilla: do not load style file if template is specified (BC) This prepares for the API change to support template aliases. I'm going to extract a factory function of templater that reads a map file: # original templater(mapfile, ..., cache, ...) # new templater.frommapfile(mapfile, ...) # read mapfile to build cache/map templater(..., cache, ...) # use specified cache (= map elements) This will make it clear to isolate stock styles (i.e. map files) from user aliases. Template aliases should be applied to command arguments and templates in hgrc, but not to map files. Otherwise, our stock styles and web templates could be modified unintentionally. This patch makes sure that either "tmpl" or "mapfile" is exclusively set. It's theoretically a behavior change, since you could put new keywords in template by defining them in a map file before: # mapfile foo = "{rev}" # hgrc [bugzilla] style = mapfile template = {foo} But the old behavior would be a bug because bugzilla.template is documented as "overrides style if specified". Also, common log-like templates and formatter doesn't allow using mapfile-keywords in a separate template. So I decided to make a BC. Since there was no test for the bugzilla extension, this adds new test that covers style/template output.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 04 Apr 2016 22:48:34 +0900
parents 2f0384242b35
children 80880ad3fccd
line wrap: on
line diff
--- a/hgext/bugzilla.py	Sat Apr 16 15:14:25 2016 -0500
+++ b/hgext/bugzilla.py	Mon Apr 04 22:48:34 2016 +0900
@@ -886,8 +886,10 @@
                 count -= 1
             return root
 
-        mapfile = self.ui.config('bugzilla', 'style')
+        mapfile = None
         tmpl = self.ui.config('bugzilla', 'template')
+        if not tmpl:
+            mapfile = self.ui.config('bugzilla', 'style')
         if not mapfile and not tmpl:
             tmpl = _('changeset {node|short} in repo {root} refers '
                      'to bug {bug}.\ndetails:\n\t{desc|tabindent}')