changeset 33057:99c6c9fa9e6d

cmdutil: use named arguments for changeset_templater.__init__ This will make the API more extensible and easier to use.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 24 Jun 2017 11:47:26 -0700
parents 1d2b68952950
children 11f768258dcc
files mercurial/cmdutil.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Thu Jun 22 21:45:32 2017 -0700
+++ b/mercurial/cmdutil.py	Sat Jun 24 11:47:26 2017 -0700
@@ -1577,7 +1577,12 @@
 class changeset_templater(changeset_printer):
     '''format changeset information.'''
 
-    def __init__(self, ui, repo, tmplspec, matchfn, diffopts, buffered):
+    # Arguments before "buffered" used to be positional. Consider not
+    # adding/removing arguments before "buffered" to not break callers.
+    def __init__(self, ui, repo, tmplspec, matchfn=None, diffopts=None,
+                 buffered=False):
+        diffopts = diffopts or {}
+
         changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
         self.t = formatter.loadtemplater(ui, tmplspec,
                                          cache=templatekw.defaulttempl)
@@ -1694,8 +1699,7 @@
 def makelogtemplater(ui, repo, tmpl, buffered=False):
     """Create a changeset_templater from a literal template 'tmpl'"""
     spec = logtemplatespec(tmpl, None)
-    return changeset_templater(ui, repo, spec, matchfn=None, diffopts={},
-                               buffered=buffered)
+    return changeset_templater(ui, repo, spec, buffered=buffered)
 
 def show_changeset(ui, repo, opts, buffered=False):
     """show one changeset using template or regular display.