535
535
return self._backing_vf.add_lines(key, parents, lines, parent_texts,
536
536
left_matching_blocks, nostore_sha, random_id, check_content)
539
self._backing_vf.check()
538
541
def get_parent_map(self, keys):
539
542
self.calls.append(("get_parent_map", copy(keys)))
540
543
return self._backing_vf.get_parent_map(keys)
890
893
knit_keys.update(parent_keys)
891
894
missing_keys = keys - set(parent_map)
893
raise errors.RevisionNotPresent(missing_keys.pop(), self)
896
raise errors.RevisionNotPresent(list(missing_keys)[0], self)
894
897
# We need to filter out ghosts, because we can't diff against them.
895
898
maybe_ghosts = knit_keys - keys
896
899
ghosts = maybe_ghosts - set(self.get_parent_map(maybe_ghosts))
1320
1323
PlanWeaveMerge.__init__(self, plan, a_marker, b_marker)
1326
class VirtualVersionedFiles(VersionedFiles):
1327
"""Dummy implementation for VersionedFiles that uses other functions for
1328
obtaining fulltexts and parent maps.
1330
This is always on the bottom of the stack and uses string keys
1331
(rather than tuples) internally.
1334
def __init__(self, get_parent_map, get_lines):
1335
"""Create a VirtualVersionedFiles.
1337
:param get_parent_map: Same signature as Repository.get_parent_map.
1338
:param get_lines: Should return lines for specified key or None if
1341
super(VirtualVersionedFiles, self).__init__()
1342
self._get_parent_map = get_parent_map
1343
self._get_lines = get_lines
1345
def check(self, progressbar=None):
1346
"""See VersionedFiles.check.
1348
:note: Always returns True for VirtualVersionedFiles.
1352
def add_mpdiffs(self, records):
1353
"""See VersionedFiles.mpdiffs.
1355
:note: Not implemented for VirtualVersionedFiles.
1357
raise NotImplementedError(self.add_mpdiffs)
1359
def get_parent_map(self, keys):
1360
"""See VersionedFiles.get_parent_map."""
1361
return dict([((k,), tuple([(p,) for p in v]))
1362
for k,v in self._get_parent_map([k for (k,) in keys]).iteritems()])
1364
def get_sha1s(self, keys):
1365
"""See VersionedFiles.get_sha1s."""
1368
lines = self._get_lines(k)
1369
if lines is not None:
1370
if not isinstance(lines, list):
1371
raise AssertionError
1372
ret[(k,)] = osutils.sha_strings(lines)
1375
def get_record_stream(self, keys, ordering, include_delta_closure):
1376
"""See VersionedFiles.get_record_stream."""
1377
for (k,) in list(keys):
1378
lines = self._get_lines(k)
1379
if lines is not None:
1380
if not isinstance(lines, list):
1381
raise AssertionError
1382
yield FulltextContentFactory((k,), None,
1383
sha1=osutils.sha_strings(lines),
1384
text=''.join(lines))
1386
yield AbsentContentFactory((k,))