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

  • Committer: Jelmer Vernooij
  • Date: 2020-02-13 23:57:28 UTC
  • mfrom: (7490 work)
  • mto: This revision was merged to the branch mainline in revision 7492.
  • Revision ID: jelmer@jelmer.uk-20200213235728-m6ds0mm3mbs4y182
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Helper functions for proposing merges."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
from . import (
20
22
    errors,
21
23
    hooks,
126
128
        """Return the source branch."""
127
129
        raise NotImplementedError(self.get_source_branch_url)
128
130
 
129
 
    def get_source_revision(self):
130
 
        """Return the latest revision for the source branch."""
131
 
        raise NotImplementedError(self.get_source_revision)
132
 
 
133
131
    def get_target_branch_url(self):
134
132
        """Return the target branch."""
135
133
        raise NotImplementedError(self.get_target_branch_url)
176
174
        """
177
175
        raise NotImplementedError(self.get_merged_at)
178
176
 
179
 
    def post_comment(self, body):
180
 
        """Post a comment on the merge proposal.
181
 
 
182
 
        Args:
183
 
          body: Body of the comment
184
 
        """
185
 
        raise NotImplementedError(self.post_comment)
186
 
 
187
177
 
188
178
class MergeProposalBuilder(object):
189
179
    """Merge proposal creator.
212
202
 
213
203
    def create_proposal(self, description, reviewers=None, labels=None,
214
204
                        prerequisite_branch=None, commit_message=None,
215
 
                        work_in_progress=False, allow_collaboration=False):
 
205
                        work_in_progress=False):
216
206
        """Create a proposal to merge a branch for merging.
217
207
 
218
208
        :param description: Description for the merge proposal
222
212
        :param commit_message: Optional commit message
223
213
        :param work_in_progress:
224
214
            Whether this merge proposal is still a work-in-progress
225
 
        :param allow_collaboration:
226
 
            Whether to allow changes to the branch from the target branch
227
 
            maintainer(s)
228
215
        :return: A `MergeProposal` object
229
216
        """
230
217
        raise NotImplementedError(self.create_proposal)
238
225
    # proposals?
239
226
    supports_merge_proposal_labels = None
240
227
 
241
 
    @property
242
 
    def name(self):
243
 
        """Name of this instance."""
244
 
        return "%s at %s" % (type(self).__name__, self.base_url)
245
 
 
246
228
    # Does this hoster support suggesting a commit message in the
247
229
    # merge proposal?
248
230
    supports_merge_proposal_commit_message = None
255
237
    # Common values: 'plain', 'markdown'
256
238
    merge_proposal_description_format = None
257
239
 
258
 
    # Does this hoster support the allow_collaboration flag?
259
 
    supports_allow_collaboration = False
260
 
 
261
240
    def publish_derived(self, new_branch, base_branch, name, project=None,
262
241
                        owner=None, revision_id=None, overwrite=False,
263
 
                        allow_lossy=True, tag_selector=None):
 
242
                        allow_lossy=True):
264
243
        """Publish a branch to the site, derived from base_branch.
265
244
 
266
245
        :param base_branch: branch to derive the new branch from
269
248
        :raise HosterLoginRequired: Action requires a hoster login, but none is
270
249
            known.
271
250
        """
272
 
        raise NotImplementedError(self.publish_derived)
 
251
        raise NotImplementedError(self.publish)
273
252
 
274
253
    def get_derived_branch(self, base_branch, name, project=None, owner=None):
275
254
        """Get a derived branch ('a fork').
357
336
        """
358
337
        raise NotImplementedError(cls.iter_instances)
359
338
 
360
 
    def get_current_user(self):
361
 
        """Retrieve the name of the currently logged in user.
362
 
 
363
 
        :return: Username or None if not logged in
364
 
        """
365
 
        raise NotImplementedError(self.get_current_user)
366
 
 
367
 
    def get_user_url(self, user):
368
 
        """Rerieve the web URL for a user."""
369
 
        raise NotImplementedError(self.get_user_url)
370
 
 
371
339
 
372
340
def determine_title(description):
373
341
    """Determine the title for a merge proposal based on full description."""
398
366
    raise UnsupportedHoster(branch)
399
367
 
400
368
 
401
 
def iter_hoster_instances():
402
 
    """Iterate over all known hoster instances.
403
 
 
404
 
    :return: Iterator over Hoster instances
405
 
    """
406
 
    for name, hoster_cls in hosters.items():
407
 
        for instance in hoster_cls.iter_instances():
408
 
            yield instance
409
 
 
410
 
 
411
369
def get_proposal_by_url(url):
412
370
    """Get the proposal object associated with a URL.
413
371
 
415
373
    :raise UnsupportedHoster: if there is no hoster that supports the URL
416
374
    :return: A `MergeProposal` object
417
375
    """
418
 
    for instance in iter_hoster_instances():
419
 
        try:
420
 
            return instance.get_proposal_by_url(url)
421
 
        except UnsupportedHoster:
422
 
            pass
 
376
    for name, hoster_cls in hosters.items():
 
377
        for instance in hoster_cls.iter_instances():
 
378
            try:
 
379
                return instance.get_proposal_by_url(url)
 
380
            except UnsupportedHoster:
 
381
                pass
423
382
    raise UnsupportedHoster(url)
424
383
 
425
384