Hi,
I'm looking for a way to look up a reviewboard repository by its name using 
the python api.  We're currently moving our single CVS repo to a 
modularized git one, and so we're expecting the number of repositories that 
reviewboard has to manage to grow very quickly.  So, what I'm trying to do 
is write a git post-commit script that can check to see if a given git repo 
already has a reviewboard repository created for it, and create one if it 
doesn't exist yet.  My current solution is to do this:

def find_repo_by_name(repository_name):
    from rbtools.api.client import RBClient
    client = RBClient('http://path/to/reviewboard')
    root = client.get_root()
    repo_count = root.get_repositories(counts_only=True).count
    all_repositories = root.get_repositories(max_results=repo_count)
    repository_name = 'prod-nuke'
    for repository in all_repositories:
        if repository.name == repository_name:
            return repository
    raise IndexError('Repository {name} does not exist on 
server'.format(name=repository_name))

This stinks because it has to do the http transmission of all the data for 
all the repositories.  Obviously I could write it using max_results=25 and 
use the get_next() method on the ListResource class, but the worst case 
still has O(n) efficiency.

I'd really like to do something like this:
client.get_root().get_repository(repository_name='my-name-here')

Does the reviewboard api provide mechanisms for searching with keys other 
than the primary key / resource id?  If it does, I can't seem to find it...

Thanks,
-Chris

-- 
Get the Review Board Power Pack at http://www.reviewboard.org/powerpack/
---
Sign up for Review Board hosting at RBCommons: https://rbcommons.com/
---
Happy user? Let us know at http://www.reviewboard.org/users/
--- 
You received this message because you are subscribed to the Google Groups 
"reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to reviewboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to