obslog: extract display of a markers to its own function draft
authorRodrigo Damazio Bovendorp <rdamazio@google.com>
Sat, 01 Feb 2020 10:54:20 +0100
changeset 5250 265f30e3c50d
parent 5083 e50f4fc6cc6d
child 5251 353e546ab324
obslog: extract display of a markers to its own function
hgext3rd/evolve/obshistory.py
--- a/hgext3rd/evolve/obshistory.py	Mon Nov 04 00:18:55 2019 +0530
+++ b/hgext3rd/evolve/obshistory.py	Sat Feb 01 10:54:20 2020 +0100
@@ -166,37 +166,13 @@
             fm = self.ui.formatter(b'debugobshistory', _props)
 
             _debugobshistorydisplaynode(fm, self.repo, changenode)
-
-            markerfm = fm.nested(b"markers")
-
-            # Succs markers
-            if self.filter is False:
-                succs = self.repo.obsstore.successors.get(changenode, ())
-                succs = sorted(succs)
-
-                for successor in succs:
-                    _debugobshistorydisplaymarker(self.ui, markerfm, successor,
-                                                  ctx.node(), self.repo,
-                                                  self._includediff)
-
-            else:
-                r = obsutil.successorsandmarkers(self.repo, ctx)
-                if r is None:
-                    r = []
-
-                for succset in sorted(r):
-                    markers = succset[b"markers"]
-                    if not markers:
-                        continue
-                    successors = succset[b"successors"]
-                    _debugobshistorydisplaysuccsandmarkers(self.ui, markerfm, successors, markers, ctx.node(), self.repo, self._includediff)
-
-            markerfm.end()
+            _debugobshistorydisplaymarkers(self.ui, self.repo, fm, ctx,
+                                           self.filter, self._includediff)
 
             fm.plain(b'\n')
             fm.end()
 
-            self.hunk[ctx.node()] = self.ui.popbuffer()
+            self.hunk[changenode] = self.ui.popbuffer()
         else:
             ### graph output is buffered only
             msg = b'cannot be used outside of the graphlog (yet)'
@@ -496,7 +472,36 @@
              label=b"evolve.node evolve.missing_change_ctx")
     fm.plain(b'\n')
 
-def _debugobshistorydisplaymarker(ui, fm, marker, node, repo, includediff=False):
+def _debugobshistorydisplaymarkers(ui, repo, fm, ctx, filter_,
+                                   includediff=False):
+    changenode = ctx.node()
+    markerfm = fm.nested(b"markers")
+
+    # Succs markers
+    if filter_ is False:
+        succs = repo.obsstore.successors.get(changenode, ())
+        succs = sorted(succs)
+
+        for successor in succs:
+            _debugobshistorydisplaymarker(ui, markerfm, successor, changenode,
+                                          repo, includediff)
+
+    else:
+        r = obsutil.successorsandmarkers(repo, ctx) or []
+
+        for succset in sorted(r):
+            markers = succset[b"markers"]
+            if not markers:
+                continue
+            successors = succset[b"successors"]
+            _debugobshistorydisplaysuccsandmarkers(
+                ui, markerfm, successors, markers, changenode, repo,
+                includediff)
+
+    markerfm.end()
+
+def _debugobshistorydisplaymarker(ui, fm, marker, node, repo,
+                                  includediff=False):
     succnodes = marker[1]
     date = marker[4]
     metadata = dict(marker[3])