~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: 2012-10-25 11:13:27 UTC
  • mfrom: (6570.1.6 rubberstamp)
  • Revision ID: pqm@pqm.ubuntu.com-20121025111327-p0ylql0nh9fla0rs
(gz) Set approved revision and vote "Approve" when using lp-propose
 --approve (Jonathan Lange)

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
            })
138
138
        return body
139
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
 
140
149
    def check_proposal(self):
141
150
        """Check that the submission is sensible."""
142
151
        if self.source_branch.lp.self_link == self.target_branch.lp.self_link:
180
189
                error_lines.append(line)
181
190
            raise Exception(''.join(error_lines))
182
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
 
183
201
    def create_proposal(self):
184
202
        """Perform the submission."""
185
203
        prerequisite_branch = self._get_prerequisite_branch()
203
221
            commit_message=self.commit_message, reviewers=reviewers,
204
222
            review_types=review_types)
205
223
        if self.approve:
206
 
            self.call_webservice(mp.setStatus, status='Approved')
 
224
            self.approve_proposal(mp)
207
225
        if self.fixes:
208
226
            if self.fixes.startswith('lp:'):
209
227
                self.fixes = self.fixes[3:]