hgext3rd/evolve/obshistory.py
changeset 4946 bd992b1d4426
parent 4945 bd50608f54d8
child 4947 0ad2000854c4
--- a/hgext3rd/evolve/obshistory.py	Thu Nov 07 17:22:44 2019 -0800
+++ b/hgext3rd/evolve/obshistory.py	Thu Nov 07 16:34:01 2019 -0800
@@ -179,7 +179,7 @@
                 succs = sorted(succs)
 
                 for successor in succs:
-                    _debugobshistorydisplaymarker(markerfm, successor,
+                    _debugobshistorydisplaymarker(self.ui, markerfm, successor,
                                                   ctx.node(), self.repo,
                                                   self._includediff)
 
@@ -191,7 +191,7 @@
                     if not markers:
                         continue
                     successors = succset[b"successors"]
-                    _debugobshistorydisplaysuccsandmarkers(markerfm, successors, markers, ctx.node(), self.repo, self._includediff)
+                    _debugobshistorydisplaysuccsandmarkers(self.ui, markerfm, successors, markers, ctx.node(), self.repo, self._includediff)
 
             markerfm.end()
 
@@ -455,7 +455,7 @@
         markerfm = fm.nested(b"markers")
         for successor in sorted(succs):
             includediff = opts and opts.get("patch")
-            _debugobshistorydisplaymarker(markerfm, successor, ctxnode, unfi, includediff)
+            _debugobshistorydisplaymarker(ui, markerfm, successor, ctxnode, unfi, includediff)
         markerfm.end()
 
         precs = precursors.get(ctxnode, ())
@@ -497,7 +497,7 @@
              label=b"evolve.node evolve.missing_change_ctx")
     fm.plain(b'\n')
 
-def _debugobshistorydisplaymarker(fm, marker, node, repo, includediff=False):
+def _debugobshistorydisplaymarker(ui, fm, marker, node, repo, includediff=False):
     succnodes = marker[1]
     date = marker[4]
     metadata = dict(marker[3])
@@ -593,15 +593,18 @@
                 def tolist(text):
                     return [text]
 
-                fm.plain(b"\n")
+                ui.pushbuffer(labeled=True)
+                ui.write(b"\n")
 
                 for chunk, label in patch.difflabel(tolist, descriptionpatch):
                     chunk = chunk.strip(b'\t')
                     if chunk and chunk != b'\n':
-                        fm.plain(b'    ')
-                    fm.write(b'descdiff', b'%s', chunk, label=label)
+                        ui.write(b'    ')
+                    ui.write(chunk, label=label)
+                fm.write(b'descdiff', b'%s', ui.popbuffer())
 
             # Content patch
+            ui.pushbuffer(labeled=True)
             diffopts = patch.diffallopts(repo.ui, {})
             matchfn = scmutil.matchall(repo)
             firstline = True
@@ -609,14 +612,15 @@
             for chunk, label in patch.diffui(repo, node, succ, matchfn,
                                              opts=diffopts):
                 if firstline:
-                    fm.plain(b'\n')
+                    ui.write(b'\n')
                     firstline = False
                 if linestart:
-                    fm.plain(b'    ')
+                    ui.write(b'    ')
                     linestart = False
                 if chunk == b'\n':
                     linestart = True
-                fm.write(b'patch', b'%s', chunk, label=label)
+                ui.write(chunk, label=label)
+            fm.write(b'patch', b'%s', ui.popbuffer())
         else:
             nopatch = b"    (No patch available, %s)" % _patchavailable[1]
             fm.plain(b"\n")
@@ -625,7 +629,7 @@
 
     fm.plain(b"\n")
 
-def _debugobshistorydisplaysuccsandmarkers(fm, succnodes, markers, node, repo, includediff=False):
+def _debugobshistorydisplaysuccsandmarkers(ui, fm, succnodes, markers, node, repo, includediff=False):
     """
     This function is a duplication of _debugobshistorydisplaymarker modified
     to accept multiple markers as input.
@@ -733,15 +737,18 @@
                 def tolist(text):
                     return [text]
 
-                fm.plain(b"\n")
+                ui.pushbuffer(labeled=True)
+                ui.write(b"\n")
 
                 for chunk, label in patch.difflabel(tolist, descriptionpatch):
                     chunk = chunk.strip(b'\t')
                     if chunk and chunk != b'\n':
-                        fm.plain(b'    ')
-                    fm.write(b'descdiff', b'%s', chunk, label=label)
+                        ui.write(b'    ')
+                    ui.write(chunk, label=label)
+                fm.write(b'descdiff', b'%s', ui.popbuffer())
 
             # Content patch
+            ui.pushbuffer(labeled=True)
             diffopts = patch.diffallopts(repo.ui, {})
             matchfn = scmutil.matchall(repo)
             firstline = True
@@ -749,14 +756,15 @@
             for chunk, label in patch.diffui(repo, node, succ, matchfn,
                                              opts=diffopts):
                 if firstline:
-                    fm.plain(b'\n')
+                    ui.write(b'\n')
                     firstline = False
                 if linestart:
-                    fm.plain(b'    ')
+                    ui.write(b'    ')
                     linestart = False
                 if chunk == b'\n':
                     linestart = True
-                fm.write(b'patch', b'%s', chunk, label=label)
+                ui.write(chunk, label=label)
+            fm.write(b'patch', b'%s', ui.popbuffer())
         else:
             nopatch = b"    (No patch available, %s)" % _patchavailable[1]
             fm.plain(b"\n")