~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2013-05-27 10:22:27 UTC
  • mfrom: (6571.2.1 cmdline-empty-quotes)
  • mto: This revision was merged to the branch mainline in revision 6578.
  • Revision ID: v.ladeuil+lp@free.fr-20130527102227-qfc5dwoz41j5fk1z
Finish cleanup including merging original Ross fix

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
    hooks = ProposeMergeHooks()
53
53
 
54
54
    def __init__(self, tree, source_branch, target_branch, message, reviews,
55
 
                 staging=False, approve=False):
 
55
                 staging=False, approve=False, fixes=None):
56
56
        """Constructor.
57
57
 
58
58
        :param tree: The working tree for the source branch.
90
90
                            for reviewer, review_type in
91
91
                            reviews]
92
92
        self.approve = approve
 
93
        self.fixes = fixes
93
94
 
94
95
    def get_comment(self, prerequisite_branch):
95
96
        """Determine the initial comment for the merge proposal."""
136
137
            })
137
138
        return body
138
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
 
139
149
    def check_proposal(self):
140
150
        """Check that the submission is sensible."""
141
151
        if self.source_branch.lp.self_link == self.target_branch.lp.self_link:
179
189
                error_lines.append(line)
180
190
            raise Exception(''.join(error_lines))
181
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
 
182
201
    def create_proposal(self):
183
202
        """Perform the submission."""
184
203
        prerequisite_branch = self._get_prerequisite_branch()
202
221
            commit_message=self.commit_message, reviewers=reviewers,
203
222
            review_types=review_types)
204
223
        if self.approve:
205
 
            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)])
206
231
        webbrowser.open(lp_api.canonical_url(mp))
207
232
 
208
233