2 from functools import partial
4 from bup import client, git
8 def __init__(self, repo_dir=None):
9 self.repo_dir = repo_dir or git.repo()
10 self._cp = git.cp(repo_dir)
11 self.rev_list = partial(git.rev_list, repo_dir=repo_dir)
14 """If ref does not exist, yield (None, None, None). Otherwise yield
15 (oidx, type, size), and then all of the data associated with
19 it = self._cp.get(ref)
20 oidx, typ, size = info = next(it)
25 assert not next(it, None)
28 return self._cp.join(ref)
30 def refs(self, patterns=None, limit_to_heads=False, limit_to_tags=False):
31 for ref in git.list_refs(patterns=patterns,
32 limit_to_heads=limit_to_heads,
33 limit_to_tags=limit_to_tags,
34 repo_dir=self.repo_dir):
38 def __init__(self, address):
39 self.address = address
40 self.client = client.Client(address)
41 self.rev_list = self.client.rev_list
44 """If ref does not exist, yield (None, None, None). Otherwise yield
45 (oidx, type, size), and then all of the data associated with
49 # Yield all the data here so that we don't finish the
50 # cat_batch iterator (triggering its cleanup) until all of the
51 # data has been read. Otherwise we'd be out of sync with the
53 items = self.client.cat_batch((ref,))
54 oidx, typ, size, it = info = next(items)
59 assert not next(items, None)
62 return self.client.join(ref)
64 def refs(self, patterns=None, limit_to_heads=False, limit_to_tags=False):
65 for ref in self.client.refs(patterns=patterns,
66 limit_to_heads=limit_to_heads,
67 limit_to_tags=limit_to_tags):