[PATCH 7 of 7] repair: use bytestr() to turn hashes into bytes

Yuya Nishihara yuya at tcha.org
Thu Aug 31 09:59:16 EDT 2017


On Tue, 29 Aug 2017 11:22:04 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <raf at durin42.com>
> # Date 1503451354 14400
> #      Tue Aug 22 21:22:34 2017 -0400
> # Node ID 67e8c38e7efb154b63c23426d402e0ffdf0831aa
> # Parent  ae30c980ec329715171d142644a6bda68114df57
> repair: use bytestr() to turn hashes into bytes
> 
> diff --git a/mercurial/repair.py b/mercurial/repair.py
> --- a/mercurial/repair.py
> +++ b/mercurial/repair.py
> @@ -21,6 +21,7 @@ from . import (
>      exchange,
>      obsolete,
>      obsutil,
> +    pycompat,
>      util,
>  )
>  
> @@ -36,7 +37,8 @@ def _bundle(repo, bases, heads, node, su
>      allcommits = repo.set('%ln::%ln', bases, heads)
>      allhashes = sorted(c.hex() for c in allcommits)
>      totalhash = hashlib.sha1(''.join(allhashes)).hexdigest()
> -    name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix)
> +    name = "%s/%s-%s-%s.hg" % (backupdir, pycompat.bytestr(short(node)),
> +                               pycompat.bytestr(totalhash[:8]), suffix)

I slightly prefer .digest() and hex(totalhash[:4]).


More information about the Mercurial-devel mailing list