##// END OF EJS Templates
libgit2: changed is_empty and introduced new way for checking tree_id for path in git
marcink -
r726:f20a6430 default
parent child
Show More
@@ -160,13 +160,10 class GitRemote(object):
160 def is_empty(self, wire):
160 def is_empty(self, wire):
161 repo = self._factory.repo_libgit2(wire)
161 repo = self._factory.repo_libgit2(wire)
162
162
163 # NOTE(marcink): old solution as an alternative
163 try:
164 # try:
164 return not repo.head.name
165 # return not repo.head.name
165 except Exception:
166 # except Exception:
166 return True
167 # return True
168
169 return repo.is_empty
170
167
171 @reraise_safe_exceptions
168 @reraise_safe_exceptions
172 def add_object(self, wire, content):
169 def add_object(self, wire, content):
@@ -227,13 +224,18 class GitRemote(object):
227
224
228 @reraise_safe_exceptions
225 @reraise_safe_exceptions
229 def is_large_file(self, wire, sha):
226 def is_large_file(self, wire, sha):
230 repo = self._factory.repo(wire)
227 repo_init = self._factory.repo_libgit2(wire)
231 blob = repo[sha]
228
232 return self._parse_lfs_pointer(blob.as_raw_string())
229 with repo_init as repo:
230 blob = repo[sha]
231 if blob.is_binary:
232 return {}
233
234 return self._parse_lfs_pointer(blob.data)
233
235
234 @reraise_safe_exceptions
236 @reraise_safe_exceptions
235 def in_largefiles_store(self, wire, oid):
237 def in_largefiles_store(self, wire, oid):
236 repo = self._factory.repo(wire)
238 repo = self._factory.repo_libgit2(wire)
237 conf = self._wire_to_config(wire)
239 conf = self._wire_to_config(wire)
238
240
239 store_location = conf.get('vcs_git_lfs_store_location')
241 store_location = conf.get('vcs_git_lfs_store_location')
@@ -247,7 +249,7 class GitRemote(object):
247
249
248 @reraise_safe_exceptions
250 @reraise_safe_exceptions
249 def store_path(self, wire, oid):
251 def store_path(self, wire, oid):
250 repo = self._factory.repo(wire)
252 repo = self._factory.repo_libgit2(wire)
251 conf = self._wire_to_config(wire)
253 conf = self._wire_to_config(wire)
252
254
253 store_location = conf.get('vcs_git_lfs_store_location')
255 store_location = conf.get('vcs_git_lfs_store_location')
@@ -725,11 +727,27 class GitRemote(object):
725 return list(result)
727 return list(result)
726
728
727 @reraise_safe_exceptions
729 @reraise_safe_exceptions
730 def tree_and_type_for_path(self, wire, commit_id, path):
731 repo_init = self._factory.repo_libgit2(wire)
732
733 with repo_init as repo:
734 commit = repo[commit_id]
735 try:
736 tree = commit.tree[path]
737 except KeyError:
738 return None, None, None
739
740 return tree.id.hex, tree.type, tree.filemode
741
742 @reraise_safe_exceptions
728 def tree_items(self, wire, tree_id):
743 def tree_items(self, wire, tree_id):
729 repo_init = self._factory.repo_libgit2(wire)
744 repo_init = self._factory.repo_libgit2(wire)
730
745
731 with repo_init as repo:
746 with repo_init as repo:
732 tree = repo[tree_id]
747 try:
748 tree = repo[tree_id]
749 except KeyError:
750 raise ObjectMissing('No tree with id: {}'.format(tree_id))
733
751
734 result = []
752 result = []
735 for item in tree:
753 for item in tree:
General Comments 0
You need to be logged in to leave comments. Login now