Search code examples
pythonbazaar

How can I get a revision id's children?


If you run this

Branch.open(repository_location).repository.get_revision(revision_id).parent_ids

it will return the parent_ids of the specified revision_id.

How can I do this same thing, but instead of returning the parent_ids it returns the children_ids?

I looked through the different properties in the API and didn't find one for children.


Solution

  • The only way in which you can get this information is to scan all the revisions in the repository:

    child_revids = {}
    revs = r.get_revisions(r.all_revision_ids())
    for rev in revs:
        for parent_id in rev.parent_ids:
            child_revids.setdefault(parent_id, []).append(rev.revision_id)
    

    You probably want to avoid doing this if at all possible, since its performance scales with the size of the repository.