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