changeset 37886:3fe1c9263024

log: consume --stat/patch options at constructor of changesetprinter The variable name, self.diffopts, was confusing. Let's split it to two booleans.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 29 Apr 2018 15:52:01 +0900
parents e0f30c91dfd8
children 395571419274
files mercurial/logcmdutil.py
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/logcmdutil.py	Sun Apr 29 15:44:17 2018 +0900
+++ b/mercurial/logcmdutil.py	Sun Apr 29 15:52:01 2018 +0900
@@ -155,7 +155,8 @@
         self.buffered = buffered
         self._differ = differ or changesetdiffer()
         self._diffopts = patch.diffallopts(ui, diffopts)
-        self.diffopts = diffopts or {}
+        self._includestat = diffopts and diffopts.get('stat')
+        self._includediff = diffopts and diffopts.get('patch')
         self.header = {}
         self.hunk = {}
         self.lastheader = None
@@ -299,15 +300,13 @@
         '''
 
     def _showpatch(self, ctx):
-        stat = self.diffopts.get('stat')
-        diff = self.diffopts.get('patch')
-        if stat:
+        if self._includestat:
             self._differ.showdiff(self.ui, ctx, self._diffopts, stat=True)
-        if stat and diff:
+        if self._includestat and self._includediff:
             self.ui.write("\n")
-        if diff:
+        if self._includediff:
             self._differ.showdiff(self.ui, ctx, self._diffopts, stat=False)
-        if stat or diff:
+        if self._includestat or self._includediff:
             self.ui.write("\n")
 
 class changesetformatter(changesetprinter):
@@ -368,13 +367,11 @@
                 fm.data(copies=fm.formatdict(copies,
                                              key='name', value='source'))
 
-        stat = self.diffopts.get('stat')
-        diff = self.diffopts.get('patch')
-        if stat:
+        if self._includestat:
             self.ui.pushbuffer()
             self._differ.showdiff(self.ui, ctx, self._diffopts, stat=True)
             fm.data(diffstat=self.ui.popbuffer())
-        if diff:
+        if self._includediff:
             self.ui.pushbuffer()
             self._differ.showdiff(self.ui, ctx, self._diffopts, stat=False)
             fm.data(diff=self.ui.popbuffer())