comparison hgext/convert/convcmd.py @ 36133:6df206ef4b10

convcmd: pass encoding name as a sysstr Differential Revision: https://phab.mercurial-scm.org/D2221
author Augie Fackler <augie@google.com>
date Mon, 12 Feb 2018 23:51:18 -0500
parents 42a393ea56d2
children 0f9e52f900c4
comparison
equal deleted inserted replaced
36132:42a393ea56d2 36133:6df206ef4b10
14 from mercurial.i18n import _ 14 from mercurial.i18n import _
15 from mercurial import ( 15 from mercurial import (
16 encoding, 16 encoding,
17 error, 17 error,
18 hg, 18 hg,
19 pycompat,
19 scmutil, 20 scmutil,
20 util, 21 util,
21 ) 22 )
22 23
23 from . import ( 24 from . import (
53 54
54 orig_encoding = 'ascii' 55 orig_encoding = 'ascii'
55 56
56 def recode(s): 57 def recode(s):
57 if isinstance(s, unicode): 58 if isinstance(s, unicode):
58 return s.encode(orig_encoding, 'replace') 59 return s.encode(pycompat.sysstr(orig_encoding), 'replace')
59 else: 60 else:
60 return s.decode('utf-8').encode(orig_encoding, 'replace') 61 return s.decode('utf-8').encode(
62 pycompat.sysstr(orig_encoding), 'replace')
61 63
62 def mapbranch(branch, branchmap): 64 def mapbranch(branch, branchmap):
63 ''' 65 '''
64 >>> bmap = {b'default': b'branch1'} 66 >>> bmap = {b'default': b'branch1'}
65 >>> for i in [b'', None]: 67 >>> for i in [b'', None]: