Eu agora descobri como fazer isso. Estou adicionando código para verificar uma cópia local da ramificação, embora não seja estritamente necessário (as informações de revisão podem ser lidas diretamente de uma cópia local registrada). Os bits importantes são os métodos all_revision_ids()
, get_revisions()
e get_apparent_authors()
.
import os
from bzrlib.branch import Branch
from bzrlib.plugin import load_plugins
# The location on your file system where you want to check out
# the branch to get revisions for
local_path = '/path/to/local/checkout'
# The name of the project you want to get the branch from
project_name = 'launchpad-project-name'
# Load the bzr plugins - the "launchpad" plugin
# provides support for the "lp:" shortcut
load_plugins()
remote_branch_url = 'lp:{0}'.format(project_name)
remote_branch = Branch.open(remote_branch_url)
# Check out and get an instance of the branch
local_branch = remote_branch.bzrdir.sprout(
os.path.join(local_path,
project_name)).open_branch()
# Get all revisions from the branch
all_revision_ids = local_branch.repository.get_revisions(
local_branch.repository.all_revision_ids())
# Set up a set of unique author names
authors = set()
# Iterate all revisions and get the list of authors
# without duplicates
for revision in all_revision_ids:
for author in revision.get_apparent_authors():
authors.add(author)
print 'Authors:', authors