comparison tests/test-log-exthook.t @ 39657:2b9f315a4217

py3: use codecs.encode() to encode in rot-13 encoding The other occurence will need some more love as description is bytes by default and we need to decode it and then encode it. Differential Revision: https://phab.mercurial-scm.org/D4608
author Pulkit Goyal <pulkit@yandex-team.ru>
date Sun, 16 Sep 2018 19:58:01 +0530
parents c8e2d6ed1f9e
children 005bc856e919
comparison
equal deleted inserted replaced
39656:e3768bd48e26 39657:2b9f315a4217
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