diff mercurial/templater.py @ 33993:3d0f8918351b

template: compute verb in obsfateverb Add a template function obsfateverb which use the markers information to compute a better obsfate verb. The current logic behind the obsfate verb is simple for the moment: - If the successorsets is empty, the changeset has been pruned, for example: Obsfate: pruned - If the successorsets length is 1, the changeset has been rewritten without divergence, for example: Obsfate: rewritten as 2:337fec4d2edc, 3:f257fde29c7a - If the successorsets length is more than 1, the changeset has diverged, for example: Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a As the divergence might occurs on a subset of successors, we might see some successors twice: Obsfate: split as 9:0b997eb7ceee, 5:dd800401bd8c, 10:eceed8f98ffc; split as 8:b18bc8331526, 5:dd800401bd8c, 10:eceed8f98ffc
author Boris Feld <boris.feld@octobus.net>
date Mon, 03 Jul 2017 15:33:27 +0200
parents 2943141f5e07
children 38f08eaba6b0
line wrap: on
line diff
--- a/mercurial/templater.py	Tue Aug 22 17:16:13 2017 -0400
+++ b/mercurial/templater.py	Mon Jul 03 15:33:27 2017 +0200
@@ -18,6 +18,7 @@
     encoding,
     error,
     minirst,
+    obsutil,
     parser,
     pycompat,
     registrar,
@@ -849,6 +850,22 @@
     func = lambda a, b: a % b
     return runarithmetic(context, mapping, (func, args[0], args[1]))
 
+@templatefunc('obsfateverb(successors)')
+def obsfateverb(context, mapping, args):
+    """Compute obsfate related information based on successors (EXPERIMENTAL)"""
+    if len(args) != 1:
+        # i18n: "obsfateverb" is a keyword
+        raise error.ParseError(_("obsfateverb expects one arguments"))
+
+    successors = evalfuncarg(context, mapping, args[0])
+
+    try:
+        return obsutil.successorsetverb(successors)
+    except TypeError:
+        # i18n: "obsfateverb" is a keyword
+        errmsg = _("obsfateverb first argument should be countable")
+        raise error.ParseError(errmsg)
+
 @templatefunc('relpath(path)')
 def relpath(context, mapping, args):
     """Convert a repository-absolute path into a filesystem path relative to