cmdutil: use named arguments for changeset_templater.__init__
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 24 Jun 2017 11:47:26 -0700
changeset 33045 99c6c9fa9e6d
parent 33044 1d2b68952950
child 33046 11f768258dcc
cmdutil: use named arguments for changeset_templater.__init__ This will make the API more extensible and easier to use.
mercurial/cmdutil.py
--- 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.