mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
lfs: move hg filelog metadata calculation to a separate method
Summary: The method will be reused by remotefilelog. Reviewed By: DurhamG Differential Revision: D6906205 fbshipit-source-id: 5e36a5c7f40c7e226e6dd18e102e433632b1005d
This commit is contained in:
parent
c223bb4eaf
commit
c323bb68e8
@ -43,6 +43,15 @@ class gitlfspointer(dict):
|
||||
def size(self):
|
||||
return int(self['size'])
|
||||
|
||||
def hgmeta(self):
|
||||
"""Translate LFS metadata to hg filelog metadata dictionary"""
|
||||
hgmeta = {}
|
||||
for k, v in self.iteritems():
|
||||
if k.startswith('x-hg-'):
|
||||
name = k[len('x-hg-'):]
|
||||
hgmeta[name] = v
|
||||
return hgmeta
|
||||
|
||||
# regular expressions used by _validate
|
||||
# see https://github.com/git-lfs/git-lfs/blob/master/docs/spec.md
|
||||
_keyre = re.compile(r'\A[a-z0-9.-]+\Z')
|
||||
|
@ -55,11 +55,7 @@ def readfromstore(self, text):
|
||||
text = store.read(oid)
|
||||
|
||||
# pack hg filelog metadata
|
||||
hgmeta = {}
|
||||
for k in p.keys():
|
||||
if k.startswith('x-hg-'):
|
||||
name = k[len('x-hg-'):]
|
||||
hgmeta[name] = p[k]
|
||||
hgmeta = p.hgmeta()
|
||||
if hgmeta or text.startswith('\1\n'):
|
||||
text = filelog.packmeta(hgmeta, text)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user