[PATCH 1 of 7] largefiles: introduce readasstandin() to read hex hash from given filectx

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Mar 31 13:41:46 EDT 2017


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1490981551 -32400
#      Sat Apr 01 02:32:31 2017 +0900
# Node ID 340c76876899a57ded1f59fee4e2035f078895d7
# Parent  6be6e4becaafd1bf24f01a2d0464df9cea67588d
largefiles: introduce readasstandin() to  read hex hash from given filectx

This will be used to centralize and encapsulate the logic to read hash
from given (filectx of) standin file. readstandin() isn't suitable for
this purpose, because there are some code paths, which want to read
hex hash directly from filectx.

diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -355,10 +355,16 @@ def updatestandin(repo, lfile, standin):
     else:
         raise error.Abort(_('%s: file not found!') % lfile)
 
+def readasstandin(fctx):
+    '''read hex hash from given filectx of standin file
+
+    This encapsulates how "standin" data is stored into storage layer.'''
+    return fctx.data().strip()
+
 def readstandin(repo, filename, node=None):
     '''read hex hash from standin for filename at given node, or working
     directory if no node is given'''
-    return repo[node][standin(filename)].data().strip()
+    return readasstandin(repo[node][standin(filename)])
 
 def writestandin(repo, standin, hash, executable):
     '''write hash to <repo.root>/<standin>'''


More information about the Mercurial-devel mailing list