~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2012-03-13 17:25:29 UTC
  • mfrom: (6499 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6501.
  • Revision ID: v.ladeuil+lp@free.fr-20120313172529-i0suyjnepsor25i7
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tools for dealing with the Launchpad API."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
# Importing this module will be expensive, since it imports launchpadlib and
20
22
# its dependencies. However, our plan is to only load this module when it is
21
23
# needed by a command that uses it.
33
35
    trace,
34
36
    transport,
35
37
    )
 
38
from bzrlib.i18n import gettext
36
39
from bzrlib.plugins.launchpad.lp_registration import (
37
40
    InvalidLaunchpadInstance,
38
41
    )
134
137
        proxy_info=proxy_info)
135
138
    # XXX: Work-around a minor security bug in launchpadlib 1.5.1, which would
136
139
    # create this directory with default umask.
137
 
    os.chmod(cache_directory, 0700)
 
140
    osutils.chmod_if_possible(cache_directory, 0700)
138
141
    return launchpad
139
142
 
140
143
 
235
238
        """Create a Bazaar branch on Launchpad for the supplied branch."""
236
239
        url = cls.tweak_url(bzr_branch.get_push_location(), launchpad)
237
240
        if not cls.plausible_launchpad_url(url):
238
 
            raise errors.BzrError('%s is not registered on Launchpad' %
 
241
            raise errors.BzrError(gettext('%s is not registered on Launchpad') %
239
242
                                  bzr_branch.base)
240
243
        bzr_branch.create_clone_on_transport(transport.get_transport(url))
241
244
        lp_branch = launchpad.branches.getByUrl(url=url)
242
245
        if lp_branch is None:
243
 
            raise errors.BzrError('%s is not registered on Launchpad' % url)
 
246
            raise errors.BzrError(gettext('%s is not registered on Launchpad') %
 
247
                                                                            url)
244
248
        return lp_branch
245
249
 
246
250
    def get_target(self):
249
253
        if lp_branch.project is not None:
250
254
            dev_focus = lp_branch.project.development_focus
251
255
            if dev_focus is None:
252
 
                raise errors.BzrError('%s has no development focus.' %
 
256
                raise errors.BzrError(gettext('%s has no development focus.') %
253
257
                                  lp_branch.bzr_identity)
254
258
            target = dev_focus.branch
255
259
            if target is None:
256
 
                raise errors.BzrError('development focus %s has no branch.' % dev_focus)
 
260
                raise errors.BzrError(gettext(
 
261
                        'development focus %s has no branch.') % dev_focus)
257
262
        elif lp_branch.sourcepackage is not None:
258
263
            target = lp_branch.sourcepackage.getBranch(pocket="Release")
259
264
            if target is None:
260
 
                raise errors.BzrError('source package %s has no branch.' %
 
265
                raise errors.BzrError(gettext(
 
266
                                      'source package %s has no branch.') %
261
267
                                      lp_branch.sourcepackage)
262
268
        else:
263
 
            raise errors.BzrError('%s has no associated product or source package.' %
 
269
            raise errors.BzrError(gettext(
 
270
                        '%s has no associated product or source package.') %
264
271
                                  lp_branch.bzr_identity)
265
272
        return LaunchpadBranch(target, target.bzr_identity)
266
273
 
272
279
        try:
273
280
            if self.lp.last_scanned_id is not None:
274
281
                if self.bzr.last_revision() == self.lp.last_scanned_id:
275
 
                    trace.note('%s is already up-to-date.' %
 
282
                    trace.note(gettext('%s is already up-to-date.') %
276
283
                               self.lp.bzr_identity)
277
284
                    return
278
285
                graph = self.bzr.repository.get_graph()
279
286
                if not graph.is_ancestor(self.lp.last_scanned_id,
280
287
                                         self.bzr.last_revision()):
281
288
                    raise errors.DivergedBranches(self.bzr, self.push_bzr)
282
 
                trace.note('Pushing to %s' % self.lp.bzr_identity)
 
289
                trace.note(gettext('Pushing to %s') % self.lp.bzr_identity)
283
290
            self.bzr.push(self.push_bzr)
284
291
        finally:
285
292
            self.bzr.unlock()