~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: Robert Collins
  • Date: 2006-04-26 05:26:38 UTC
  • mto: (1686.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1687.
  • Revision ID: robertc@robertcollins.net-20060426052638-e95d815562fc6caa
Factor out version_ids-to-join selection in InterVersionedfile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
561
561
            # Make a new target-format versioned file. 
562
562
            temp_source = self.target.create_empty("temp", MemoryTransport())
563
563
            target = temp_source
564
 
        if version_ids is not None:
565
 
            new_version_ids = []
566
 
            for version in version_ids:
567
 
                if not self.source.has_version(version):
568
 
                    if not ignore_missing:
569
 
                        raise errors.RevisionNotPresent(version, str(self.source))
570
 
                else:
571
 
                    new_version_ids.append(version)
572
 
            version_ids = new_version_ids
 
564
        version_ids = self._get_source_version_ids(version_ids, ignore_missing)
573
565
        graph = self.source.get_graph(version_ids)
574
566
        order = topo_sort(graph.items())
575
567
        pb = ui.ui_factory.nested_progress_bar()
615
607
        finally:
616
608
            pb.finished()
617
609
 
 
610
    def _get_source_version_ids(self, version_ids, ignore_missing):
 
611
        """Determine the version ids to be used from self.source.
 
612
 
 
613
        :param version_ids: The caller-supplied version ids to check. (None 
 
614
                            for all).
 
615
        :param ignore_missing: if True, remove missing ids from the version 
 
616
                               list. If False, raise RevisionNotPresent on
 
617
                               a missing version id.
 
618
        :return: A set of version ids.
 
619
        """
 
620
        if version_ids is None:
 
621
            return set(self.source.versions())
 
622
        else:
 
623
            if ignore_missing:
 
624
                return set(self.source.versions()).intersection(set(version_ids))
 
625
            else:
 
626
                new_version_ids = set()
 
627
                for version in version_ids:
 
628
                    if not self.source.has_version(version):
 
629
                        raise errors.RevisionNotPresent(version, str(self.source))
 
630
                    else:
 
631
                        new_version_ids.add(version)
 
632
                return new_version_ids
 
633
 
618
634
 
619
635
class InterVersionedFileTestProviderAdapter(object):
620
636
    """A tool to generate a suite testing multiple inter versioned-file classes.