Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master, master-1, and master-0

Add function for finding the object in a tree.

Changeset fda18290491d

Parent 5b199401b304

by Jelmer Vernooij

Changes to one file · Browse files at fda18290491d Showing diff from parent 5b199401b304 Diff from another changeset...

 
20
21
22
 
 
 
23
24
 
25
26
27
 
273
274
275
 
 
 
 
 
 
 
 
 
 
 
 
20
21
22
23
24
25
26
27
28
29
30
31
 
277
278
279
280
281
282
283
284
285
286
287
288
289
290
@@ -20,8 +20,12 @@
 import tempfile  import urllib2   +from dulwich.errors import ( + NotTreeError, + )  from dulwich.objects import (   ShaFile, + Tree,   hex_to_sha,   sha_to_hex,   ) @@ -273,3 +277,14 @@
  def __len__(self):   """Return the number of objects."""   return len(list(self.itershas())) + + +def tree_lookup_path(object_store, root_sha, path): + parts = path.split("/") + sha = root_sha + for p in parts: + obj = object_store[sha] + if type(obj) is not Tree: + raise NotTreeError(sha) + mode, sha = obj[p] + return object_store[sha]