py3: port things from chgserver.py
authorPulkit Goyal <pulkit@yandex-team.ru>
Sat, 02 Mar 2019 05:12:45 +0530
changeset 41828 bce2356ece68
parent 41827 faa04f45b5fe
child 41829 8e364664a999
py3: port things from chgserver.py I have installed mercurial on my personal laptop using Python 3.7. I also have hg aliased to chg. Before this commit, `hg version` didn't work. After this patch, things are better and now chg works. Differential Revision: https://phab.mercurial-scm.org/D6040
mercurial/chgserver.py
--- a/mercurial/chgserver.py	Sat Mar 02 05:01:00 2019 +0530
+++ b/mercurial/chgserver.py	Sat Mar 02 05:12:45 2019 +0530
@@ -64,11 +64,12 @@
 
 from .utils import (
     procutil,
+    stringutil,
 )
 
 def _hashlist(items):
     """return sha1 hexdigest for a list"""
-    return node.hex(hashlib.sha1(str(items)).digest())
+    return node.hex(hashlib.sha1(stringutil.pprint(items)).digest())
 
 # sensitive config sections affecting confighash
 _configsections = [
@@ -83,7 +84,7 @@
 ]
 
 # sensitive environment variables affecting confighash
-_envre = re.compile(r'''\A(?:
+_envre = re.compile(br'''\A(?:
                     CHGHG
                     |HG(?:DEMANDIMPORT|EMITWARNINGS|MODULEPOLICY|PROF|RCPATH)?
                     |HG(?:ENCODING|PLAIN).*
@@ -449,7 +450,7 @@
         if newhash.confighash != self.hashstate.confighash:
             addr = _hashaddress(self.baseaddress, newhash.confighash)
             insts.append('redirect %s' % addr)
-        self.ui.log('chgserver', 'validate: %s\n', insts)
+        self.ui.log('chgserver', 'validate: %s\n', stringutil.pprint(insts))
         self.cresult.write('\0'.join(insts) or '\0')
 
     def chdir(self):