1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/usr/bin/python -S
#
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Get useful hosting information for a branch.
Usage: get-branch-info <branch_url>
"""
import _pythonpath
import sys
from bzrlib.urlutils import join
from zope.component import getUtility
from canonical.config import config
from lp.services.scripts import execute_zcml_for_scripts
from canonical.launchpad.webapp.publisher import canonical_url
from lp.code.enums import BranchType
from lp.code.interfaces.branchlookup import IBranchLookup
from lp.codehosting.vfs import branch_id_to_path
def main(args):
branch_url = args[1]
execute_zcml_for_scripts()
branch_lookup = getUtility(IBranchLookup)
branch = branch_lookup.getByUrl(branch_url)
if branch is None:
print "Could not find branch at %r" % (branch_url,)
return
print branch.bzr_identity
print
print 'Unique name:', branch.unique_name
print 'ID:', branch.id
print 'Private:', branch.private
print 'Type:', branch.branch_type
print 'URL:', canonical_url(branch)
if branch.url is not None:
print 'External URL:', branch.url
branch_path = branch_id_to_path(branch.id)
mirrored_path = join(
config.codehosting.mirrored_branches_root, branch_path)
print 'Mirrored copy:', mirrored_path
if __name__ == '__main__':
main(sys.argv)
|