/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 breezy/plugins/launchpad/lp_propose.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

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 ... import (
20
18
    errors,
21
19
    hooks,
30
28
from breezy.i18n import gettext
31
29
from breezy.plugins.launchpad import (
32
30
    lp_api,
33
 
    lp_registration,
34
31
    )
35
32
""")
36
33
 
40
37
 
41
38
    def __init__(self):
42
39
        hooks.Hooks.__init__(self, "breezy.plugins.launchpad.lp_propose",
43
 
            "Proposer.hooks")
 
40
                             "Proposer.hooks")
44
41
        self.add_hook('get_prerequisite',
45
 
            "Return the prerequisite branch for proposing as merge.", (2, 1))
 
42
                      "Return the prerequisite branch for proposing as merge.", (2, 1))
46
43
        self.add_hook('merge_proposal_body',
47
 
            "Return an initial body for the merge proposal message.", (2, 1))
 
44
                      "Return an initial body for the merge proposal message.", (2, 1))
48
45
 
49
46
 
50
47
class Proposer(object):
69
66
        """
70
67
        self.tree = tree
71
68
        if staging:
72
 
            lp_instance = 'staging'
 
69
            lp_base_url = lp_api.uris.STAGING_SERVICE_ROOT
73
70
        else:
74
 
            lp_instance = 'production'
75
 
        service = lp_registration.LaunchpadService(lp_instance=lp_instance)
76
 
        self.launchpad = lp_api.login(service)
 
71
            lp_base_url = lp_api.uris.LPNET_SERVICE_ROOT
 
72
        self.launchpad = lp_api.connect_launchpad(lp_base_url)
77
73
        self.source_branch = lp_api.LaunchpadBranch.from_bzr(
78
74
            self.launchpad, source_branch)
79
75
        if target_branch is None:
122
118
            files = modified_files(lca_tree, source_tree)
123
119
            return list(files)
124
120
        target_loc = ('bzr+ssh://bazaar.launchpad.net/%s' %
125
 
                       self.target_branch.lp.unique_name)
 
121
                      self.target_branch.lp.unique_name)
126
122
        body = None
127
123
        for hook in self.hooks['merge_proposal_body']:
128
124
            body = hook({
165
161
 
166
162
    def call_webservice(self, call, *args, **kwargs):
167
163
        """Make a call to the webservice, wrapping failures.
168
 
        
 
164
 
169
165
        :param call: The call to make.
170
166
        :param *args: *args for the call.
171
167
        :param **kwargs: **kwargs for the call.
187
183
        self.call_webservice(
188
184
            mp.createComment,
189
185
            vote=u'Approve',
190
 
            subject='', # Use the default subject.
 
186
            subject='',  # Use the default subject.
191
187
            content=u"Rubberstamp! Proposer approves of own proposal.")
192
188
        self.call_webservice(mp.setStatus, status=u'Approved', revid=revid)
193
189
 
226
222
 
227
223
def modified_files(old_tree, new_tree):
228
224
    """Return a list of paths in the new tree with modified contents."""
229
 
    for f, (op, path), c, v, p, n, (ok, k), e in new_tree.iter_changes(
230
 
        old_tree):
231
 
        if c and k == 'file':
 
225
    for change in new_tree.iter_changes(old_tree):
 
226
        if change.changed_content and change.kind[1] == 'file':
232
227
            yield str(path)