/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: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

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