Show More
@@ -0,0 +1,56 b'' | |||
|
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 |
@@ -1411,6 +1411,8 b' class changeset_printer(object):' | |||
|
1411 | 1411 | self.ui.write(_("trouble: %s\n") % ', '.join(ctx.troubles()), |
|
1412 | 1412 | label='log.trouble') |
|
1413 | 1413 | |
|
1414 | self._exthook(ctx) | |
|
1415 | ||
|
1414 | 1416 | if self.ui.debugflag: |
|
1415 | 1417 | files = ctx.p1().status(ctx)[:3] |
|
1416 | 1418 | for key, value in zip([# i18n: column positioning for "hg log" |
@@ -1457,6 +1459,11 b' class changeset_printer(object):' | |||
|
1457 | 1459 | |
|
1458 | 1460 | self.showpatch(ctx, matchfn) |
|
1459 | 1461 | |
|
1462 | def _exthook(self, ctx): | |
|
1463 | '''empty method used by extension as a hook point | |
|
1464 | ''' | |
|
1465 | pass | |
|
1466 | ||
|
1460 | 1467 | def showpatch(self, ctx, matchfn): |
|
1461 | 1468 | if not matchfn: |
|
1462 | 1469 | matchfn = self.matchfn |
General Comments 0
You need to be logged in to leave comments.
Login now