~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/__init__.py

  • Committer: Robert Collins
  • Date: 2008-01-25 10:46:10 UTC
  • mto: This revision was merged to the branch mainline in revision 3211.
  • Revision ID: robertc@robertcollins.net-20080125104610-4qweeqqch2feyxdv
 * The ``register-branch`` command will now use the public url of the branch
   containing the current directory, if one has been set and no explicit branch is provided.
   (Robert Collins)

 * New error ``NoPublicBranch`` for commands that need a public branch to
   operate. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
# see http://bazaar-vcs.org/Specs/BranchRegistrationTool
23
23
 
 
24
from bzrlib.branch import Branch
24
25
from bzrlib.commands import Command, Option, register_command
 
26
from bzrlib.errors import BzrCommandError, NoPublicBranch, NotBranchError
25
27
from bzrlib.transport import register_lazy_transport
26
28
from bzrlib.help_topics import topic_registry
27
29
 
37
39
    branch belongs, and create an account for yourself on launchpad.net.
38
40
 
39
41
    arguments:
40
 
        branch_url: The publicly visible url for the branch.
41
 
                    This must be an http or https url, not a local file
42
 
                    path.
 
42
        public_url: The publicly visible url for the branch.
 
43
                    This must be an http or https url (which Launchpad can read
 
44
                    from to access the branch). Local file urls, SFTP urls, and
 
45
                    bzr+ssh urls will not work.
 
46
                    If no public_url is provided, bzr will use the configured
 
47
                    public_url if there is one for the branch, and error if
 
48
                    none is configured.
43
49
 
44
50
    example:
45
51
        bzr register-branch http://foo.com/bzr/fooproduct.mine \\
46
52
                --product fooproduct
47
53
    """
48
 
    takes_args = ['branch_url']
 
54
    takes_args = ['public_url?']
49
55
    takes_options = [
50
56
         Option('product',
51
57
                'Launchpad product short name to associate with the branch.',
71
77
        ]
72
78
 
73
79
 
74
 
    def run(self, 
75
 
            branch_url, 
 
80
    def run(self,
 
81
            public_url=None,
76
82
            product='',
77
83
            branch_name='',
78
84
            branch_title='',
83
89
        from bzrlib.plugins.launchpad.lp_registration import (
84
90
            LaunchpadService, BranchRegistrationRequest, BranchBugLinkRequest,
85
91
            DryRunLaunchpadService)
86
 
        rego = BranchRegistrationRequest(branch_url=branch_url,
 
92
        if public_url is None:
 
93
            try:
 
94
                b = Branch.open_containing('.')[0]
 
95
            except NotBranchError:
 
96
                raise BzrCommandError('register-branch requires a public '
 
97
                    'branch url - see bzr help register-branch.')
 
98
            public_url = b.get_public_branch()
 
99
            if public_url is None:
 
100
                raise NoPublicBranch(b)
 
101
 
 
102
        rego = BranchRegistrationRequest(branch_url=public_url,
87
103
                                         branch_name=branch_name,
88
104
                                         branch_title=branch_title,
89
105
                                         branch_description=branch_description,
90
106
                                         product_name=product,
91
107
                                         author_email=author,
92
108
                                         )
93
 
        linko = BranchBugLinkRequest(branch_url=branch_url,
 
109
        linko = BranchBugLinkRequest(branch_url=public_url,
94
110
                                     bug_id=link_bug)
95
111
        if not dry_run:
96
112
            service = LaunchpadService()