/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: 2019-05-29 03:22:34 UTC
  • mfrom: (7303 work)
  • mto: This revision was merged to the branch mainline in revision 7306.
  • Revision ID: jelmer@jelmer.uk-20190529032234-mt3fuws8gq03tapi
Merge trunk.

Show diffs side-by-side

added added

removed removed

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