~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-05-18 13:02:52 UTC
  • mfrom: (5830.3.6 i18n-msgfmt)
  • Revision ID: pqm@pqm.ubuntu.com-20110518130252-ky96qcvzt6o0zg3f
(mbp) add build_mo command to setup.py (INADA Naoki)

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."""
97
 
        if self.commit_message is not None:
98
 
            return self.commit_message.strip().encode('utf-8')
99
93
        info = ["Source: %s\n" % self.source_branch.lp.bzr_identity]
100
94
        info.append("Target: %s\n" % self.target_branch.lp.bzr_identity)
101
95
        if prerequisite_branch is not None:
139
133
            })
140
134
        return body
141
135
 
142
 
    def get_source_revid(self):
143
 
        """Get the revision ID of the source branch."""
144
 
        source_branch = self.source_branch.bzr
145
 
        source_branch.lock_read()
146
 
        try:
147
 
            return source_branch.last_revision()
148
 
        finally:
149
 
            source_branch.unlock()
150
 
 
151
136
    def check_proposal(self):
152
137
        """Check that the submission is sensible."""
153
138
        if self.source_branch.lp.self_link == self.target_branch.lp.self_link:
157
142
            if mp.queue_status in ('Merged', 'Rejected'):
158
143
                continue
159
144
            if mp.target_branch.self_link == self.target_branch.lp.self_link:
160
 
                raise errors.BzrCommandError(gettext(
161
 
                    'There is already a branch merge proposal: %s') %
 
145
                raise errors.BzrCommandError(
 
146
                    'There is already a branch merge proposal: %s' %
162
147
                    lp_api.canonical_url(mp))
163
148
 
164
149
    def _get_prerequisite_branch(self):
191
176
                error_lines.append(line)
192
177
            raise Exception(''.join(error_lines))
193
178
 
194
 
    def approve_proposal(self, mp):
195
 
        revid = self.get_source_revid()
196
 
        self.call_webservice(
197
 
            mp.createComment,
198
 
            vote=u'Approve',
199
 
            subject='', # Use the default subject.
200
 
            content=u"Rubberstamp! Proposer approves of own proposal.")
201
 
        self.call_webservice(mp.setStatus, status=u'Approved', revid=revid)
202
 
 
203
179
    def create_proposal(self):
204
180
        """Perform the submission."""
205
181
        prerequisite_branch = self._get_prerequisite_branch()
223
199
            commit_message=self.commit_message, reviewers=reviewers,
224
200
            review_types=review_types)
225
201
        if self.approve:
226
 
            self.approve_proposal(mp)
227
 
        if self.fixes:
228
 
            if self.fixes.startswith('lp:'):
229
 
                self.fixes = self.fixes[3:]
230
 
            self.call_webservice(
231
 
                self.source_branch.lp.linkBug,
232
 
                bug=self.launchpad.bugs[int(self.fixes)])
 
202
            self.call_webservice(mp.setStatus, status='Approved')
233
203
        webbrowser.open(lp_api.canonical_url(mp))
234
204
 
235
205