/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-28 02:11:05 UTC
  • mfrom: (7490.40.78 work)
  • mto: This revision was merged to the branch mainline in revision 7520.
  • Revision ID: jelmer@jelmer.uk-20200728021105-fzq7g6f8bl1g0aet
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

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