Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 33154:4ecc6047d45f
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.
Add a new test file to test it and not pollute other test files.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Mon, 26 Jun 2017 15:46:24 +0200 |
parents | 1b6946f87c50 |
children | 20f533a92eda |
comparison
equal
deleted
inserted
replaced
33153:4d780d510b44 | 33154:4ecc6047d45f |
---|---|
1409 if ctx.troubled(): | 1409 if ctx.troubled(): |
1410 # i18n: column positioning for "hg log" | 1410 # i18n: column positioning for "hg log" |
1411 self.ui.write(_("trouble: %s\n") % ', '.join(ctx.troubles()), | 1411 self.ui.write(_("trouble: %s\n") % ', '.join(ctx.troubles()), |
1412 label='log.trouble') | 1412 label='log.trouble') |
1413 | 1413 |
1414 self._exthook(ctx) | |
1415 | |
1414 if self.ui.debugflag: | 1416 if self.ui.debugflag: |
1415 files = ctx.p1().status(ctx)[:3] | 1417 files = ctx.p1().status(ctx)[:3] |
1416 for key, value in zip([# i18n: column positioning for "hg log" | 1418 for key, value in zip([# i18n: column positioning for "hg log" |
1417 _("files:"), | 1419 _("files:"), |
1418 # i18n: column positioning for "hg log" | 1420 # i18n: column positioning for "hg log" |
1454 description.splitlines()[0], | 1456 description.splitlines()[0], |
1455 label='log.summary') | 1457 label='log.summary') |
1456 self.ui.write("\n") | 1458 self.ui.write("\n") |
1457 | 1459 |
1458 self.showpatch(ctx, matchfn) | 1460 self.showpatch(ctx, matchfn) |
1461 | |
1462 def _exthook(self, ctx): | |
1463 '''empty method used by extension as a hook point | |
1464 ''' | |
1465 pass | |
1459 | 1466 |
1460 def showpatch(self, ctx, matchfn): | 1467 def showpatch(self, ctx, matchfn): |
1461 if not matchfn: | 1468 if not matchfn: |
1462 matchfn = self.matchfn | 1469 matchfn = self.matchfn |
1463 if matchfn: | 1470 if matchfn: |