[PATCH] log: add an extension hook-point in changeset_printer

Boris Feld boris.feld at octobus.net
Wed Jun 28 10:02:29 EDT 2017


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1498484784 -7200
#      Mon Jun 26 15:46:24 2017 +0200
# Node ID 51dd67d33413b1219a9dccf87bf8a0306cc9fb5d
# Parent  247bae545061374a683d8d9369a4869aa6ae4537
# EXP-Topic changesetprinterhook
log: add an extension hook-point in changeset_printer

Extensions sometimes wants to add other information in the default log output
format (when no templating is used).

Add an empty function named 'exthook' for easing the extension life.
Extensions will be able to wrap this function and collaborate to display
additional information.

Exthook is called after displaying troubles and just before displaying the
files, extra and description.

diff -r 247bae545061 -r 51dd67d33413 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Tue Jun 27 23:50:22 2017 +0900
+++ b/mercurial/cmdutil.py	Mon Jun 26 15:46:24 2017 +0200
@@ -1381,6 +1381,7 @@
             for name in ns.names(self.repo, changenode):
                 self.ui.write(ns.logfmt % name,
                               label='log.%s' % ns.colorname)
+
         if self.ui.debugflag:
             # i18n: column positioning for "hg log"
             self.ui.write(_("phase:       %s\n") % ctx.phasestr(),
@@ -1411,6 +1412,8 @@
             self.ui.write(_("trouble:     %s\n") % ', '.join(ctx.troubles()),
                           label='log.trouble')
 
+        self.exthook(ctx)
+
         if self.ui.debugflag:
             files = ctx.p1().status(ctx)[:3]
             for key, value in zip([# i18n: column positioning for "hg log"
@@ -1457,6 +1460,11 @@
 
         self.showpatch(ctx, matchfn)
 
+    def exthook(self, ctx):
+        '''empty method used by extension as a hook point
+        '''
+        pass
+
     def showpatch(self, ctx, matchfn):
         if not matchfn:
             matchfn = self.matchfn


More information about the Mercurial-devel mailing list