[PATCH] formatter: set _first on formatter, not ui

Martin von Zweigbergk martinvonz at google.com
Sat Mar 11 02:40:28 EST 2017


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1489102680 28800
#      Thu Mar 09 15:38:00 2017 -0800
# Node ID 0a1c1168645329de291d3e3643a6ec007e1eee07
# Parent  2a1b16dbb9c4760002059d97c15cd0828fb1fb60
formatter: set _first on formatter, not ui

The _first field is used for tracking when to emit a separator between
items. It seems like it's clearly formatter state, not ui state, so
let's move it there.

diff -r 2a1b16dbb9c4 -r 0a1c11686453 mercurial/formatter.py
--- a/mercurial/formatter.py	Mon Mar 06 18:42:36 2017 -0500
+++ b/mercurial/formatter.py	Thu Mar 09 15:38:00 2017 -0800
@@ -305,10 +305,10 @@
         baseformatter.__init__(self, ui, topic, opts, _nullconverter)
         self._out = out
         self._out.write("[")
-        self._ui._first = True
+        self._first = True
     def _showitem(self):
-        if self._ui._first:
-            self._ui._first = False
+        if self._first:
+            self._first = False
         else:
             self._out.write(",")
 


More information about the Mercurial-devel mailing list