Patchwork [3,of,3,py3] repair: reliably obtain bytestr of node ids

login
register
mail settings
Submitter Augie Fackler
Date Sept. 16, 2017, 3:09 p.m.
Message ID <466f6bf4dd4f8902eae3.1505574588@imladris.local>
Download mbox | patch
Permalink /patch/23948/
State Accepted
Headers show

Comments

Augie Fackler - Sept. 16, 2017, 3:09 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1503451354 14400
#      Tue Aug 22 21:22:34 2017 -0400
# Node ID 466f6bf4dd4f8902eae3279c8100de320cae7145
# Parent  5b03ae7d026bb4d14e3a8aaa391654987f8169c7
repair: reliably obtain bytestr of node ids
Yuya Nishihara - Sept. 17, 2017, 3:42 a.m.
On Sat, 16 Sep 2017 11:09:48 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <raf@durin42.com>
> # Date 1503451354 14400
> #      Tue Aug 22 21:22:34 2017 -0400
> # Node ID 466f6bf4dd4f8902eae3279c8100de320cae7145
> # Parent  5b03ae7d026bb4d14e3a8aaa391654987f8169c7
> repair: reliably obtain bytestr of node ids
> 
> diff --git a/mercurial/repair.py b/mercurial/repair.py
> --- a/mercurial/repair.py
> +++ b/mercurial/repair.py
> @@ -12,7 +12,10 @@ import errno
>  import hashlib
>  
>  from .i18n import _
> -from .node import short
> +from .node import (
> +    hex,
> +    short,
> +)
>  from . import (
>      bundle2,
>      changegroup,
> @@ -21,6 +24,7 @@ from . import (
>      exchange,
>      obsolete,
>      obsutil,
> +    pycompat,

Dropped unused import.

Patch

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -12,7 +12,10 @@  import errno
 import hashlib
 
 from .i18n import _
-from .node import short
+from .node import (
+    hex,
+    short,
+)
 from . import (
     bundle2,
     changegroup,
@@ -21,6 +24,7 @@  from . import (
     exchange,
     obsolete,
     obsutil,
+    pycompat,
     util,
 )
 
@@ -35,8 +39,9 @@  def _bundle(repo, bases, heads, node, su
     # 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)).hexdigest()
-    name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix)
+    totalhash = hashlib.sha1(''.join(allhashes)).digest()
+    name = "%s/%s-%s-%s.hg" % (backupdir, short(node),
+                               hex(totalhash[:4]), suffix)
 
     cgversion = changegroup.safeversion(repo)
     comp = None