/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-07-05 12:50:01 UTC
  • mfrom: (7490.40.46 work)
  • mto: (7490.40.48 work)
  • mto: This revision was merged to the branch mainline in revision 7519.
  • Revision ID: jelmer@jelmer.uk-20200705125001-7s3vo0p55szbbws7
Merge lp:brz/3.1.

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,
238
240
    # proposals?
239
241
    supports_merge_proposal_labels = None
240
242
 
241
 
    @property
242
 
    def name(self):
243
 
        """Name of this instance."""
244
 
        return "%s at %s" % (type(self).__name__, self.base_url)
245
 
 
246
243
    # Does this hoster support suggesting a commit message in the
247
244
    # merge proposal?
248
245
    supports_merge_proposal_commit_message = None
269
266
        :raise HosterLoginRequired: Action requires a hoster login, but none is
270
267
            known.
271
268
        """
272
 
        raise NotImplementedError(self.publish_derived)
 
269
        raise NotImplementedError(self.publish)
273
270
 
274
271
    def get_derived_branch(self, base_branch, name, project=None, owner=None):
275
272
        """Get a derived branch ('a fork').
357
354
        """
358
355
        raise NotImplementedError(cls.iter_instances)
359
356
 
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
357
 
372
358
def determine_title(description):
373
359
    """Determine the title for a merge proposal based on full description."""
398
384
    raise UnsupportedHoster(branch)
399
385
 
400
386
 
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
387
def get_proposal_by_url(url):
412
388
    """Get the proposal object associated with a URL.
413
389
 
415
391
    :raise UnsupportedHoster: if there is no hoster that supports the URL
416
392
    :return: A `MergeProposal` object
417
393
    """
418
 
    for instance in iter_hoster_instances():
419
 
        try:
420
 
            return instance.get_proposal_by_url(url)
421
 
        except UnsupportedHoster:
422
 
            pass
 
394
    for name, hoster_cls in hosters.items():
 
395
        for instance in hoster_cls.iter_instances():
 
396
            try:
 
397
                return instance.get_proposal_by_url(url)
 
398
            except UnsupportedHoster:
 
399
                pass
423
400
    raise UnsupportedHoster(url)
424
401
 
425
402