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