~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-07-25 02:47:25 UTC
  • mfrom: (2625.8.2 knits)
  • Revision ID: pqm@pqm.ubuntu.com-20070725024725-x592w4y7gdqxv81x
(robertc) Allow the adaption of Knits to external indices via KnitGraphIndex. (Robert Collins).

Show diffs side-by-side

added added

removed removed

Lines of Context:
390
390
        :param version_ids: Versions to select.
391
391
                            None means retrieve all versions.
392
392
        """
 
393
        if version_ids is None:
 
394
            return dict(self.iter_parents(self.versions()))
393
395
        result = {}
394
 
        if version_ids is None:
395
 
            for version in self.versions():
396
 
                result[version] = self.get_parents(version)
397
 
        else:
398
 
            pending = set(osutils.safe_revision_id(v) for v in version_ids)
399
 
            while pending:
400
 
                version = pending.pop()
401
 
                if version in result:
402
 
                    continue
403
 
                parents = self.get_parents(version)
404
 
                for parent in parents:
405
 
                    if parent in result:
406
 
                        continue
407
 
                    pending.add(parent)
 
396
        pending = set(osutils.safe_revision_id(v) for v in version_ids)
 
397
        while pending:
 
398
            this_iteration = pending
 
399
            pending = set()
 
400
            for version, parents in self.iter_parents(this_iteration):
408
401
                result[version] = parents
 
402
                pending.update(parents)
 
403
            pending.difference_update(result)
409
404
        return result
410
405
 
411
406
    def get_graph_with_ghosts(self):
501
496
        """
502
497
        raise NotImplementedError(self.iter_lines_added_or_present_in_versions)
503
498
 
 
499
    def iter_parents(self, version_ids):
 
500
        """Iterate through the parents for many version ids.
 
501
 
 
502
        :param version_ids: An iterable yielding version_ids.
 
503
        :return: An iterator that yields (version_id, parents). Requested 
 
504
            version_ids not present in the versioned file are simply skipped.
 
505
            The order is undefined, allowing for different optimisations in
 
506
            the underlying implementation.
 
507
        """
 
508
        for version_id in version_ids:
 
509
            try:
 
510
                yield version_id, tuple(self.get_parents(version_id))
 
511
            except errors.RevisionNotPresent:
 
512
                pass
 
513
 
504
514
    def transaction_finished(self):
505
515
        """The transaction that this file was opened in has finished.
506
516