10637.3.1
by Guilherme Salgado
Use the default python version instead of a hard-coded version |
1 |
#!/usr/bin/python -S
|
8687.15.4
by Karl Fogel
Add the copyright header block to more files; tweak format in a few files. |
2 |
#
|
3 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
|
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
5 |
||
7444.4.2
by Jonathan Lange
Add a simple utility for getting information about a branch on Launchpad. |
6 |
"""Get useful hosting information for a branch.
|
7 |
||
8 |
Usage: get-branch-info <branch_url>
|
|
9 |
"""
|
|
10 |
||
11 |
import _pythonpath |
|
12 |
||
13 |
import sys |
|
14 |
||
15 |
from bzrlib.urlutils import join |
|
16 |
||
17 |
from zope.component import getUtility |
|
18 |
||
19 |
from canonical.config import config |
|
20 |
from canonical.launchpad.scripts import execute_zcml_for_scripts |
|
21 |
from canonical.launchpad.webapp.publisher import canonical_url |
|
8555.2.12
by Tim Penhey
Fix cronscripts and utilities too. |
22 |
from lp.code.enums import BranchType |
8508.1.1
by Jonathan Lange
Fix up imports, avoiding circular import. |
23 |
from lp.code.interfaces.branchlookup import IBranchLookup |
24 |
from lp.codehosting.vfs import branch_id_to_path |
|
7444.4.2
by Jonathan Lange
Add a simple utility for getting information about a branch on Launchpad. |
25 |
|
26 |
||
27 |
def main(args): |
|
28 |
branch_url = args[1] |
|
29 |
execute_zcml_for_scripts() |
|
7940.2.17
by Jonathan Lange
Remove __getitem__ from BranchSet interface. |
30 |
branch_lookup = getUtility(IBranchLookup) |
31 |
branch = branch_lookup.getByUrl(branch_url) |
|
7444.4.2
by Jonathan Lange
Add a simple utility for getting information about a branch on Launchpad. |
32 |
if branch is None: |
33 |
print "Could not find branch at %r" % (branch_url,) |
|
34 |
return
|
|
35 |
print branch.bzr_identity |
|
36 |
print
|
|
37 |
print 'Unique name:', branch.unique_name |
|
38 |
print 'ID:', branch.id |
|
39 |
print 'Private:', branch.private |
|
40 |
print 'Type:', branch.branch_type |
|
41 |
print 'URL:', canonical_url(branch) |
|
42 |
if branch.url is not None: |
|
43 |
print 'External URL:', branch.url |
|
44 |
branch_path = branch_id_to_path(branch.id) |
|
45 |
if branch.branch_type == BranchType.HOSTED: |
|
7732.1.3
by Jonathan Lange
Get rid of the branchesdest config variable. |
46 |
hosted_path = join( |
47 |
config.codehosting.hosted_branches_root, branch_path) |
|
7444.4.2
by Jonathan Lange
Add a simple utility for getting information about a branch on Launchpad. |
48 |
print 'Hosted copy:', hosted_path |
7732.1.3
by Jonathan Lange
Get rid of the branchesdest config variable. |
49 |
mirrored_path = join( |
50 |
config.codehosting.mirrored_branches_root, branch_path) |
|
7444.4.2
by Jonathan Lange
Add a simple utility for getting information about a branch on Launchpad. |
51 |
print 'Mirrored copy:', mirrored_path |
52 |
||
53 |
||
54 |
if __name__ == '__main__': |
|
55 |
main(sys.argv) |