58
62
self.repo_dir = BzrDir.open_from_transport(self.transport)
59
63
self.repo = self.repo_dir.find_repository()
60
64
self.object_store = get_object_store(self.repo)
61
self.refs = BazaarRefsContainer(self.repo_dir, self.object_store)
62
self._refs = self.refs.as_dict() # Much faster for now..
67
66
def get_peeled(self, name):
68
67
return self.get_refs()[name]
70
"""Return a dict of all tags and branches in repository (and shas) """
74
for branch in self.repo_dir.list_branches():
75
ref = branch_name_to_ref(branch.name, "refs/heads/master")
76
ret[ref] = self.object_store._lookup_revision_sha1(
77
branch.last_revision())
78
assert type(ref) == str and type(ret[ref]) == str, \
79
"(%s) %r -> %r" % (branch.name, ref, ret[ref])
84
def set_refs(self, refs):
85
for oldsha, sha, ref in refs:
87
branch_name = ref_to_branch_name(ref)
89
# FIXME: Cope with tags!
92
target_branch = self.repo_dir.open_branch(branch_name)
93
except NotBranchError:
94
target_branch = self.repo.create_branch(branch_name)
96
rev_id = self.mapping.revision_id_foreign_to_bzr(sha)
97
target_branch.lock_write()
99
target_branch.generate_revision_history(rev_id)
101
target_branch.unlock()
70
103
def fetch_objects(self, determine_wants, graph_walker, progress,
72
105
""" yield git objects to send to client """
107
# If this is a Git repository, just use the existing fetch_objects implementation.
108
if getattr(self.repo, "fetch_objects", None) is not None:
109
return self.repo.fetch_objects(determine_wants, graph_walker, progress,
74
112
wants = determine_wants(self.get_refs())
75
113
self.repo.lock_read()