2 from __future__ import absolute_import
3 from functools import partial
5 from bup import client, git
9 def __init__(self, repo_dir=None):
10 self.repo_dir = repo_dir or git.repo()
11 self._cp = git.cp(repo_dir)
12 self.rev_list = partial(git.rev_list, repo_dir=repo_dir)
15 """If ref does not exist, yield (None, None, None). Otherwise yield
16 (oidx, type, size), and then all of the data associated with
20 it = self._cp.get(ref)
21 oidx, typ, size = info = next(it)
26 assert not next(it, None)
29 return self._cp.join(ref)
31 def refs(self, patterns=None, limit_to_heads=False, limit_to_tags=False):
32 for ref in git.list_refs(patterns=patterns,
33 limit_to_heads=limit_to_heads,
34 limit_to_tags=limit_to_tags,
35 repo_dir=self.repo_dir):
39 def __init__(self, address):
40 self.address = address
41 self.client = client.Client(address)
42 self.rev_list = self.client.rev_list
45 """If ref does not exist, yield (None, None, None). Otherwise yield
46 (oidx, type, size), and then all of the data associated with
50 # Yield all the data here so that we don't finish the
51 # cat_batch iterator (triggering its cleanup) until all of the
52 # data has been read. Otherwise we'd be out of sync with the
54 items = self.client.cat_batch((ref,))
55 oidx, typ, size, it = info = next(items)
60 assert not next(items, None)
63 return self.client.join(ref)
65 def refs(self, patterns=None, limit_to_heads=False, limit_to_tags=False):
66 for ref in self.client.refs(patterns=patterns,
67 limit_to_heads=limit_to_heads,
68 limit_to_tags=limit_to_tags):