1
1
# Copyright (C) 2005, 2006 by Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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.
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
# fileids_altered_by_revision_ids requires reading the inventory
164
# weave, we will need to read the inventory weave again when
165
# all this is done, so enable caching for that specific weave
166
inv_w = self.from_repository.get_inventory_weave()
168
file_ids = self.from_repository.fileids_altered_by_revision_ids(revs)
162
170
num_file_ids = len(file_ids)
163
for file_id in file_ids:
171
for file_id, required_versions in file_ids.items():
164
172
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)
174
to_weave = self.to_weaves.get_weave_or_empty(file_id,
175
self.to_repository.get_transaction())
176
from_weave = self.from_weaves.get_weave(file_id,
177
self.from_repository.get_transaction())
178
# we fetch all the texts, because texts do
179
# not reference anything, and its cheap enough
180
to_weave.join(from_weave, version_ids=required_versions)
181
# we don't need *all* of this data anymore, but we dont know
182
# what we do. This cache clearing will result in a new read
183
# of the knit data when we do the checkout, but probably we
184
# want to emit the needed data on the fly rather than at the
186
# the from weave should know not to cache data being joined,
187
# but its ok to ask it to clear.
188
from_weave.clear_cache()
189
to_weave.clear_cache()
187
191
texts_pb.finished()
196
200
child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
198
# just merge, this is optimisable and its means we dont
202
# just merge, this is optimisable and its means we don't
199
203
# copy unreferenced data such as not-needed inventories.
200
204
pb.update("fetch inventory", 1, 3)
201
205
from_weave = self.from_repository.get_inventory_weave()