Submitter | Augie Fackler |
---|---|
Date | March 21, 2017, 2:07 a.m. |
Message ID | <f42ec07db6a995d972fe.1490062024@augie-macbookair2.roam.corp.google.com> |
Download | mbox | patch |
Permalink | /patch/19495/ |
State | Accepted |
Headers | show |
Comments
On Mon, Mar 20, 2017 at 7:07 PM, Augie Fackler <raf@durin42.com> wrote: > # HG changeset patch > # User Augie Fackler <augie@google.com> > # Date 1490062017 14400 > # Mon Mar 20 22:06:57 2017 -0400 > # Node ID f42ec07db6a995d972fee8ce2a7fb122c5372109 > # Parent 23fc9b98445fac79d216570017227673b2492347 > localrepo: use node.hex instead of awkward .encode('latin1') Queued, thanks. Even more embarrassingly, I thought of using .digest(), but couldn't think of a way of converting it to hex bytes :-P > > Spotted as an option by Yuya. Thanks! Yep, thanks :-)
Patch
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1083,9 +1083,7 @@ class localrepository(object): hint=_("run 'hg recover' to clean up transaction")) idbase = "%.40f#%f" % (random.random(), time.time()) - ha = hashlib.sha1(idbase).hexdigest() - if pycompat.ispy3: - ha = ha.encode('latin1') + ha = hex(hashlib.sha1(idbase).digest()) txnid = 'TXN:' + ha self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid)