Patchwork [1,of,3] logcmdutil: make default parameters of changesetprinters consistent

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 4, 2018, 11:18 a.m.
Message ID <6815de5ad04ee7cc9407.1517743100@mimosa>
Download mbox | patch
Permalink /patch/27279/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 4, 2018, 11:18 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1516510026 -32400
#      Sun Jan 21 13:47:06 2018 +0900
# Node ID 6815de5ad04ee7cc94071b0806f8859bdc8e6435
# Parent  16b4cc4f0cd6f72f5b7be575a7498ed0017ccea5
logcmdutil: make default parameters of changesetprinters consistent

Patch

diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -122,12 +122,12 @@  def changesetlabels(ctx):
 class changesetprinter(object):
     '''show changeset information when templating not requested.'''
 
-    def __init__(self, ui, repo, matchfn, diffopts, buffered):
+    def __init__(self, ui, repo, matchfn=None, diffopts=None, buffered=False):
         self.ui = ui
         self.repo = repo
         self.buffered = buffered
         self.matchfn = matchfn
-        self.diffopts = diffopts
+        self.diffopts = diffopts or {}
         self.header = {}
         self.hunk = {}
         self.lastheader = None
@@ -290,7 +290,7 @@  class changesetprinter(object):
 class jsonchangeset(changesetprinter):
     '''format changeset information.'''
 
-    def __init__(self, ui, repo, matchfn, diffopts, buffered):
+    def __init__(self, ui, repo, matchfn=None, diffopts=None, buffered=False):
         changesetprinter.__init__(self, ui, repo, matchfn, diffopts, buffered)
         self.cache = {}
         self._first = True
@@ -399,8 +399,6 @@  class changesettemplater(changesetprinte
     # adding/removing arguments before "buffered" to not break callers.
     def __init__(self, ui, repo, tmplspec, matchfn=None, diffopts=None,
                  buffered=False):
-        diffopts = diffopts or {}
-
         changesetprinter.__init__(self, ui, repo, matchfn, diffopts, buffered)
         tres = formatter.templateresources(ui, repo)
         self.t = formatter.loadtemplater(ui, tmplspec,