Patchwork [1,of,2] formatter: introduce isplain() to replace (the inverse of) __nonzero__()

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 20, 2016, 1:06 p.m.
Message ID <20160920220622.5932752b1255a06c1bcb01e6@tcha.org>
Download mbox | patch
Permalink /patch/16682/
State Not Applicable
Delegated to: Ryan McElroy
Headers show

Comments

Yuya Nishihara - Sept. 20, 2016, 1:06 p.m.
On Mon, 19 Sep 2016 09:14:41 -0500, Mathias De Maré wrote:
> # HG changeset patch
> # User Mathias De Maré <mathias.demare@gmail.com>
> # Date 1472483949 -7200
> #      Mon Aug 29 17:19:09 2016 +0200
> # Node ID 084ca55ce77a5fe77bc93db26346cc71211a0070
> # Parent  285a8c3e53f2183438f0cdbc238e4ab851d0d110
> formatter: introduce isplain() to replace (the inverse of) __nonzero__()

You have one more "if fm:". Fixed as follows and queued this, thanks. Also
flagged as (API).

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4442,10 +4442,10 @@  def grep(ui, repo, pattern, *pats, **opt
 
     def display(fm, fn, ctx, pstates, states):
         rev = ctx.rev()
-        if fm:
+        if fm.isplain():
+            formatuser = ui.shortuser
+        else:
             formatuser = str
-        else:
-            formatuser = ui.shortuser
         if ui.quiet:
             datefmt = '%Y-%m-%d'
         else:
diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -141,8 +141,6 @@  class plainformatter(baseformatter):
             self.hexfunc = hex
         else:
             self.hexfunc = short
-    def __nonzero__(self):
-        return False
     def startitem(self):
         pass
     def data(self, **data):