comparison tests/test-log-exthook.t @ 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
children bfafd189edd9
comparison
equal deleted inserted replaced
33153:4d780d510b44 33154:4ecc6047d45f
1 Test hg log changeset printer external hook
2 -------------------------------------------
3
4 $ cat > $TESTTMP/logexthook.py <<EOF
5 > from mercurial import repair, commands
6 > from mercurial import cmdutil
7 > def rot13description(self, ctx):
8 > summary = "summary".encode('rot13')
9 > description = ctx.description().strip().splitlines()[0].encode('rot13')
10 > self.ui.write("%s: %s\n" % (summary, description))
11 > def reposetup(ui, repo):
12 > cmdutil.changeset_printer._exthook = rot13description
13 > EOF
14
15 Prepare the repository
16
17 $ hg init empty
18 $ cd empty
19 $ touch ROOT
20 $ hg commit -A -m "Root" ROOT
21
22 $ touch a b c
23 $ hg commit -A -m "Add A, B, C" a b c
24
25 Check the log
26
27 $ hg log --config extensions.t=$TESTTMP/logexthook.py
28 changeset: 1:70fc82b23320
29 tag: tip
30 user: test
31 date: Thu Jan 01 00:00:00 1970 +0000
32 fhzznel: Nqq N, O, P
33 summary: Add A, B, C
34
35 changeset: 0:b00443a54871
36 user: test
37 date: Thu Jan 01 00:00:00 1970 +0000
38 fhzznel: Ebbg
39 summary: Root
40
41 Check that exthook is working with graph log too
42
43 $ hg log -G --config extensions.t=$TESTTMP/logexthook.py
44 @ changeset: 1:70fc82b23320
45 | tag: tip
46 | user: test
47 | date: Thu Jan 01 00:00:00 1970 +0000
48 | fhzznel: Nqq N, O, P
49 | summary: Add A, B, C
50 |
51 o changeset: 0:b00443a54871
52 user: test
53 date: Thu Jan 01 00:00:00 1970 +0000
54 fhzznel: Ebbg
55 summary: Root
56