~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: Robert Collins
  • Date: 2008-03-18 01:13:35 UTC
  • mto: This revision was merged to the branch mainline in revision 3306.
  • Revision ID: robertc@robertcollins.net-20080318011335-oq6210j5dgu9rz7d
Add VersionedFile.get_parent_map.

Show diffs side-by-side

added added

removed removed

Lines of Context:
371
371
        """
372
372
        raise NotImplementedError(self.get_graph_with_ghosts)
373
373
 
 
374
    def get_parent_map(self, version_ids):
 
375
        """Get a map of the parents of version_ids.
 
376
 
 
377
        :param version_ids: The version ids to look up parents for.
 
378
        :return: A mapping from version id to parents.
 
379
        """
 
380
        raise NotImplementedError(self.get_parent_map)
 
381
 
374
382
    def get_parents(self, version_id):
375
383
        """Return version names for parents of a version.
376
384
 
377
385
        Must raise RevisionNotPresent if version is not present in
378
386
        file history.
379
387
        """
380
 
        raise NotImplementedError(self.get_parents)
 
388
        try:
 
389
            all = self.get_parent_map([version_id])[version_id]
 
390
        except KeyError:
 
391
            raise errors.RevisionNotPresent(version_id, self)
 
392
        result = []
 
393
        parent_parents = self.get_parent_map(all)
 
394
        for version_id in all:
 
395
            if version_id in parent_parents:
 
396
                result.append(version_id)
 
397
        return result
381
398
 
382
399
    def get_parents_with_ghosts(self, version_id):
383
400
        """Return version names for parents of version_id.
388
405
        Ghosts that are known about will be included in the parent list,
389
406
        but are not explicitly marked.
390
407
        """
391
 
        raise NotImplementedError(self.get_parents_with_ghosts)
 
408
        try:
 
409
            return list(self.get_parent_map([version_id])[version_id])
 
410
        except KeyError:
 
411
            raise errors.RevisionNotPresent(version_id, self)
392
412
 
393
413
    def annotate_iter(self, version_id):
394
414
        """Yield list of (version-id, line) pairs for the specified