/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/propose/cmds.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    )
39
39
from ...sixish import text_type
40
40
from ...trace import note
41
 
from ... import (
 
41
from . import (
42
42
    propose as _mod_propose,
43
43
    )
44
44
 
91
91
            overwrite=overwrite)
92
92
        local_branch.set_push_location(remote_branch.user_url)
93
93
        local_branch.set_public_branch(public_url)
94
 
        local_branch.set_submit_branch(submit_branch.user_url)
95
94
        note(gettext("Pushed to %s") % public_url)
96
95
 
97
96
 
144
143
        Option('name', help='Name of the new remote branch.', type=str),
145
144
        Option('description', help='Description of the change.', type=str),
146
145
        Option('prerequisite', help='Prerequisite branch.', type=str),
147
 
        Option('wip', help='Mark merge request as work-in-progress'),
148
146
        Option(
149
147
            'commit-message',
150
148
            help='Set commit message for merge, if supported', type=str),
152
150
                   help='Labels to apply.'),
153
151
        Option('no-allow-lossy',
154
152
               help='Allow fallback to lossy push, if necessary.'),
155
 
        Option('allow-collaboration',
156
 
               help='Allow collaboration from target branch maintainer(s)'),
157
153
        ]
158
154
    takes_args = ['submit_branch?']
159
155
 
161
157
 
162
158
    def run(self, submit_branch=None, directory='.', hoster=None,
163
159
            reviewers=None, name=None, no_allow_lossy=False, description=None,
164
 
            labels=None, prerequisite=None, commit_message=None, wip=False,
165
 
            allow_collaboration=False):
 
160
            labels=None, prerequisite=None, commit_message=None):
166
161
        tree, branch, relpath = (
167
162
            controldir.ControlDir.open_containing_tree_or_branch(directory))
168
163
        if submit_branch is None:
183
178
        remote_branch, public_branch_url = hoster.publish_derived(
184
179
            branch, target, name=name, allow_lossy=not no_allow_lossy)
185
180
        branch.set_push_location(remote_branch.user_url)
186
 
        branch.set_submit_branch(target.user_url)
187
181
        note(gettext('Published branch to %s') % public_branch_url)
188
182
        if prerequisite is not None:
189
183
            prerequisite_branch = _mod_branch.Branch.open(prerequisite)
201
195
            proposal = proposal_builder.create_proposal(
202
196
                description=description, reviewers=reviewers,
203
197
                prerequisite_branch=prerequisite_branch, labels=labels,
204
 
                commit_message=commit_message,
205
 
                work_in_progress=wip, allow_collaboration=allow_collaboration)
 
198
                commit_message=commit_message)
206
199
        except _mod_propose.MergeProposalExists as e:
207
 
            note(gettext('There is already a branch merge proposal: %s'), e.url)
208
 
        else:
209
 
            note(gettext('Merge proposal created: %s') % proposal.url)
 
200
            raise errors.BzrCommandError(gettext(
 
201
                'There is already a branch merge proposal: %s') % e.url)
 
202
        note(gettext('Merge proposal created: %s') % proposal.url)
210
203
 
211
204
 
212
205
class cmd_find_merge_proposal(Command):
343
336
            closed='Closed merge proposals')]
344
337
 
345
338
    def run(self, status='open', verbose=False):
346
 
        for name, hoster_cls in _mod_propose.hosters.items():
 
339
        from .propose import hosters
 
340
        for name, hoster_cls in hosters.items():
347
341
            for instance in hoster_cls.iter_instances():
348
342
                for mp in instance.iter_my_proposals(status=status):
349
343
                    self.outf.write('%s\n' % mp.url)
352
346
                            '(Merging %s into %s)\n' %
353
347
                            (mp.get_source_branch_url(),
354
348
                             mp.get_target_branch_url()))
355
 
                        description = mp.get_description()
356
 
                        if description:
357
 
                            self.outf.writelines(
358
 
                                ['\t%s\n' % l
359
 
                                 for l in description.splitlines()])
 
349
                        self.outf.writelines(
 
350
                            ['\t%s\n' % l
 
351
                             for l in mp.get_description().splitlines()])
360
352
                        self.outf.write('\n')
361
 
 
362
 
 
363
 
class cmd_land_merge_proposal(Command):
364
 
    __doc__ = """Land a merge proposal."""
365
 
 
366
 
    takes_args = ['url']
367
 
    takes_options = [
368
 
        Option('message', help='Commit message to use.', type=str)]
369
 
 
370
 
    def run(self, url, message=None):
371
 
        proposal = _mod_propose.get_proposal_by_url(url)
372
 
        proposal.merge(commit_message=message)