/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-04-05 19:11:34 UTC
  • mto: (7490.7.16 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200405191134-0aebh8ikiwygxma5
Populate the .gitignore file.

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.
238
228
    # proposals?
239
229
    supports_merge_proposal_labels = None
240
230
 
241
 
    @property
242
 
    def name(self):
243
 
        """Name of this instance."""
244
 
        return "%s at %s" % (type(self).__name__, self.base_url)
245
 
 
246
231
    # Does this hoster support suggesting a commit message in the
247
232
    # merge proposal?
248
233
    supports_merge_proposal_commit_message = None
269
254
        :raise HosterLoginRequired: Action requires a hoster login, but none is
270
255
            known.
271
256
        """
272
 
        raise NotImplementedError(self.publish_derived)
 
257
        raise NotImplementedError(self.publish)
273
258
 
274
259
    def get_derived_branch(self, base_branch, name, project=None, owner=None):
275
260
        """Get a derived branch ('a fork').
357
342
        """
358
343
        raise NotImplementedError(cls.iter_instances)
359
344
 
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
345
 
372
346
def determine_title(description):
373
347
    """Determine the title for a merge proposal based on full description."""
398
372
    raise UnsupportedHoster(branch)
399
373
 
400
374
 
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
375
def get_proposal_by_url(url):
412
376
    """Get the proposal object associated with a URL.
413
377
 
415
379
    :raise UnsupportedHoster: if there is no hoster that supports the URL
416
380
    :return: A `MergeProposal` object
417
381
    """
418
 
    for instance in iter_hoster_instances():
419
 
        try:
420
 
            return instance.get_proposal_by_url(url)
421
 
        except UnsupportedHoster:
422
 
            pass
 
382
    for name, hoster_cls in hosters.items():
 
383
        for instance in hoster_cls.iter_instances():
 
384
            try:
 
385
                return instance.get_proposal_by_url(url)
 
386
            except UnsupportedHoster:
 
387
                pass
423
388
    raise UnsupportedHoster(url)
424
389
 
425
390