/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/plugins/propose/launchpad.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
    if url.startswith('lp:'):
74
74
        return True
75
75
    regex = re.compile('([a-z]*\+)*(bzr\+ssh|http|ssh|git|https)'
76
 
                       '://(bazaar|git).*.launchpad.net')
 
76
                       '://(bazaar|git).*\.launchpad\.net')
77
77
    return bool(regex.match(url))
78
78
 
79
79
 
142
142
        self._mp.description = description
143
143
        self._mp.lp_save()
144
144
 
 
145
    def get_commit_message(self):
 
146
        return self._mp.commit_message
 
147
 
 
148
    def set_commit_message(self, commit_message):
 
149
        self._mp.commit_message = commit_message
 
150
        self._mp.lp_save()
 
151
 
145
152
    def close(self):
146
153
        self._mp.setStatus(status='Rejected')
147
154
 
154
161
    # https://bugs.launchpad.net/launchpad/+bug/397676
155
162
    supports_merge_proposal_labels = False
156
163
 
 
164
    supports_merge_proposal_commit_message = True
 
165
 
157
166
    def __init__(self, staging=False):
158
167
        self._staging = staging
159
168
        if staging:
394
403
 
395
404
class LaunchpadBazaarMergeProposalBuilder(MergeProposalBuilder):
396
405
 
397
 
    def __init__(self, lp_host, source_branch, target_branch, message=None,
 
406
    def __init__(self, lp_host, source_branch, target_branch,
398
407
                 staging=None, approve=None, fixes=None):
399
408
        """Constructor.
400
409
 
401
410
        :param source_branch: The branch to propose for merging.
402
411
        :param target_branch: The branch to merge into.
403
 
        :param message: The commit message to use.  (May be None.)
404
412
        :param staging: If True, propose the merge against staging instead of
405
413
            production.
406
414
        :param approve: If True, mark the new proposal as approved immediately.
421
429
            self.target_branch = target_branch
422
430
            self.target_branch_lp = self.launchpad.branches.getByUrl(
423
431
                url=target_branch.user_url)
424
 
        self.commit_message = message
425
432
        self.approve = approve
426
433
        self.fixes = fixes
427
434
 
428
435
    def get_infotext(self):
429
436
        """Determine the initial comment for the merge proposal."""
430
 
        if self.commit_message is not None:
431
 
            return self.commit_message.strip().encode('utf-8')
432
437
        info = ["Source: %s\n" % self.source_branch_lp.bzr_identity]
433
438
        info.append("Target: %s\n" % self.target_branch_lp.bzr_identity)
434
439
        return ''.join(info)
480
485
                             revid=self.source_branch.last_revision())
481
486
 
482
487
    def create_proposal(self, description, reviewers=None, labels=None,
483
 
                        prerequisite_branch=None):
 
488
                        prerequisite_branch=None, commit_message=None):
484
489
        """Perform the submission."""
485
490
        if labels:
486
 
            raise LabelsUnsupported()
 
491
            raise LabelsUnsupported(self)
487
492
        if prerequisite_branch is not None:
488
493
            prereq = self.launchpad.branches.getByUrl(
489
494
                url=prerequisite_branch.user_url)
497
502
                target_branch=self.target_branch_lp,
498
503
                prerequisite_branch=prereq,
499
504
                initial_comment=description.strip(),
500
 
                commit_message=self.commit_message,
 
505
                commit_message=commit_message,
501
506
                reviewers=[self.launchpad.people[reviewer].self_link
502
507
                           for reviewer in reviewers],
503
508
                review_types=[None for reviewer in reviewers])
521
526
 
522
527
class LaunchpadGitMergeProposalBuilder(MergeProposalBuilder):
523
528
 
524
 
    def __init__(self, lp_host, source_branch, target_branch, message=None,
 
529
    def __init__(self, lp_host, source_branch, target_branch,
525
530
                 staging=None, approve=None, fixes=None):
526
531
        """Constructor.
527
532
 
528
533
        :param source_branch: The branch to propose for merging.
529
534
        :param target_branch: The branch to merge into.
530
 
        :param message: The commit message to use.  (May be None.)
531
535
        :param staging: If True, propose the merge against staging instead of
532
536
            production.
533
537
        :param approve: If True, mark the new proposal as approved immediately.
549
553
            self.target_branch = target_branch
550
554
            (self.target_repo_lp, self.target_branch_lp) = (
551
555
                self.lp_host._get_lp_git_ref_from_branch(target_branch))
552
 
        self.commit_message = message
553
556
        self.approve = approve
554
557
        self.fixes = fixes
555
558
 
556
559
    def get_infotext(self):
557
560
        """Determine the initial comment for the merge proposal."""
558
 
        if self.commit_message is not None:
559
 
            return self.commit_message.strip().encode('utf-8')
560
561
        info = ["Source: %s\n" % self.source_branch.user_url]
561
562
        info.append("Target: %s\n" % self.target_branch.user_url)
562
563
        return ''.join(info)
609
610
                revid=self.source_branch.last_revision())
610
611
 
611
612
    def create_proposal(self, description, reviewers=None, labels=None,
612
 
                        prerequisite_branch=None):
 
613
                        prerequisite_branch=None, commit_message=None):
613
614
        """Perform the submission."""
614
615
        if labels:
615
 
            raise LabelsUnsupported()
 
616
            raise LabelsUnsupported(self)
616
617
        if prerequisite_branch is not None:
617
618
            (prereq_repo_lp, prereq_branch_lp) = (
618
619
                self.lp_host._get_lp_git_ref_from_branch(prerequisite_branch))
626
627
                merge_target=self.target_branch_lp,
627
628
                merge_prerequisite=prereq_branch_lp,
628
629
                initial_comment=description.strip(),
629
 
                commit_message=self.commit_message,
 
630
                commit_message=commit_message,
630
631
                needs_review=True,
631
632
                reviewers=[self.launchpad.people[reviewer].self_link
632
633
                           for reviewer in reviewers],