Patchwork [02,of,13] largefiles: refactoring - return hex from _getfile and copyandhash

login
register
mail settings
Submitter Mads Kiilerich
Date April 16, 2013, 2:43 a.m.
Message ID <d36db32a4352b2d97d9b.1366080199@mk-desktop>
Download mbox | patch
Permalink /patch/1332/
State Accepted
Commit c1b5f9c4d989e9727217c704ed9c1fed39e04399
Headers show

Comments

Mads Kiilerich - April 16, 2013, 2:43 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1366061718 -7200
#      Mon Apr 15 23:35:18 2013 +0200
# Node ID d36db32a4352b2d97d9b2bd0089789f83a623e84
# Parent  ee8921bf4a35fe2fd8a2dcc04a0048db344ca58f
largefiles: refactoring - return hex from _getfile and copyandhash

Patch

diff --git a/hgext/largefiles/basestore.py b/hgext/largefiles/basestore.py
--- a/hgext/largefiles/basestore.py
+++ b/hgext/largefiles/basestore.py
@@ -8,7 +8,6 @@ 
 
 '''base class for store implementations and store-related utility code'''
 
-import binascii
 import re
 
 from mercurial import util, node, hg
@@ -74,7 +73,7 @@ 
                                           createmode=self.repo.store.createmode)
 
             try:
-                hhash = binascii.hexlify(self._getfile(tmpfile, filename, hash))
+                hhash = self._getfile(tmpfile, filename, hash)
             except StoreError, err:
                 ui.warn(err.longmessage())
                 hhash = ""
@@ -128,7 +127,7 @@ 
     def _getfile(self, tmpfile, filename, hash):
         '''Fetch one revision of one file from the store and write it
         to tmpfile.  Compute the hash of the file on-the-fly as it
-        downloads and return the binary hash.  Close tmpfile.  Raise
+        downloads and return the hash.  Close tmpfile.  Raise
         StoreError if unable to download the file (e.g. it does not
         exist in the store).'''
         raise NotImplementedError('abstract method')
diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -290,7 +290,7 @@ 
 def copyandhash(instream, outfile):
     '''Read bytes from instream (iterable) and write them to outfile,
     computing the SHA-1 hash of the data along the way.  Close outfile
-    when done and return the binary hash.'''
+    when done and return the hash.'''
     hasher = util.sha1('')
     for data in instream:
         hasher.update(data)
@@ -301,7 +301,7 @@ 
     # outfile was opened just to copy and hash.
     outfile.close()
 
-    return hasher.digest()
+    return hasher.hexdigest()
 
 def hashrepofile(repo, file):
     return hashfile(repo.wjoin(file))