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