/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/launchpad/cmds.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-02 07:23:11 UTC
  • mfrom: (6647 work)
  • mto: This revision was merged to the branch mainline in revision 6649.
  • Revision ID: jelmer@jelmer.uk-20170602072311-3w22bcl0t8lzhuax
Merge lp:brz.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012 Canonical Ltd
 
1
# Copyright (C) 2006-2017 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
29
29
from ...errors import (
30
30
    BzrCommandError,
31
31
    InvalidURL,
32
 
    NoPublicBranch,
33
32
    NotBranchError,
34
33
    )
35
34
from ...i18n import gettext
39
38
    )
40
39
 
41
40
 
42
 
class cmd_register_branch(Command):
43
 
    __doc__ = """Register a branch with launchpad.net.
44
 
 
45
 
    This command lists a brz branch in the directory of branches on
46
 
    launchpad.net.  Registration allows the branch to be associated with
47
 
    bugs or specifications.
48
 
 
49
 
    Before using this command you must register the project to which the
50
 
    branch belongs, and create an account for yourself on launchpad.net.
51
 
 
52
 
    arguments:
53
 
        public_url: The publicly visible url for the branch to register.
54
 
                    This must be an http or https url (which Launchpad can read
55
 
                    from to access the branch). Local file urls, SFTP urls, and
56
 
                    brz+ssh urls will not work.
57
 
                    If no public_url is provided, brz will use the configured
58
 
                    public_url if there is one for the current branch, and
59
 
                    otherwise error.
60
 
 
61
 
    example:
62
 
        brz register-branch http://foo.com/brz/fooproject.mine \\
63
 
                --project fooproject
64
 
    """
65
 
    takes_args = ['public_url?']
66
 
    takes_options = [
67
 
         Option('project',
68
 
                'Launchpad project short name to associate with the branch.',
69
 
                unicode),
70
 
         Option('product',
71
 
                'Launchpad product short name to associate with the branch.',
72
 
                unicode,
73
 
                hidden=True),
74
 
         Option('branch-name',
75
 
                'Short name for the branch; '
76
 
                'by default taken from the last component of the url.',
77
 
                unicode),
78
 
         Option('branch-title',
79
 
                'One-sentence description of the branch.',
80
 
                unicode),
81
 
         Option('branch-description',
82
 
                'Longer description of the purpose or contents of the branch.',
83
 
                unicode),
84
 
         Option('author',
85
 
                "Branch author's email address, if not yourself.",
86
 
                unicode),
87
 
         Option('link-bug',
88
 
                'The bug this branch fixes.',
89
 
                int),
90
 
         Option('dry-run',
91
 
                'Prepare the request but don\'t actually send it.')
92
 
        ]
93
 
 
94
 
 
95
 
    def run(self,
96
 
            public_url=None,
97
 
            project='',
98
 
            product=None,
99
 
            branch_name='',
100
 
            branch_title='',
101
 
            branch_description='',
102
 
            author='',
103
 
            link_bug=None,
104
 
            dry_run=False):
105
 
        from .lp_registration import (
106
 
            BranchRegistrationRequest, BranchBugLinkRequest,
107
 
            DryRunLaunchpadService, LaunchpadService)
108
 
        if public_url is None:
109
 
            try:
110
 
                b = _mod_branch.Branch.open_containing('.')[0]
111
 
            except NotBranchError:
112
 
                raise BzrCommandError(gettext(
113
 
                            'register-branch requires a public '
114
 
                            'branch url - see brz help register-branch.'))
115
 
            public_url = b.get_public_branch()
116
 
            if public_url is None:
117
 
                raise NoPublicBranch(b)
118
 
        if product is not None:
119
 
            project = product
120
 
            trace.note(gettext(
121
 
                '--product is deprecated; please use --project.'))
122
 
 
123
 
 
124
 
        rego = BranchRegistrationRequest(branch_url=public_url,
125
 
                                         branch_name=branch_name,
126
 
                                         branch_title=branch_title,
127
 
                                         branch_description=branch_description,
128
 
                                         product_name=project,
129
 
                                         author_email=author,
130
 
                                         )
131
 
        linko = BranchBugLinkRequest(branch_url=public_url,
132
 
                                     bug_id=link_bug)
133
 
        if not dry_run:
134
 
            service = LaunchpadService()
135
 
            # This gives back the xmlrpc url that can be used for future
136
 
            # operations on the branch.  It's not so useful to print to the
137
 
            # user since they can't do anything with it from a web browser; it
138
 
            # might be nice for the server to tell us about an html url as
139
 
            # well.
140
 
        else:
141
 
            # Run on service entirely in memory
142
 
            service = DryRunLaunchpadService()
143
 
        service.gather_user_credentials()
144
 
        rego.submit(service)
145
 
        if link_bug:
146
 
            linko.submit(service)
147
 
        self.outf.write('Branch registered.\n')
148
 
 
149
 
 
150
41
class cmd_launchpad_open(Command):
151
42
    __doc__ = """Open a Launchpad branch page in your web browser."""
152
43