changeset 31515:590319c07259

localrepo: ensure transaction id is fully bytes on py3
author Augie Fackler <augie@google.com>
date Sun, 19 Mar 2017 01:08:59 -0400
parents 4d1dd9cf0dca
children 5c9936193145
files mercurial/localrepo.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sun Mar 19 01:08:17 2017 -0400
+++ b/mercurial/localrepo.py	Sun Mar 19 01:08:59 2017 -0400
@@ -49,6 +49,7 @@
     peer,
     phases,
     pushkey,
+    pycompat,
     repoview,
     revset,
     revsetlang,
@@ -1082,7 +1083,10 @@
                 hint=_("run 'hg recover' to clean up transaction"))
 
         idbase = "%.40f#%f" % (random.random(), time.time())
-        txnid = 'TXN:' + hashlib.sha1(idbase).hexdigest()
+        ha = hashlib.sha1(idbase).hexdigest()
+        if pycompat.ispy3:
+            ha = ha.encode('latin1')
+        txnid = 'TXN:' + ha
         self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid)
 
         self._writejournal(desc)