largefiles: introduce readasstandin() to read hex hash from given filectx
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sat, 01 Apr 2017 02:32:31 +0900
changeset 31734 44ff5e4ffc8c
parent 31733 ae6bab095c66
child 31735 3e37b479ce2f
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.
hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py	Thu Mar 30 03:50:10 2017 -0700
+++ b/hgext/largefiles/lfutil.py	Sat Apr 01 02:32:31 2017 +0900
@@ -355,10 +355,16 @@
     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>'''