1
# Copyright (C) 2005, 2006 Canonical Ltd
4
# Johan Rydberg <jrydberg@gnu.org>
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
"""Versioned text file storage api."""
22
from bzrlib.lazy_import import lazy_import
23
lazy_import(globals(), """
33
from bzrlib.graph import Graph
34
from bzrlib.transport.memory import MemoryTransport
37
from cStringIO import StringIO
39
from bzrlib.inter import InterObject
40
from bzrlib.symbol_versioning import *
41
from bzrlib.textmerge import TextMerge
44
class VersionedFile(object):
45
"""Versioned text file storage.
47
A versioned file manages versions of line-based text files,
48
keeping track of the originating version for each line.
50
To clients the "lines" of the file are represented as a list of
51
strings. These strings will typically have terminal newline
52
characters, but this is not required. In particular files commonly
53
do not have a newline at the end of the file.
55
Texts are identified by a version-id string.
58
def __init__(self, access_mode):
60
self._access_mode = access_mode
63
def check_not_reserved_id(version_id):
64
revision.check_not_reserved_id(version_id)
66
def copy_to(self, name, transport):
67
"""Copy this versioned file to name on transport."""
68
raise NotImplementedError(self.copy_to)
71
"""Return a unsorted list of versions."""
72
raise NotImplementedError(self.versions)
74
@deprecated_method(one_four)
75
def has_ghost(self, version_id):
76
"""Returns whether version is present as a ghost."""
77
raise NotImplementedError(self.has_ghost)
79
def has_version(self, version_id):
80
"""Returns whether version is present."""
81
raise NotImplementedError(self.has_version)
83
def add_lines(self, version_id, parents, lines, parent_texts=None,
84
left_matching_blocks=None, nostore_sha=None, random_id=False,
86
"""Add a single text on top of the versioned file.
88
Must raise RevisionAlreadyPresent if the new version is
89
already present in file history.
91
Must raise RevisionNotPresent if any of the given parents are
92
not present in file history.
94
:param lines: A list of lines. Each line must be a bytestring. And all
95
of them except the last must be terminated with \n and contain no
96
other \n's. The last line may either contain no \n's or a single
97
terminated \n. If the lines list does meet this constraint the add
98
routine may error or may succeed - but you will be unable to read
99
the data back accurately. (Checking the lines have been split
100
correctly is expensive and extremely unlikely to catch bugs so it
101
is not done at runtime unless check_content is True.)
102
:param parent_texts: An optional dictionary containing the opaque
103
representations of some or all of the parents of version_id to
104
allow delta optimisations. VERY IMPORTANT: the texts must be those
105
returned by add_lines or data corruption can be caused.
106
:param left_matching_blocks: a hint about which areas are common
107
between the text and its left-hand-parent. The format is
108
the SequenceMatcher.get_matching_blocks format.
109
:param nostore_sha: Raise ExistingContent and do not add the lines to
110
the versioned file if the digest of the lines matches this.
111
:param random_id: If True a random id has been selected rather than
112
an id determined by some deterministic process such as a converter
113
from a foreign VCS. When True the backend may choose not to check
114
for uniqueness of the resulting key within the versioned file, so
115
this should only be done when the result is expected to be unique
117
:param check_content: If True, the lines supplied are verified to be
118
bytestrings that are correctly formed lines.
119
:return: The text sha1, the number of bytes in the text, and an opaque
120
representation of the inserted version which can be provided
121
back to future add_lines calls in the parent_texts dictionary.
123
self._check_write_ok()
124
return self._add_lines(version_id, parents, lines, parent_texts,
125
left_matching_blocks, nostore_sha, random_id, check_content)
127
def _add_lines(self, version_id, parents, lines, parent_texts,
128
left_matching_blocks, nostore_sha, random_id, check_content):
129
"""Helper to do the class specific add_lines."""
130
raise NotImplementedError(self.add_lines)
132
def add_lines_with_ghosts(self, version_id, parents, lines,
133
parent_texts=None, nostore_sha=None, random_id=False,
134
check_content=True, left_matching_blocks=None):
135
"""Add lines to the versioned file, allowing ghosts to be present.
137
This takes the same parameters as add_lines and returns the same.
139
self._check_write_ok()
140
return self._add_lines_with_ghosts(version_id, parents, lines,
141
parent_texts, nostore_sha, random_id, check_content, left_matching_blocks)
143
def _add_lines_with_ghosts(self, version_id, parents, lines, parent_texts,
144
nostore_sha, random_id, check_content, left_matching_blocks):
145
"""Helper to do class specific add_lines_with_ghosts."""
146
raise NotImplementedError(self.add_lines_with_ghosts)
148
def check(self, progress_bar=None):
149
"""Check the versioned file for integrity."""
150
raise NotImplementedError(self.check)
152
def _check_lines_not_unicode(self, lines):
153
"""Check that lines being added to a versioned file are not unicode."""
155
if line.__class__ is not str:
156
raise errors.BzrBadParameterUnicode("lines")
158
def _check_lines_are_lines(self, lines):
159
"""Check that the lines really are full lines without inline EOL."""
161
if '\n' in line[:-1]:
162
raise errors.BzrBadParameterContainsNewline("lines")
164
def _check_write_ok(self):
165
"""Is the versioned file marked as 'finished' ? Raise if it is."""
167
raise errors.OutSideTransaction()
168
if self._access_mode != 'w':
169
raise errors.ReadOnlyObjectDirtiedError(self)
171
def enable_cache(self):
172
"""Tell this versioned file that it should cache any data it reads.
174
This is advisory, implementations do not have to support caching.
178
def clear_cache(self):
179
"""Remove any data cached in the versioned file object.
181
This only needs to be supported if caches are supported
185
def clone_text(self, new_version_id, old_version_id, parents):
186
"""Add an identical text to old_version_id as new_version_id.
188
Must raise RevisionNotPresent if the old version or any of the
189
parents are not present in file history.
191
Must raise RevisionAlreadyPresent if the new version is
192
already present in file history."""
193
self._check_write_ok()
194
return self._clone_text(new_version_id, old_version_id, parents)
196
def _clone_text(self, new_version_id, old_version_id, parents):
197
"""Helper function to do the _clone_text work."""
198
raise NotImplementedError(self.clone_text)
200
def create_empty(self, name, transport, mode=None):
201
"""Create a new versioned file of this exact type.
203
:param name: the file name
204
:param transport: the transport
205
:param mode: optional file mode.
207
raise NotImplementedError(self.create_empty)
209
def get_format_signature(self):
210
"""Get a text description of the data encoding in this file.
214
raise NotImplementedError(self.get_format_signature)
216
def make_mpdiffs(self, version_ids):
217
"""Create multiparent diffs for specified versions."""
218
knit_versions = set()
219
knit_versions.update(version_ids)
220
parent_map = self.get_parent_map(version_ids)
221
for version_id in version_ids:
223
knit_versions.update(parent_map[version_id])
225
raise RevisionNotPresent(version_id, self)
226
# We need to filter out ghosts, because we can't diff against them.
227
knit_versions = set(self.get_parent_map(knit_versions).keys())
228
lines = dict(zip(knit_versions,
229
self._get_lf_split_line_list(knit_versions)))
231
for version_id in version_ids:
232
target = lines[version_id]
234
parents = [lines[p] for p in parent_map[version_id] if p in
237
raise RevisionNotPresent(version_id, self)
239
left_parent_blocks = self._extract_blocks(version_id,
242
left_parent_blocks = None
243
diffs.append(multiparent.MultiParent.from_lines(target, parents,
247
def _extract_blocks(self, version_id, source, target):
250
def add_mpdiffs(self, records):
251
"""Add mpdiffs to this VersionedFile.
253
Records should be iterables of version, parents, expected_sha1,
254
mpdiff. mpdiff should be a MultiParent instance.
256
# Does this need to call self._check_write_ok()? (IanC 20070919)
258
mpvf = multiparent.MultiMemoryVersionedFile()
260
for version, parent_ids, expected_sha1, mpdiff in records:
261
versions.append(version)
262
mpvf.add_diff(mpdiff, version, parent_ids)
263
needed_parents = set()
264
for version, parent_ids, expected_sha1, mpdiff in records:
265
needed_parents.update(p for p in parent_ids
266
if not mpvf.has_version(p))
267
present_parents = set(self.get_parent_map(needed_parents).keys())
268
for parent_id, lines in zip(present_parents,
269
self._get_lf_split_line_list(present_parents)):
270
mpvf.add_version(lines, parent_id, [])
271
for (version, parent_ids, expected_sha1, mpdiff), lines in\
272
zip(records, mpvf.get_line_list(versions)):
273
if len(parent_ids) == 1:
274
left_matching_blocks = list(mpdiff.get_matching_blocks(0,
275
mpvf.get_diff(parent_ids[0]).num_lines()))
277
left_matching_blocks = None
279
_, _, version_text = self.add_lines_with_ghosts(version,
280
parent_ids, lines, vf_parents,
281
left_matching_blocks=left_matching_blocks)
282
except NotImplementedError:
283
# The vf can't handle ghosts, so add lines normally, which will
284
# (reasonably) fail if there are ghosts in the data.
285
_, _, version_text = self.add_lines(version,
286
parent_ids, lines, vf_parents,
287
left_matching_blocks=left_matching_blocks)
288
vf_parents[version] = version_text
289
for (version, parent_ids, expected_sha1, mpdiff), sha1 in\
290
zip(records, self.get_sha1s(versions)):
291
if expected_sha1 != sha1:
292
raise errors.VersionedFileInvalidChecksum(version)
294
def get_sha1(self, version_id):
295
"""Get the stored sha1 sum for the given revision.
297
:param version_id: The name of the version to lookup
299
raise NotImplementedError(self.get_sha1)
301
def get_sha1s(self, version_ids):
302
"""Get the stored sha1 sums for the given revisions.
304
:param version_ids: The names of the versions to lookup
305
:return: a list of sha1s in order according to the version_ids
307
raise NotImplementedError(self.get_sha1s)
309
def get_suffixes(self):
310
"""Return the file suffixes associated with this versioned file."""
311
raise NotImplementedError(self.get_suffixes)
313
def get_text(self, version_id):
314
"""Return version contents as a text string.
316
Raises RevisionNotPresent if version is not present in
319
return ''.join(self.get_lines(version_id))
320
get_string = get_text
322
def get_texts(self, version_ids):
323
"""Return the texts of listed versions as a list of strings.
325
Raises RevisionNotPresent if version is not present in
328
return [''.join(self.get_lines(v)) for v in version_ids]
330
def get_lines(self, version_id):
331
"""Return version contents as a sequence of lines.
333
Raises RevisionNotPresent if version is not present in
336
raise NotImplementedError(self.get_lines)
338
def _get_lf_split_line_list(self, version_ids):
339
return [StringIO(t).readlines() for t in self.get_texts(version_ids)]
341
def get_ancestry(self, version_ids, topo_sorted=True):
342
"""Return a list of all ancestors of given version(s). This
343
will not include the null revision.
345
This list will not be topologically sorted if topo_sorted=False is
348
Must raise RevisionNotPresent if any of the given versions are
349
not present in file history."""
350
if isinstance(version_ids, basestring):
351
version_ids = [version_ids]
352
raise NotImplementedError(self.get_ancestry)
354
def get_ancestry_with_ghosts(self, version_ids):
355
"""Return a list of all ancestors of given version(s). This
356
will not include the null revision.
358
Must raise RevisionNotPresent if any of the given versions are
359
not present in file history.
361
Ghosts that are known about will be included in ancestry list,
362
but are not explicitly marked.
364
raise NotImplementedError(self.get_ancestry_with_ghosts)
366
def get_graph(self, version_ids=None):
367
"""Return a graph from the versioned file.
369
Ghosts are not listed or referenced in the graph.
370
:param version_ids: Versions to select.
371
None means retrieve all versions.
373
if version_ids is None:
374
return dict(self.iter_parents(self.versions()))
376
pending = set(version_ids)
378
this_iteration = pending
380
for version, parents in self.iter_parents(this_iteration):
381
result[version] = parents
382
for parent in parents:
388
@deprecated_method(one_four)
389
def get_graph_with_ghosts(self):
390
"""Return a graph for the entire versioned file.
392
Ghosts are referenced in parents list but are not
395
raise NotImplementedError(self.get_graph_with_ghosts)
397
def get_parent_map(self, version_ids):
398
"""Get a map of the parents of version_ids.
400
:param version_ids: The version ids to look up parents for.
401
:return: A mapping from version id to parents.
403
raise NotImplementedError(self.get_parent_map)
405
@deprecated_method(one_four)
406
def get_parents(self, version_id):
407
"""Return version names for parents of a version.
409
Must raise RevisionNotPresent if version is not present in
413
all = self.get_parent_map([version_id])[version_id]
415
raise errors.RevisionNotPresent(version_id, self)
417
parent_parents = self.get_parent_map(all)
418
for version_id in all:
419
if version_id in parent_parents:
420
result.append(version_id)
423
def get_parents_with_ghosts(self, version_id):
424
"""Return version names for parents of version_id.
426
Will raise RevisionNotPresent if version_id is not present
429
Ghosts that are known about will be included in the parent list,
430
but are not explicitly marked.
433
return list(self.get_parent_map([version_id])[version_id])
435
raise errors.RevisionNotPresent(version_id, self)
437
def annotate_iter(self, version_id):
438
"""Yield list of (version-id, line) pairs for the specified
441
Must raise RevisionNotPresent if the given version is
442
not present in file history.
444
raise NotImplementedError(self.annotate_iter)
446
def annotate(self, version_id):
447
return list(self.annotate_iter(version_id))
449
def join(self, other, pb=None, msg=None, version_ids=None,
450
ignore_missing=False):
451
"""Integrate versions from other into this versioned file.
453
If version_ids is None all versions from other should be
454
incorporated into this versioned file.
456
Must raise RevisionNotPresent if any of the specified versions
457
are not present in the other file's history unless ignore_missing
458
is supplied in which case they are silently skipped.
460
self._check_write_ok()
461
return InterVersionedFile.get(other, self).join(
467
def iter_lines_added_or_present_in_versions(self, version_ids=None,
469
"""Iterate over the lines in the versioned file from version_ids.
471
This may return lines from other versions. Each item the returned
472
iterator yields is a tuple of a line and a text version that that line
473
is present in (not introduced in).
475
Ordering of results is in whatever order is most suitable for the
476
underlying storage format.
478
If a progress bar is supplied, it may be used to indicate progress.
479
The caller is responsible for cleaning up progress bars (because this
482
NOTES: Lines are normalised: they will all have \n terminators.
483
Lines are returned in arbitrary order.
485
:return: An iterator over (line, version_id).
487
raise NotImplementedError(self.iter_lines_added_or_present_in_versions)
489
def iter_parents(self, version_ids):
490
"""Iterate through the parents for many version ids.
492
:param version_ids: An iterable yielding version_ids.
493
:return: An iterator that yields (version_id, parents). Requested
494
version_ids not present in the versioned file are simply skipped.
495
The order is undefined, allowing for different optimisations in
496
the underlying implementation.
498
return self.get_parent_map(version_ids).iteritems()
500
def transaction_finished(self):
501
"""The transaction that this file was opened in has finished.
503
This records self.finished = True and should cause all mutating
508
def plan_merge(self, ver_a, ver_b):
509
"""Return pseudo-annotation indicating how the two versions merge.
511
This is computed between versions a and b and their common
514
Weave lines present in none of them are skipped entirely.
517
killed-base Dead in base revision
518
killed-both Killed in each revision
521
unchanged Alive in both a and b (possibly created in both)
524
ghost-a Killed in a, unborn in b
525
ghost-b Killed in b, unborn in a
526
irrelevant Not in either revision
528
raise NotImplementedError(VersionedFile.plan_merge)
530
def weave_merge(self, plan, a_marker=TextMerge.A_MARKER,
531
b_marker=TextMerge.B_MARKER):
532
return PlanWeaveMerge(plan, a_marker, b_marker).merge_lines()[0]
535
class _PlanMergeVersionedFile(object):
536
"""A VersionedFile for uncommitted and committed texts.
538
It is intended to allow merges to be planned with working tree texts.
539
It implements only the small part of the VersionedFile interface used by
540
PlanMerge. It falls back to multiple versionedfiles for data not stored in
541
_PlanMergeVersionedFile itself.
544
def __init__(self, file_id, fallback_versionedfiles=None):
547
:param file_id: Used when raising exceptions.
548
:param fallback_versionedfiles: If supplied, the set of fallbacks to
549
use. Otherwise, _PlanMergeVersionedFile.fallback_versionedfiles
550
can be appended to later.
552
self._file_id = file_id
553
if fallback_versionedfiles is None:
554
self.fallback_versionedfiles = []
556
self.fallback_versionedfiles = fallback_versionedfiles
560
def plan_merge(self, ver_a, ver_b, base=None):
561
"""See VersionedFile.plan_merge"""
562
from bzrlib.merge import _PlanMerge
564
return _PlanMerge(ver_a, ver_b, self).plan_merge()
565
old_plan = list(_PlanMerge(ver_a, base, self).plan_merge())
566
new_plan = list(_PlanMerge(ver_a, ver_b, self).plan_merge())
567
return _PlanMerge._subtract_plans(old_plan, new_plan)
569
def plan_lca_merge(self, ver_a, ver_b, base=None):
570
from bzrlib.merge import _PlanLCAMerge
571
graph = self._get_graph()
572
new_plan = _PlanLCAMerge(ver_a, ver_b, self, graph).plan_merge()
575
old_plan = _PlanLCAMerge(ver_a, base, self, graph).plan_merge()
576
return _PlanLCAMerge._subtract_plans(list(old_plan), list(new_plan))
578
def add_lines(self, version_id, parents, lines):
579
"""See VersionedFile.add_lines
581
Lines are added locally, not fallback versionedfiles. Also, ghosts are
582
permitted. Only reserved ids are permitted.
584
if not revision.is_reserved_id(version_id):
585
raise ValueError('Only reserved ids may be used')
587
raise ValueError('Parents may not be None')
589
raise ValueError('Lines may not be None')
590
self._parents[version_id] = tuple(parents)
591
self._lines[version_id] = lines
593
def get_lines(self, version_id):
594
"""See VersionedFile.get_ancestry"""
595
lines = self._lines.get(version_id)
596
if lines is not None:
598
for versionedfile in self.fallback_versionedfiles:
600
return versionedfile.get_lines(version_id)
601
except errors.RevisionNotPresent:
604
raise errors.RevisionNotPresent(version_id, self._file_id)
606
def get_ancestry(self, version_id, topo_sorted=False):
607
"""See VersionedFile.get_ancestry.
609
Note that this implementation assumes that if a VersionedFile can
610
answer get_ancestry at all, it can give an authoritative answer. In
611
fact, ghosts can invalidate this assumption. But it's good enough
612
99% of the time, and far cheaper/simpler.
614
Also note that the results of this version are never topologically
615
sorted, and are a set.
618
raise ValueError('This implementation does not provide sorting')
619
parents = self._parents.get(version_id)
621
for vf in self.fallback_versionedfiles:
623
return vf.get_ancestry(version_id, topo_sorted=False)
624
except errors.RevisionNotPresent:
627
raise errors.RevisionNotPresent(version_id, self._file_id)
628
ancestry = set([version_id])
629
for parent in parents:
630
ancestry.update(self.get_ancestry(parent, topo_sorted=False))
633
def get_parent_map(self, version_ids):
634
"""See VersionedFile.get_parent_map"""
636
pending = set(version_ids)
637
for key in version_ids:
639
result[key] = self._parents[key]
642
pending = pending - set(result.keys())
643
for versionedfile in self.fallback_versionedfiles:
644
parents = versionedfile.get_parent_map(pending)
645
result.update(parents)
646
pending = pending - set(parents.keys())
651
def _get_graph(self):
652
from bzrlib.graph import (
655
_StackedParentsProvider,
657
from bzrlib.repofmt.knitrepo import _KnitParentsProvider
658
parent_providers = [DictParentsProvider(self._parents)]
659
for vf in self.fallback_versionedfiles:
660
parent_providers.append(_KnitParentsProvider(vf))
661
return Graph(_StackedParentsProvider(parent_providers))
664
class PlanWeaveMerge(TextMerge):
665
"""Weave merge that takes a plan as its input.
667
This exists so that VersionedFile.plan_merge is implementable.
668
Most callers will want to use WeaveMerge instead.
671
def __init__(self, plan, a_marker=TextMerge.A_MARKER,
672
b_marker=TextMerge.B_MARKER):
673
TextMerge.__init__(self, a_marker, b_marker)
676
def _merge_struct(self):
681
def outstanding_struct():
682
if not lines_a and not lines_b:
684
elif ch_a and not ch_b:
687
elif ch_b and not ch_a:
689
elif lines_a == lines_b:
692
yield (lines_a, lines_b)
694
# We previously considered either 'unchanged' or 'killed-both' lines
695
# to be possible places to resynchronize. However, assuming agreement
696
# on killed-both lines may be too aggressive. -- mbp 20060324
697
for state, line in self.plan:
698
if state == 'unchanged':
699
# resync and flush queued conflicts changes if any
700
for struct in outstanding_struct():
706
if state == 'unchanged':
709
elif state == 'killed-a':
712
elif state == 'killed-b':
715
elif state == 'new-a':
718
elif state == 'new-b':
721
elif state == 'conflicted-a':
724
elif state == 'conflicted-b':
728
assert state in ('irrelevant', 'ghost-a', 'ghost-b',
729
'killed-base', 'killed-both'), state
730
for struct in outstanding_struct():
734
class WeaveMerge(PlanWeaveMerge):
735
"""Weave merge that takes a VersionedFile and two versions as its input."""
737
def __init__(self, versionedfile, ver_a, ver_b,
738
a_marker=PlanWeaveMerge.A_MARKER, b_marker=PlanWeaveMerge.B_MARKER):
739
plan = versionedfile.plan_merge(ver_a, ver_b)
740
PlanWeaveMerge.__init__(self, plan, a_marker, b_marker)
743
class InterVersionedFile(InterObject):
744
"""This class represents operations taking place between two VersionedFiles.
746
Its instances have methods like join, and contain
747
references to the source and target versionedfiles these operations can be
750
Often we will provide convenience methods on 'versionedfile' which carry out
751
operations with another versionedfile - they will always forward to
752
InterVersionedFile.get(other).method_name(parameters).
756
"""The available optimised InterVersionedFile types."""
758
def join(self, pb=None, msg=None, version_ids=None, ignore_missing=False):
759
"""Integrate versions from self.source into self.target.
761
If version_ids is None all versions from source should be
762
incorporated into this versioned file.
764
Must raise RevisionNotPresent if any of the specified versions
765
are not present in the other file's history unless ignore_missing is
766
supplied in which case they are silently skipped.
769
# - if the target is empty, just add all the versions from
770
# source to target, otherwise:
771
# - make a temporary versioned file of type target
772
# - insert the source content into it one at a time
774
if not self.target.versions():
777
# Make a new target-format versioned file.
778
temp_source = self.target.create_empty("temp", MemoryTransport())
780
version_ids = self._get_source_version_ids(version_ids, ignore_missing)
781
graph = Graph(self.source)
782
search = graph._make_breadth_first_searcher(version_ids)
783
transitive_ids = set()
784
map(transitive_ids.update, list(search))
785
parent_map = self.source.get_parent_map(transitive_ids)
786
order = tsort.topo_sort(parent_map.items())
787
pb = ui.ui_factory.nested_progress_bar()
790
# TODO for incremental cross-format work:
791
# make a versioned file with the following content:
792
# all revisions we have been asked to join
793
# all their ancestors that are *not* in target already.
794
# the immediate parents of the above two sets, with
795
# empty parent lists - these versions are in target already
796
# and the incorrect version data will be ignored.
797
# TODO: for all ancestors that are present in target already,
798
# check them for consistent data, this requires moving sha1 from
800
# TODO: remove parent texts when they are not relevant any more for
801
# memory pressure reduction. RBC 20060313
802
# pb.update('Converting versioned data', 0, len(order))
804
for index, version in enumerate(order):
805
pb.update('Converting versioned data', index, total)
806
_, _, parent_text = target.add_lines(version,
808
self.source.get_lines(version),
809
parent_texts=parent_texts)
810
parent_texts[version] = parent_text
812
# this should hit the native code path for target
813
if target is not self.target:
814
return self.target.join(temp_source,
824
def _get_source_version_ids(self, version_ids, ignore_missing):
825
"""Determine the version ids to be used from self.source.
827
:param version_ids: The caller-supplied version ids to check. (None
828
for all). If None is in version_ids, it is stripped.
829
:param ignore_missing: if True, remove missing ids from the version
830
list. If False, raise RevisionNotPresent on
831
a missing version id.
832
:return: A set of version ids.
834
if version_ids is None:
835
# None cannot be in source.versions
836
return set(self.source.versions())
839
return set(self.source.versions()).intersection(set(version_ids))
841
new_version_ids = set()
842
for version in version_ids:
845
if not self.source.has_version(version):
846
raise errors.RevisionNotPresent(version, str(self.source))
848
new_version_ids.add(version)
849
return new_version_ids