/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-18 01:57:45 UTC
  • mto: This revision was merged to the branch mainline in revision 7493.
  • Revision ID: jelmer@jelmer.uk-20200218015745-q2ss9tsk74h4nh61
drop use of future.

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
        """Return the source branch."""
127
127
        raise NotImplementedError(self.get_source_branch_url)
128
128
 
129
 
    def get_source_revision(self):
130
 
        """Return the latest revision for the source branch."""
131
 
        raise NotImplementedError(self.get_source_revision)
132
 
 
133
129
    def get_target_branch_url(self):
134
130
        """Return the target branch."""
135
131
        raise NotImplementedError(self.get_target_branch_url)
176
172
        """
177
173
        raise NotImplementedError(self.get_merged_at)
178
174
 
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
175
 
188
176
class MergeProposalBuilder(object):
189
177
    """Merge proposal creator.
212
200
 
213
201
    def create_proposal(self, description, reviewers=None, labels=None,
214
202
                        prerequisite_branch=None, commit_message=None,
215
 
                        work_in_progress=False, allow_collaboration=False):
 
203
                        work_in_progress=False):
216
204
        """Create a proposal to merge a branch for merging.
217
205
 
218
206
        :param description: Description for the merge proposal
222
210
        :param commit_message: Optional commit message
223
211
        :param work_in_progress:
224
212
            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
213
        :return: A `MergeProposal` object
229
214
        """
230
215
        raise NotImplementedError(self.create_proposal)
238
223
    # proposals?
239
224
    supports_merge_proposal_labels = None
240
225
 
241
 
    @property
242
 
    def name(self):
243
 
        """Name of this instance."""
244
 
        return "%s at %s" % (type(self).__name__, self.base_url)
245
 
 
246
226
    # Does this hoster support suggesting a commit message in the
247
227
    # merge proposal?
248
228
    supports_merge_proposal_commit_message = None
255
235
    # Common values: 'plain', 'markdown'
256
236
    merge_proposal_description_format = None
257
237
 
258
 
    # Does this hoster support the allow_collaboration flag?
259
 
    supports_allow_collaboration = False
260
 
 
261
238
    def publish_derived(self, new_branch, base_branch, name, project=None,
262
239
                        owner=None, revision_id=None, overwrite=False,
263
 
                        allow_lossy=True, tag_selector=None):
 
240
                        allow_lossy=True):
264
241
        """Publish a branch to the site, derived from base_branch.
265
242
 
266
243
        :param base_branch: branch to derive the new branch from
269
246
        :raise HosterLoginRequired: Action requires a hoster login, but none is
270
247
            known.
271
248
        """
272
 
        raise NotImplementedError(self.publish_derived)
 
249
        raise NotImplementedError(self.publish)
273
250
 
274
251
    def get_derived_branch(self, base_branch, name, project=None, owner=None):
275
252
        """Get a derived branch ('a fork').
357
334
        """
358
335
        raise NotImplementedError(cls.iter_instances)
359
336
 
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
337
 
372
338
def determine_title(description):
373
339
    """Determine the title for a merge proposal based on full description."""
398
364
    raise UnsupportedHoster(branch)
399
365
 
400
366
 
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
367
def get_proposal_by_url(url):
412
368
    """Get the proposal object associated with a URL.
413
369
 
415
371
    :raise UnsupportedHoster: if there is no hoster that supports the URL
416
372
    :return: A `MergeProposal` object
417
373
    """
418
 
    for instance in iter_hoster_instances():
419
 
        try:
420
 
            return instance.get_proposal_by_url(url)
421
 
        except UnsupportedHoster:
422
 
            pass
 
374
    for name, hoster_cls in hosters.items():
 
375
        for instance in hoster_cls.iter_instances():
 
376
            try:
 
377
                return instance.get_proposal_by_url(url)
 
378
            except UnsupportedHoster:
 
379
                pass
423
380
    raise UnsupportedHoster(url)
424
381
 
425
382