134
134
revs = self._revids_to_fetch()
138
self._fetch_weave_texts(revs)
135
self._fetch_everything_for_revisions(revs, pp)
139
def _fetch_everything_for_revisions(self, revs, pp):
140
"""Fetch all data for the given set of revisions."""
143
what_to_do = self.from_repository.get_data_about_revision_ids(revs)
144
for knit_kind, file_id, revisions in what_to_do:
145
if knit_kind == "file":
146
self._fetch_weave_text(file_id, revisions)
147
elif knit_kind == "inventory":
149
# Once we've processed all the files, then we generate the root
150
# texts (if necessary), then we process the inventory. It's a
151
# bit distasteful to have knit_kind == "inventory" mean this,
152
# perhaps it should happen on the first non-"file" knit, in case
153
# it's not always inventory?
154
self._generate_root_texts(revs)
140
155
self._fetch_inventory_weave(revs)
156
elif knit_kind == "revisions":
142
157
self._fetch_revision_texts(revs)
143
self.count_copied += len(revs)
159
raise AssertionError("Unknown knit kind %r" % knit_kind)
160
self.count_copied += len(revs)
147
162
def _revids_to_fetch(self):
148
163
mutter('fetch up to rev {%s}', self._last_revision)
149
164
if self._last_revision is NULL_REVISION:
173
188
for file_id, required_versions in file_ids.items():
174
189
texts_pb.update("fetch texts", count, num_file_ids)
176
to_weave = self.to_weaves.get_weave_or_empty(file_id,
177
self.to_repository.get_transaction())
178
from_weave = self.from_weaves.get_weave(file_id,
179
self.from_repository.get_transaction())
180
# we fetch all the texts, because texts do
181
# not reference anything, and its cheap enough
182
to_weave.join(from_weave, version_ids=required_versions)
183
# we don't need *all* of this data anymore, but we dont know
184
# what we do. This cache clearing will result in a new read
185
# of the knit data when we do the checkout, but probably we
186
# want to emit the needed data on the fly rather than at the
188
# the from weave should know not to cache data being joined,
189
# but its ok to ask it to clear.
190
from_weave.clear_cache()
191
to_weave.clear_cache()
191
self._fetch_weave_text(file_id, required_versions)
193
193
texts_pb.finished()
195
def _fetch_weave_text(self, file_id, required_versions):
196
to_weave = self.to_weaves.get_weave_or_empty(file_id,
197
self.to_repository.get_transaction())
198
from_weave = self.from_weaves.get_weave(file_id,
199
self.from_repository.get_transaction())
200
# we fetch all the texts, because texts do
201
# not reference anything, and its cheap enough
202
to_weave.join(from_weave, version_ids=required_versions)
203
# we don't need *all* of this data anymore, but we dont know
204
# what we do. This cache clearing will result in a new read
205
# of the knit data when we do the checkout, but probably we
206
# want to emit the needed data on the fly rather than at the
208
# the from weave should know not to cache data being joined,
209
# but its ok to ask it to clear.
210
from_weave.clear_cache()
211
to_weave.clear_cache()
195
213
def _fetch_inventory_weave(self, revs):
196
214
pb = bzrlib.ui.ui_factory.nested_progress_bar()
239
def _generate_root_texts(self, revs):
240
"""This will be called by __fetch between fetching weave texts and
241
fetching the inventory weave.
243
Subclasses should override this if they need to generate root texts
244
after fetching weave texts.
222
249
class GenericRepoFetcher(RepoFetcher):
223
250
"""This is a generic repo to repo fetcher.
360
387
def _fetch_weave_texts(self, revs):
361
388
GenericRepoFetcher._fetch_weave_texts(self, revs)
389
self._generate_root_texts(revs)
391
def _generate_root_texts(self, revs):
362
392
# Now generate a weave for the tree root
363
393
self.helper.generate_root_texts(revs)
378
408
def _fetch_weave_texts(self, revs):
379
409
KnitRepoFetcher._fetch_weave_texts(self, revs)
410
self._generate_root_texts(revs)
412
def _generate_root_texts(self, revs):
380
413
# Now generate a weave for the tree root
381
414
self.helper.generate_root_texts(revs)