~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jonathan Lange
  • Date: 2009-07-04 09:29:51 UTC
  • mto: This revision was merged to the branch mainline in revision 4907.
  • Revision ID: jml@canonical.com-20090704092951-naw45aq6vgog5znl
Add a command to mirror Launchpad branches now.
Add an API for dealing with the Launchpad API.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    NotLaunchpadBranch,
49
49
    )
50
50
 
 
51
try:
 
52
    from bzrlib.plugins.launchpad import lp_api
 
53
except ImportError:
 
54
    lp_api = None
 
55
 
51
56
 
52
57
class cmd_register_branch(Command):
53
58
    """Register a branch with launchpad.net.
246
251
register_command(cmd_launchpad_login)
247
252
 
248
253
 
 
254
class cmd_launchpad_mirror(Command):
 
255
    """Ask Launchpad to mirror a branch now."""
 
256
 
 
257
    aliases = ['lp-mirror']
 
258
    takes_args = ['location?']
 
259
 
 
260
    def run(self, location='.'):
 
261
        service = LaunchpadService()
 
262
        launchpad = lp_api.login(service)
 
263
        branch = _mod_branch.Branch.open(location)
 
264
        lp_branch = lp_api.load_branch(launchpad, branch)
 
265
        lp_branch.requestMirror()
 
266
 
 
267
 
 
268
if lp_api is not None:
 
269
    register_command(cmd_launchpad_mirror)
 
270
 
 
271
 
249
272
def _register_directory():
250
273
    directories.register_lazy('lp:', 'bzrlib.plugins.launchpad.lp_directory',
251
274
                              'LaunchpadDirectory',