##// END OF EJS Templates
largefiles: added handling of detection and fetching of largefiles....
marcink -
r182:5af7fc0d default
parent child Browse files
Show More
@@ -38,7 +38,7 b' from vcsserver.utils import safe_str'
38 from vcsserver.base import RepoFactory, obfuscate_qs, raise_from_original
38 from vcsserver.base import RepoFactory, obfuscate_qs, raise_from_original
39 from vcsserver.hgcompat import (
39 from vcsserver.hgcompat import (
40 hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler)
40 hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler)
41
41 from vcsserver.git_lfs.lib import LFSOidStore
42
42
43 DIR_STAT = stat.S_IFDIR
43 DIR_STAT = stat.S_IFDIR
44 FILE_MODE = stat.S_IFMT
44 FILE_MODE = stat.S_IFMT
@@ -105,6 +105,11 b' class GitRemote(object):'
105 "_commit": self.revision,
105 "_commit": self.revision,
106 }
106 }
107
107
108 def _wire_to_config(self, wire):
109 if 'config' in wire:
110 return dict([(x[0] + '_' + x[1], x[2]) for x in wire['config']])
111 return {}
112
108 def _assign_ref(self, wire, ref, commit_id):
113 def _assign_ref(self, wire, ref, commit_id):
109 repo = self._factory.repo(wire)
114 repo = self._factory.repo(wire)
110 repo[ref] = commit_id
115 repo[ref] = commit_id
@@ -141,6 +146,56 b' class GitRemote(object):'
141 blob = repo[sha]
146 blob = repo[sha]
142 return blob.raw_length()
147 return blob.raw_length()
143
148
149 def _parse_lfs_pointer(self, raw_content):
150
151 spec_string = 'version https://git-lfs.github.com/spec'
152 if raw_content and raw_content.startswith(spec_string):
153 pattern = re.compile(r"""
154 (?:\n)?
155 ^version[ ]https://git-lfs\.github\.com/spec/(?P<spec_ver>v\d+)\n
156 ^oid[ ] sha256:(?P<oid_hash>[0-9a-f]{64})\n
157 ^size[ ](?P<oid_size>[0-9]+)\n
158 (?:\n)?
159 """, re.VERBOSE | re.MULTILINE)
160 match = pattern.match(raw_content)
161 if match:
162 return match.groupdict()
163
164 return {}
165
166 @reraise_safe_exceptions
167 def is_large_file(self, wire, sha):
168 repo = self._factory.repo(wire)
169 blob = repo[sha]
170 return self._parse_lfs_pointer(blob.as_raw_string())
171
172 @reraise_safe_exceptions
173 def in_largefiles_store(self, wire, oid):
174 repo = self._factory.repo(wire)
175 conf = self._wire_to_config(wire)
176
177 store_location = conf.get('vcs_git_lfs_store_location')
178 if store_location:
179 repo_name = repo.path
180 store = LFSOidStore(
181 oid=oid, repo=repo_name, store_location=store_location)
182 return store.has_oid()
183
184 return False
185
186 @reraise_safe_exceptions
187 def store_path(self, wire, oid):
188 repo = self._factory.repo(wire)
189 conf = self._wire_to_config(wire)
190
191 store_location = conf.get('vcs_git_lfs_store_location')
192 if store_location:
193 repo_name = repo.path
194 store = LFSOidStore(
195 oid=oid, repo=repo_name, store_location=store_location)
196 return store.oid_path
197 raise ValueError('Unable to fetch oid with path {}'.format(oid))
198
144 @reraise_safe_exceptions
199 @reraise_safe_exceptions
145 def bulk_request(self, wire, rev, pre_load):
200 def bulk_request(self, wire, rev, pre_load):
146 result = {}
201 result = {}
@@ -485,7 +485,7 b' class HgRemote(object):'
485 return largefiles.lfutil.isstandin(path)
485 return largefiles.lfutil.isstandin(path)
486
486
487 @reraise_safe_exceptions
487 @reraise_safe_exceptions
488 def in_store(self, wire, sha):
488 def in_largefiles_store(self, wire, sha):
489 repo = self._factory.repo(wire)
489 repo = self._factory.repo(wire)
490 return largefiles.lfutil.instore(repo, sha)
490 return largefiles.lfutil.instore(repo, sha)
491
491
@@ -377,6 +377,10 b' class SvnRemote(object):'
377 "Path might not exist %s, %s" % (path1, path2))
377 "Path might not exist %s, %s" % (path1, path2))
378 return ""
378 return ""
379
379
380 @reraise_safe_exceptions
381 def is_large_file(self, wire, path):
382 return False
383
380
384
381 class SvnDiffer(object):
385 class SvnDiffer(object):
382 """
386 """
General Comments 0
You need to be logged in to leave comments. Login now