obshistory: prepare data for displaymarkers() in a separate function
authorAnton Shestakov <av6@dwimlabs.net>
Mon, 16 Mar 2020 19:13:33 +0700
changeset 5306 1e2f3fa129f2
parent 5305 292de4cca111
child 5307 66a913cc53af
obshistory: prepare data for displaymarkers() in a separate function
hgext3rd/evolve/obshistory.py
--- a/hgext3rd/evolve/obshistory.py	Mon Jan 13 16:32:25 2020 +0700
+++ b/hgext3rd/evolve/obshistory.py	Mon Mar 16 19:13:33 2020 +0700
@@ -136,6 +136,19 @@
     b"patch": TEMPLATE_PATCH,
 }
 
+def _nodesandmarkers(repo, ctx, filternonlocal):
+    if filternonlocal:
+        r = obsutil.successorsandmarkers(repo, ctx)
+        if r is None:
+            r = []
+        for succset in sorted(r):
+            if succset[b'markers']:
+                yield (succset[b'successors'], succset[b'markers'])
+    else:
+        markers = repo.obsstore.successors.get(ctx.node(), ())
+        for marker in sorted(markers):
+            yield (marker[1], [marker])
+
 class obsmarker_printer(logcmdutil.changesetprinter):
     """show (available) information about a node
 
@@ -173,28 +186,10 @@
 
             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:
-                    displaymarkers(self.ui, markerfm, successor[1],
-                                   [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"]
-                    displaymarkers(self.ui, markerfm, successors, markers,
-                                   ctx.node(), self.repo, self._includediff)
+            data = _nodesandmarkers(self.repo, ctx, self.filter)
+            for nodes, markers in data:
+                displaymarkers(self.ui, markerfm, nodes, markers, ctx.node(),
+                               self.repo, self._includediff)
 
             markerfm.end()