~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-30 18:28:17 UTC
  • mfrom: (5967.10.2 test-cat)
  • Revision ID: pqm@pqm.ubuntu.com-20110630182817-83a5q9r9rxfkdn8r
(mbp) don't use subprocesses for testing cat (Martin Pool)

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
 
 
19
17
from bzrlib import (
20
18
    errors,
21
19
    hooks,
27
25
from bzrlib import (
28
26
    msgeditor,
29
27
    )
30
 
from bzrlib.i18n import gettext
31
28
from bzrlib.plugins.launchpad import (
32
29
    lp_api,
33
30
    lp_registration,
52
49
    hooks = ProposeMergeHooks()
53
50
 
54
51
    def __init__(self, tree, source_branch, target_branch, message, reviews,
55
 
                 staging=False, approve=False, fixes=None):
 
52
                 staging=False, approve=False):
56
53
        """Constructor.
57
54
 
58
55
        :param tree: The working tree for the source branch.
90
87
                            for reviewer, review_type in
91
88
                            reviews]
92
89
        self.approve = approve
93
 
        self.fixes = fixes
94
90
 
95
91
    def get_comment(self, prerequisite_branch):
96
92
        """Determine the initial comment for the merge proposal."""
137
133
            })
138
134
        return body
139
135
 
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
 
 
149
136
    def check_proposal(self):
150
137
        """Check that the submission is sensible."""
151
138
        if self.source_branch.lp.self_link == self.target_branch.lp.self_link:
155
142
            if mp.queue_status in ('Merged', 'Rejected'):
156
143
                continue
157
144
            if mp.target_branch.self_link == self.target_branch.lp.self_link:
158
 
                raise errors.BzrCommandError(gettext(
159
 
                    'There is already a branch merge proposal: %s') %
 
145
                raise errors.BzrCommandError(
 
146
                    'There is already a branch merge proposal: %s' %
160
147
                    lp_api.canonical_url(mp))
161
148
 
162
149
    def _get_prerequisite_branch(self):
189
176
                error_lines.append(line)
190
177
            raise Exception(''.join(error_lines))
191
178
 
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
 
 
201
179
    def create_proposal(self):
202
180
        """Perform the submission."""
203
181
        prerequisite_branch = self._get_prerequisite_branch()
221
199
            commit_message=self.commit_message, reviewers=reviewers,
222
200
            review_types=review_types)
223
201
        if self.approve:
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)])
 
202
            self.call_webservice(mp.setStatus, status='Approved')
231
203
        webbrowser.open(lp_api.canonical_url(mp))
232
204
 
233
205