33
from bzrlib.errors import InstallFailed
34
from bzrlib.progress import ProgressPhase
35
33
from bzrlib.revision import NULL_REVISION
36
34
from bzrlib.tsort import topo_sort
37
35
from bzrlib.trace import mutter
53
51
:param last_revision: If set, try to limit to the data this revision
55
53
:param find_ghosts: If True search the entire history for ghosts.
56
:param _write_group_acquired_callable: Don't use; this parameter only
57
exists to facilitate a hack done in InterPackRepo.fetch. We would
58
like to remove this parameter.
59
54
:param pb: ProgressBar object to use; deprecated and ignored.
60
55
This method will just create one on top of the stack.
64
59
symbol_versioning.deprecated_in((1, 14, 0))
65
60
% "pb parameter to RepoFetcher.__init__")
66
61
# and for simplicity it is in fact ignored
67
if to_repository.has_same_location(from_repository):
68
# repository.fetch should be taking care of this case.
69
raise errors.BzrError('RepoFetcher run '
70
'between two objects at the same location: '
71
'%r and %r' % (to_repository, from_repository))
62
# repository.fetch has the responsibility for short-circuiting
63
# attempts to copy between a repository and itself.
72
64
self.to_repository = to_repository
73
65
self.from_repository = from_repository
74
66
self.sink = to_repository._get_sink()
136
128
pb.update("Inserting stream")
137
129
resume_tokens, missing_keys = self.sink.insert_stream(
138
130
stream, from_format, [])
131
if self.to_repository._fallback_repositories:
133
self._parent_inventories(search.get_keys()))
140
135
pb.update("Missing keys")
141
136
stream = source.get_stream_for_missing_keys(missing_keys)
167
162
if self._last_revision is NULL_REVISION:
168
163
# explicit limit of no revisions needed
170
if (self._last_revision is not None and
171
self.to_repository.has_revision(self._last_revision)):
174
return self.to_repository.search_missing_revision_ids(
175
self.from_repository, self._last_revision,
176
find_ghosts=self.find_ghosts)
177
except errors.NoSuchRevision, e:
178
raise InstallFailed([self._last_revision])
165
return self.to_repository.search_missing_revision_ids(
166
self.from_repository, self._last_revision,
167
find_ghosts=self.find_ghosts)
169
def _parent_inventories(self, revision_ids):
170
# Find all the parent revisions referenced by the stream, but
171
# not present in the stream, and make sure we send their
173
parent_maps = self.to_repository.get_parent_map(revision_ids)
175
map(parents.update, parent_maps.itervalues())
176
parents.discard(NULL_REVISION)
177
parents.difference_update(revision_ids)
178
missing_keys = set(('inventories', rev_id) for rev_id in parents)
181
182
class Inter1and2Helper(object):