py3: repair: fix encoding for SHA1 calculation

Reviewed By: farnz

Differential Revision: D19613687

fbshipit-source-id: e8dbbcc8c1151dd2defe63b1c67df0a3dc598c90
This commit is contained in:
Jun Wu 2020-01-29 07:38:41 -08:00 committed by Facebook Github Bot
parent 21b2a06c6f
commit 0e6add4877

View File

@ -31,7 +31,7 @@ from . import (
)
from .i18n import _
from .node import hex, short
from .pycompat import range
from .pycompat import encodeutf8, range
def _bundle(repo, bases, heads, node, suffix, compress=True, obsolescence=True):
@ -45,7 +45,7 @@ def _bundle(repo, bases, heads, node, suffix, compress=True, obsolescence=True):
# Include a hash of all the nodes in the filename for uniqueness
allcommits = repo.set("%ln::%ln", bases, heads)
allhashes = sorted(c.hex() for c in allcommits)
totalhash = hashlib.sha1("".join(allhashes)).digest()
totalhash = hashlib.sha1(encodeutf8("".join(allhashes))).digest()
name = "%s/%s-%s-%s.hg" % (backupdir, short(node), hex(totalhash[:4]), suffix)
cgversion = changegroup.localversion(repo)