comparison mercurial/wireproto.py @ 37084:f0b6fbea00cf

stringutil: bulk-replace call sites to point to new module This might conflict with other patches floating around, sorry.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 22 Mar 2018 21:56:20 +0900
parents cd0ca979a8b8
children d4a2e0d5d042
comparison
equal deleted inserted replaced
37083:f99d64e8a4e4 37084:f0b6fbea00cf
30 pycompat, 30 pycompat,
31 repository, 31 repository,
32 streamclone, 32 streamclone,
33 util, 33 util,
34 wireprototypes, 34 wireprototypes,
35 )
36
37 from .utils import (
38 stringutil,
35 ) 39 )
36 40
37 urlerr = util.urlerr 41 urlerr = util.urlerr
38 urlreq = util.urlreq 42 urlreq = util.urlreq
39 43
992 k = encoding.tolocal(key) 996 k = encoding.tolocal(key)
993 c = repo[k] 997 c = repo[k]
994 r = c.hex() 998 r = c.hex()
995 success = 1 999 success = 1
996 except Exception as inst: 1000 except Exception as inst:
997 r = util.forcebytestr(inst) 1001 r = stringutil.forcebytestr(inst)
998 success = 0 1002 success = 0
999 return bytesresponse('%d %s\n' % (success, r)) 1003 return bytesresponse('%d %s\n' % (success, r))
1000 1004
1001 @wireprotocommand('known', 'nodes *', permission='pull') 1005 @wireprotocommand('known', 'nodes *', permission='pull')
1002 def known(repo, proto, nodes, others): 1006 def known(repo, proto, nodes, others):
1005 1009
1006 @wireprotocommand('pushkey', 'namespace key old new', permission='push') 1010 @wireprotocommand('pushkey', 'namespace key old new', permission='push')
1007 def pushkey(repo, proto, namespace, key, old, new): 1011 def pushkey(repo, proto, namespace, key, old, new):
1008 # compatibility with pre-1.8 clients which were accidentally 1012 # compatibility with pre-1.8 clients which were accidentally
1009 # sending raw binary nodes rather than utf-8-encoded hex 1013 # sending raw binary nodes rather than utf-8-encoded hex
1010 if len(new) == 20 and util.escapestr(new) != new: 1014 if len(new) == 20 and stringutil.escapestr(new) != new:
1011 # looks like it could be a binary node 1015 # looks like it could be a binary node
1012 try: 1016 try:
1013 new.decode('utf-8') 1017 new.decode('utf-8')
1014 new = encoding.tolocal(new) # but cleanly decodes as UTF-8 1018 new = encoding.tolocal(new) # but cleanly decodes as UTF-8
1015 except UnicodeDecodeError: 1019 except UnicodeDecodeError:
1121 if exc.parttype is not None: 1125 if exc.parttype is not None:
1122 errpart.addparam('parttype', exc.parttype) 1126 errpart.addparam('parttype', exc.parttype)
1123 if exc.params: 1127 if exc.params:
1124 errpart.addparam('params', '\0'.join(exc.params)) 1128 errpart.addparam('params', '\0'.join(exc.params))
1125 except error.Abort as exc: 1129 except error.Abort as exc:
1126 manargs = [('message', util.forcebytestr(exc))] 1130 manargs = [('message', stringutil.forcebytestr(exc))]
1127 advargs = [] 1131 advargs = []
1128 if exc.hint is not None: 1132 if exc.hint is not None:
1129 advargs.append(('hint', exc.hint)) 1133 advargs.append(('hint', exc.hint))
1130 bundler.addpart(bundle2.bundlepart('error:abort', 1134 bundler.addpart(bundle2.bundlepart('error:abort',
1131 manargs, advargs)) 1135 manargs, advargs))
1132 except error.PushRaced as exc: 1136 except error.PushRaced as exc:
1133 bundler.newpart('error:pushraced', 1137 bundler.newpart('error:pushraced',
1134 [('message', util.forcebytestr(exc))]) 1138 [('message', stringutil.forcebytestr(exc))])
1135 return streamres_legacy(gen=bundler.getchunks()) 1139 return streamres_legacy(gen=bundler.getchunks())