Patchwork [3,of,6] formatter: add nullformatter

login
register
mail settings
Submitter Yuya Nishihara
Date May 30, 2017, 4:07 p.m.
Message ID <aa8b8c29ea0f3345ee49.1496160431@mimosa>
Download mbox | patch
Permalink /patch/21070/
State Accepted
Headers show

Comments

Yuya Nishihara - May 30, 2017, 4:07 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1495874666 -32400
#      Sat May 27 17:44:26 2017 +0900
# Node ID aa8b8c29ea0f3345ee490275a42c279fbe1f6e39
# Parent  3b1c26a047eb15f0d606ad6816a04cf83a0c9fc6
formatter: add nullformatter

This can be used as a placeholder variable.

Patch

diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -207,6 +207,10 @@  class baseformatter(object):
         if self._item is not None:
             self._showitem()
 
+def nullformatter(ui, topic):
+    '''formatter that prints nothing'''
+    return baseformatter(ui, topic, opts={}, converter=_nullconverter)
+
 class _nestedformatter(baseformatter):
     '''build sub items and store them in the parent formatter'''
     def __init__(self, ui, converter, data):