~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/lp_propose.py

  • Committer: Patch Queue Manager
  • Date: 2015-12-17 18:39:00 UTC
  • mfrom: (6606.1.2 fix-float)
  • Revision ID: pqm@pqm.ubuntu.com-20151217183900-0719du2uv1kwu3lc
(vila) Inline testtools private method to fix an issue in xenial (the
 private implementation has changed in an backward incompatible way).
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
from bzrlib import (
18
20
    errors,
19
21
    hooks,
25
27
from bzrlib import (
26
28
    msgeditor,
27
29
    )
 
30
from bzrlib.i18n import gettext
28
31
from bzrlib.plugins.launchpad import (
29
32
    lp_api,
30
33
    lp_registration,
49
52
    hooks = ProposeMergeHooks()
50
53
 
51
54
    def __init__(self, tree, source_branch, target_branch, message, reviews,
52
 
                 staging=False, approve=False):
 
55
                 staging=False, approve=False, fixes=None):
53
56
        """Constructor.
54
57
 
55
58
        :param tree: The working tree for the source branch.
87
90
                            for reviewer, review_type in
88
91
                            reviews]
89
92
        self.approve = approve
 
93
        self.fixes = fixes
90
94
 
91
95
    def get_comment(self, prerequisite_branch):
92
96
        """Determine the initial comment for the merge proposal."""
133
137
            })
134
138
        return body
135
139
 
 
140
    def get_source_revid(self):
 
141
        """Get the revision ID of the source branch."""
 
142
        source_branch = self.source_branch.bzr
 
143
        source_branch.lock_read()
 
144
        try:
 
145
            return source_branch.last_revision()
 
146
        finally:
 
147
            source_branch.unlock()
 
148
 
136
149
    def check_proposal(self):
137
150
        """Check that the submission is sensible."""
138
151
        if self.source_branch.lp.self_link == self.target_branch.lp.self_link:
176
189
                error_lines.append(line)
177
190
            raise Exception(''.join(error_lines))
178
191
 
 
192
    def approve_proposal(self, mp):
 
193
        revid = self.get_source_revid()
 
194
        self.call_webservice(
 
195
            mp.createComment,
 
196
            vote=u'Approve',
 
197
            subject='', # Use the default subject.
 
198
            content=u"Rubberstamp! Proposer approves of own proposal.")
 
199
        self.call_webservice(mp.setStatus, status=u'Approved', revid=revid)
 
200
 
179
201
    def create_proposal(self):
180
202
        """Perform the submission."""
181
203
        prerequisite_branch = self._get_prerequisite_branch()
199
221
            commit_message=self.commit_message, reviewers=reviewers,
200
222
            review_types=review_types)
201
223
        if self.approve:
202
 
            self.call_webservice(mp.setStatus, status='Approved')
 
224
            self.approve_proposal(mp)
 
225
        if self.fixes:
 
226
            if self.fixes.startswith('lp:'):
 
227
                self.fixes = self.fixes[3:]
 
228
            self.call_webservice(
 
229
                self.source_branch.lp.linkBug,
 
230
                bug=self.launchpad.bugs[int(self.fixes)])
203
231
        webbrowser.open(lp_api.canonical_url(mp))
204
232
 
205
233