149
147
def _write_revisions(self, pb):
150
148
"""Write the information for all of the revisions."""
152
i_max = len(self.revision_ids)
153
# Taken from Repository.get_deltas_for_revisions, and modified for our
154
# case of manually specified base trees, and prefering deltas against
155
# last parent, rather than first parent
156
required_trees = set(self.forced_bases.values())
157
for rev in self.revisions:
158
required_trees.add(rev.revision_id)
159
required_trees.update(rev.parent_ids[-1:])
150
# Optimize for the case of revisions in order
161
# TODO: jam 20060815 handle ghosts
162
# TODO: jam 20060815 This can potentially grow without bound
163
# It keeps a full RevisionTree for every entry being bundled
164
# We really should have a convenience function for only extracting
165
# a portion, while still allowing the optimization of reading
167
trees = dict((t.get_revision_id(), t) for
168
t in self.source.revision_trees(required_trees))
169
trees[NULL_REVISION] = self.source.revision_tree(NULL_REVISION)
170
for i, rev in enumerate(self.revisions):
154
i_max = len(self.revision_ids)
155
for i, rev_id in enumerate(self.revision_ids):
171
156
pb.update("Generating revsion data", i, i_max)
172
if rev.revision_id in self.forced_bases:
157
rev = self.source.get_revision(rev_id)
158
if rev_id == last_rev_id:
159
rev_tree = last_rev_tree
161
rev_tree = self.source.revision_tree(rev_id)
162
if rev_id in self.forced_bases:
173
163
explicit_base = True
174
base_id = self.forced_bases[rev.revision_id]
164
base_id = self.forced_bases[rev_id]
175
165
if base_id is None:
176
166
base_id = NULL_REVISION
180
170
base_id = rev.parent_ids[-1]
182
172
base_id = NULL_REVISION
183
base_tree = trees[base_id]
184
rev_tree = trees[rev.revision_id]
174
if base_id == last_rev_id:
175
base_tree = last_rev_tree
177
base_tree = self.source.revision_tree(base_id)
185
178
force_binary = (i != 0)
186
self._write_revision(rev, rev_tree, base_id, base_tree,
179
self._write_revision(rev, rev_tree, base_id, base_tree,
187
180
explicit_base, force_binary)
189
def _write_revision(self, rev, rev_tree, base_rev, base_tree,
182
last_rev_id = base_id
183
last_rev_tree = base_tree
185
def _write_revision(self, rev, rev_tree, base_rev, base_tree,
190
186
explicit_base, force_binary):
191
187
"""Write out the information for a revision."""
192
188
def w(key, value):