~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: Robert Collins
  • Date: 2007-07-19 06:34:09 UTC
  • mto: (2592.3.46 repository)
  • mto: This revision was merged to the branch mainline in revision 2651.
  • Revision ID: robertc@robertcollins.net-20070719063409-stu9sckrxp8wp3mo
LIBRARY API BREAKS:

  * KnitIndex.get_parents now returns tuples. (Robert Collins)

INTERNALS:

  * Unused functions on the private interface KnitIndex have been removed.
    (Robert Collins)

  * New ``knit.KnitGraphIndex`` which provides a ``KnitIndex`` layered on top
    of a ``index.GraphIndex``. (Robert Collins)

  * New ``knit.KnitVersionedFile.iter_parents`` method that allows querying
    the parents of many knit nodes at once, reducing round trips to the 
    underlying index. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
332
332
        :param version_ids: Versions to select.
333
333
                            None means retrieve all versions.
334
334
        """
 
335
        if version_ids is None:
 
336
            return dict(self.iter_parents(self.versions()))
335
337
        result = {}
336
 
        if version_ids is None:
337
 
            for version in self.versions():
338
 
                result[version] = self.get_parents(version)
339
 
        else:
340
 
            pending = set(osutils.safe_revision_id(v) for v in version_ids)
341
 
            while pending:
342
 
                version = pending.pop()
343
 
                if version in result:
344
 
                    continue
345
 
                parents = self.get_parents(version)
346
 
                for parent in parents:
347
 
                    if parent in result:
348
 
                        continue
349
 
                    pending.add(parent)
 
338
        pending = set(osutils.safe_revision_id(v) for v in version_ids)
 
339
        while pending:
 
340
            this_iteration = pending
 
341
            pending = set()
 
342
            for version, parents in self.iter_parents(this_iteration):
350
343
                result[version] = parents
 
344
                pending.update(parents)
 
345
            pending.difference_update(result)
351
346
        return result
352
347
 
353
348
    def get_graph_with_ghosts(self):
443
438
        """
444
439
        raise NotImplementedError(self.iter_lines_added_or_present_in_versions)
445
440
 
 
441
    def iter_parents(self, version_ids):
 
442
        """Iterate through the parents for many version ids.
 
443
 
 
444
        :param version_ids: An iterable yielding version_ids.
 
445
        :return: An iterator that yields (version_id, parents). Requested 
 
446
            version_ids not present in the versioned file are simply skipped.
 
447
            The order is undefined, allowing for different optimisations in
 
448
            the underlying implementation.
 
449
        """
 
450
        for version_id in version_ids:
 
451
            try:
 
452
                yield version_id, tuple(self.get_parents(version_id))
 
453
            except errors.RevisionNotPresent:
 
454
                pass
 
455
 
446
456
    def transaction_finished(self):
447
457
        """The transaction that this file was opened in has finished.
448
458