[PATCH 6 of 7] obsutil: make obsfateprinter() less dependent on templater

Yuya Nishihara yuya at tcha.org
Wed Apr 4 10:48:57 EDT 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1521459126 -32400
#      Mon Mar 19 20:32:06 2018 +0900
# Node ID 3e8117550703c88ed14a84e9db133eb2390adaa4
# Parent  4bfb025606df5d48f9052f47a45cdfe6a2d61439
obsutil: make obsfateprinter() less dependent on templater

joinfmt() is defined as 'lambda x: scmutil.formatchangeid(repo[x])' in
showsuccsandmarkers().

Function arguments are reordered so they look more normal.

diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -832,7 +832,7 @@ def markersoperations(markers):
 
     return sorted(operations)
 
-def obsfateprinter(successors, markers, ui):
+def obsfateprinter(ui, repo, successors, markers, formatctx):
     """ Build a obsfate string for a single successorset using all obsfate
     related function defined in obsutil
     """
@@ -852,7 +852,7 @@ def obsfateprinter(successors, markers, 
 
     # Successors
     if successors:
-        fmtsuccessors = [successors.joinfmt(succ) for succ in successors]
+        fmtsuccessors = [formatctx(repo[succ]) for succ in successors]
         line.append(" as %s" % ", ".join(fmtsuccessors))
 
     # Users
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -498,10 +498,13 @@ def showobsfate(context, mapping):
     succsandmarkers = showsuccsandmarkers(context, mapping)
 
     ui = context.resource(mapping, 'ui')
+    repo = context.resource(mapping, 'repo')
     values = []
 
     for x in succsandmarkers:
-        values.append(obsutil.obsfateprinter(x['successors'], x['markers'], ui))
+        v = obsutil.obsfateprinter(ui, repo, x['successors'], x['markers'],
+                                   scmutil.formatchangeid)
+        values.append(v)
 
     return compatlist(context, mapping, "fate", values)
 


More information about the Mercurial-devel mailing list