/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from __future__ import absolute_import
18
18
 
19
 
from ... import (
 
19
from bzrlib import (
20
20
    errors,
21
21
    hooks,
22
22
    )
23
 
from ...lazy_import import lazy_import
 
23
from bzrlib.lazy_import import lazy_import
24
24
lazy_import(globals(), """
25
25
import webbrowser
26
26
 
27
 
from breezy import (
 
27
from bzrlib import (
28
28
    msgeditor,
29
29
    )
30
 
from breezy.i18n import gettext
31
 
from breezy.plugins.launchpad import (
 
30
from bzrlib.i18n import gettext
 
31
from bzrlib.plugins.launchpad import (
32
32
    lp_api,
33
33
    lp_registration,
34
34
    )
39
39
    """Hooks for proposing a merge on Launchpad."""
40
40
 
41
41
    def __init__(self):
42
 
        hooks.Hooks.__init__(self, "breezy.plugins.launchpad.lp_propose",
 
42
        hooks.Hooks.__init__(self, "bzrlib.plugins.launchpad.lp_propose",
43
43
            "Proposer.hooks")
44
44
        self.add_hook('get_prerequisite',
45
45
            "Return the prerequisite branch for proposing as merge.", (2, 1))
94
94
 
95
95
    def get_comment(self, prerequisite_branch):
96
96
        """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
97
        info = ["Source: %s\n" % self.source_branch.lp.bzr_identity]
100
98
        info.append("Target: %s\n" % self.target_branch.lp.bzr_identity)
101
99
        if prerequisite_branch is not None:
103
101
        for rdata in self.reviews:
104
102
            uniquename = "%s (%s)" % (rdata[0].display_name, rdata[0].name)
105
103
            info.append('Reviewer: %s, type "%s"\n' % (uniquename, rdata[1]))
106
 
        with self.source_branch.bzr.lock_read(), \
107
 
                self.target_branch.bzr.lock_read():
108
 
            body = self.get_initial_body()
 
104
        self.source_branch.bzr.lock_read()
 
105
        try:
 
106
            self.target_branch.bzr.lock_read()
 
107
            try:
 
108
                body = self.get_initial_body()
 
109
            finally:
 
110
                self.target_branch.bzr.unlock()
 
111
        finally:
 
112
            self.source_branch.bzr.unlock()
109
113
        initial_comment = msgeditor.edit_commit_message(''.join(info),
110
114
                                                        start_message=body)
111
115
        return initial_comment.strip().encode('utf-8')
136
140
    def get_source_revid(self):
137
141
        """Get the revision ID of the source branch."""
138
142
        source_branch = self.source_branch.bzr
139
 
        with source_branch.lock_read():
 
143
        source_branch.lock_read()
 
144
        try:
140
145
            return source_branch.last_revision()
 
146
        finally:
 
147
            source_branch.unlock()
141
148
 
142
149
    def check_proposal(self):
143
150
        """Check that the submission is sensible."""
174
181
        from lazr.restfulclient import errors as restful_errors
175
182
        try:
176
183
            return call(*args, **kwargs)
177
 
        except restful_errors.HTTPError as e:
 
184
        except restful_errors.HTTPError, e:
178
185
            error_lines = []
179
186
            for line in e.content.splitlines():
180
187
                if line.startswith('Traceback (most recent call last):'):