/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 00:32:38 UTC
  • mfrom: (7490.40.77 work)
  • mto: (7490.40.79 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200728003238-vx5u412hn72f18lr
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
240
240
    # proposals?
241
241
    supports_merge_proposal_labels = None
242
242
 
 
243
    @property
 
244
    def name(self):
 
245
        """Name of this instance."""
 
246
        return "%s at %s" % (type(self).__name__, self.base_url)
 
247
 
243
248
    # Does this hoster support suggesting a commit message in the
244
249
    # merge proposal?
245
250
    supports_merge_proposal_commit_message = None
266
271
        :raise HosterLoginRequired: Action requires a hoster login, but none is
267
272
            known.
268
273
        """
269
 
        raise NotImplementedError(self.publish)
 
274
        raise NotImplementedError(self.publish_derived)
270
275
 
271
276
    def get_derived_branch(self, base_branch, name, project=None, owner=None):
272
277
        """Get a derived branch ('a fork').
354
359
        """
355
360
        raise NotImplementedError(cls.iter_instances)
356
361
 
 
362
    def get_current_user(self):
 
363
        """Retrieve the name of the currently logged in user.
 
364
 
 
365
        :return: Username or None if not logged in
 
366
        """
 
367
        raise NotImplementedError(self.get_current_user)
 
368
 
 
369
    def get_user_url(self, user):
 
370
        """Rerieve the web URL for a user."""
 
371
        raise NotImplementedError(self.get_user_url)
 
372
 
357
373
 
358
374
def determine_title(description):
359
375
    """Determine the title for a merge proposal based on full description."""
384
400
    raise UnsupportedHoster(branch)
385
401
 
386
402
 
 
403
def iter_hoster_instances():
 
404
    """Iterate over all known hoster instances.
 
405
 
 
406
    :return: Iterator over Hoster instances
 
407
    """
 
408
    for name, hoster_cls in hosters.items():
 
409
        for instance in hoster_cls.iter_instances():
 
410
            yield instance
 
411
 
 
412
 
387
413
def get_proposal_by_url(url):
388
414
    """Get the proposal object associated with a URL.
389
415
 
391
417
    :raise UnsupportedHoster: if there is no hoster that supports the URL
392
418
    :return: A `MergeProposal` object
393
419
    """
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
 
420
    for instance in iter_hoster_instances():
 
421
        try:
 
422
            return instance.get_proposal_by_url(url)
 
423
        except UnsupportedHoster:
 
424
            pass
400
425
    raise UnsupportedHoster(url)
401
426
 
402
427