1220
1221
# rather copying them?
1221
1222
self._safe_to_return_from_cache = False
1224
def fetch(self, source, revision_id=None, find_ghosts=False,
1226
"""Fetch the content required to construct revision_id from source.
1228
If revision_id is None and fetch_spec is None, then all content is
1231
fetch() may not be used when the repository is in a write group -
1232
either finish the current write group before using fetch, or use
1233
fetch before starting the write group.
1235
:param find_ghosts: Find and copy revisions in the source that are
1236
ghosts in the target (and not reachable directly by walking out to
1237
the first-present revision in target from revision_id).
1238
:param revision_id: If specified, all the content needed for this
1239
revision ID will be copied to the target. Fetch will determine for
1240
itself which content needs to be copied.
1241
:param fetch_spec: If specified, a SearchResult or
1242
PendingAncestryResult that describes which revisions to copy. This
1243
allows copying multiple heads at once. Mutually exclusive with
1246
if fetch_spec is not None and revision_id is not None:
1247
raise AssertionError(
1248
"fetch_spec and revision_id are mutually exclusive.")
1249
if self.is_in_write_group():
1250
raise errors.InternalBzrError(
1251
"May not fetch while in a write group.")
1252
# fast path same-url fetch operations
1253
# TODO: lift out to somewhere common with RemoteRepository
1254
# <https://bugs.launchpad.net/bzr/+bug/401646>
1255
if (self.has_same_location(source)
1256
and fetch_spec is None
1257
and self._has_same_fallbacks(source)):
1258
# check that last_revision is in 'from' and then return a
1260
if (revision_id is not None and
1261
not _mod_revision.is_null(revision_id)):
1262
self.get_revision(revision_id)
1264
inter = InterRepository.get(source, self)
1265
if (fetch_spec is not None and
1266
not getattr(inter, "supports_fetch_spec", False)):
1267
raise errors.UnsupportedOperation(
1268
"fetch_spec not supported for %r" % inter)
1269
return inter.fetch(revision_id=revision_id,
1270
find_ghosts=find_ghosts, fetch_spec=fetch_spec)
1223
1272
@needs_read_lock
1224
1273
def gather_stats(self, revid=None, committers=None):
1225
1274
"""See Repository.gather_stats()."""
1854
1903
"""Return the graph walker for text revisions."""
1855
1904
return graph.Graph(self.texts)
1906
def revision_ids_to_search_result(self, result_set):
1907
"""Convert a set of revision ids to a graph SearchResult."""
1908
result_parents = set()
1909
for parents in self.get_graph().get_parent_map(
1910
result_set).itervalues():
1911
result_parents.update(parents)
1912
included_keys = result_set.intersection(result_parents)
1913
start_keys = result_set.difference(included_keys)
1914
exclude_keys = result_parents.difference(result_set)
1915
result = vf_search.SearchResult(start_keys, exclude_keys,
1916
len(result_set), result_set)
1857
1919
def _get_versioned_file_checker(self, text_key_references=None,
1858
1920
ancestors=None):
1859
1921
"""Return an object suitable for checking versioned files.
2576
2640
searcher.stop_searching_any(stop_revs)
2577
2641
if searcher_exhausted:
2579
return searcher.get_result()
2643
(started_keys, excludes, included_keys) = searcher.get_state()
2644
return vf_search.SearchResult(started_keys, excludes,
2645
len(included_keys), included_keys)
2581
2647
@needs_read_lock
2582
2648
def search_missing_revision_ids(self,