Patchwork formatter: set _first on formatter, not ui

login
register
mail settings
Submitter via Mercurial-devel
Date March 11, 2017, 7:40 a.m.
Message ID <0a1c1168645329de291d.1489218028@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/19097/
State Accepted
Headers show

Comments

via Mercurial-devel - March 11, 2017, 7:40 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@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.
Yuya Nishihara - March 11, 2017, 6:13 p.m.
On Fri, 10 Mar 2017 23:40:28 -0800, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@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

Queued, thanks.
Augie Fackler - March 11, 2017, 6:32 p.m.
On Fri, Mar 10, 2017 at 11:40:28PM -0800, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@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

Queued, thanks.

Patch

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(",")