comparison hgext/largefiles/lfutil.py @ 31734:44ff5e4ffc8c

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.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 01 Apr 2017 02:32:31 +0900
parents 0eec36112e58
children 3e37b479ce2f
comparison
equal deleted inserted replaced
31733:ae6bab095c66 31734:44ff5e4ffc8c
353 executable = getexecutable(file) 353 executable = getexecutable(file)
354 writestandin(repo, standin, hash, executable) 354 writestandin(repo, standin, hash, executable)
355 else: 355 else:
356 raise error.Abort(_('%s: file not found!') % lfile) 356 raise error.Abort(_('%s: file not found!') % lfile)
357 357
358 def readasstandin(fctx):
359 '''read hex hash from given filectx of standin file
360
361 This encapsulates how "standin" data is stored into storage layer.'''
362 return fctx.data().strip()
363
358 def readstandin(repo, filename, node=None): 364 def readstandin(repo, filename, node=None):
359 '''read hex hash from standin for filename at given node, or working 365 '''read hex hash from standin for filename at given node, or working
360 directory if no node is given''' 366 directory if no node is given'''
361 return repo[node][standin(filename)].data().strip() 367 return readasstandin(repo[node][standin(filename)])
362 368
363 def writestandin(repo, standin, hash, executable): 369 def writestandin(repo, standin, hash, executable):
364 '''write hash to <repo.root>/<standin>''' 370 '''write hash to <repo.root>/<standin>'''
365 repo.wwrite(standin, hash + '\n', executable and 'x' or '') 371 repo.wwrite(standin, hash + '\n', executable and 'x' or '')
366 372