35
35
import bzrlib.errors as errors
36
from bzrlib.errors import (InstallFailed, NoSuchRevision,
36
from bzrlib.errors import (InstallFailed,
38
38
from bzrlib.trace import mutter
39
from bzrlib.progress import ProgressBar, ProgressPhase
40
from bzrlib.reconcile import RepoReconciler
39
from bzrlib.progress import ProgressPhase
41
40
from bzrlib.revision import NULL_REVISION
42
from bzrlib.symbol_versioning import *
41
from bzrlib.symbol_versioning import (deprecated_function,
45
47
# TODO: Avoid repeatedly opening weaves so many times.
124
126
self.from_control = self.from_repository.control_weaves
125
127
self.count_total = 0
126
128
self.file_ids_names = {}
127
pp = ProgressPhase('fetch phase', 4, self.pb)
129
pp = ProgressPhase('Fetch phase', 4, self.pb)
129
132
revs = self._revids_to_fetch()
130
133
# something to do ?
157
160
def _fetch_weave_texts(self, revs):
158
161
texts_pb = bzrlib.ui.ui_factory.nested_progress_bar()
160
file_ids = self.from_repository.fileid_involved_by_set(revs)
163
file_ids = self.from_repository.fileids_altered_by_revision_ids(revs)
162
165
num_file_ids = len(file_ids)
163
for file_id in file_ids:
166
for file_id, required_versions in file_ids.items():
164
167
texts_pb.update("fetch texts", count, num_file_ids)
167
to_weave = self.to_weaves.get_weave(file_id,
168
self.to_repository.get_transaction())
169
except errors.NoSuchFile:
170
# destination is empty, just copy it.
171
# this copies all the texts, which is useful and
172
# on per-file basis quite cheap.
173
self.to_weaves.copy_multi(
177
self.from_repository.get_transaction(),
178
self.to_repository.get_transaction())
180
# destination has contents, must merge
181
from_weave = self.from_weaves.get_weave(file_id,
182
self.from_repository.get_transaction())
183
# we fetch all the texts, because texts do
184
# not reference anything, and its cheap enough
185
to_weave.join(from_weave)
169
to_weave = self.to_weaves.get_weave_or_empty(file_id,
170
self.to_repository.get_transaction())
171
from_weave = self.from_weaves.get_weave(file_id,
172
self.from_repository.get_transaction())
173
# we fetch all the texts, because texts do
174
# not reference anything, and its cheap enough
175
to_weave.join(from_weave, version_ids=required_versions)
176
# we don't need *all* of this data anymore, but we dont know
177
# what we do. This cache clearing will result in a new read
178
# of the knit data when we do the checkout, but probably we
179
# want to emit the needed data on the fly rather than at the
181
# the from weave should know not to cache data being joined,
182
# but its ok to ask it to clear.
183
from_weave.clear_cache()
184
to_weave.clear_cache()
187
186
texts_pb.finished()
196
195
child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
198
# just merge, this is optimisable and its means we dont
197
# just merge, this is optimisable and its means we don't
199
198
# copy unreferenced data such as not-needed inventories.
200
199
pb.update("fetch inventory", 1, 3)
201
200
from_weave = self.from_repository.get_inventory_weave()
279
278
class Fetcher(object):
280
"""Backwards compatability glue for branch.fetch()."""
279
"""Backwards compatibility glue for branch.fetch()."""
282
281
@deprecated_method(zero_eight)
283
282
def __init__(self, to_branch, from_branch, last_revision=None, pb=None):