~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-02-11 11:49:25 UTC
  • mfrom: (5657.1.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20110211114925-r8vawh0c4vlf2tfo
(jelmer) Fix ``bzr lp-mirror`` to work on command line branch URLs and
 branches without an explicit public location. (Max Bowsher)

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    )
36
36
from bzrlib.plugins.launchpad.lp_registration import (
37
37
    InvalidLaunchpadInstance,
38
 
    NotLaunchpadBranch,
39
38
    )
40
39
 
41
40
try:
197
196
        url = bzr_branch.get_push_location()
198
197
        if url is not None:
199
198
            yield url
 
199
        url = bzr_branch.get_parent()
 
200
        if url is not None:
 
201
            yield url
200
202
        yield bzr_branch.base
201
203
 
202
204
    @staticmethod
294
296
        return self.bzr.repository.revision_tree(lca)
295
297
 
296
298
 
297
 
def load_branch(launchpad, branch):
298
 
    """Return the launchpadlib Branch object corresponding to 'branch'.
299
 
 
300
 
    :param launchpad: The root `Launchpad` object from launchpadlib.
301
 
    :param branch: A `bzrlib.branch.Branch`.
302
 
    :raise NotLaunchpadBranch: If we cannot determine the Launchpad URL of
303
 
        `branch`.
304
 
    :return: A launchpadlib Branch object.
305
 
    """
306
 
    # XXX: This duplicates the "What are possible URLs for the branch that
307
 
    # Launchpad might recognize" logic found in cmd_lp_open.
308
 
 
309
 
    # XXX: This makes multiple roundtrips to Launchpad for what is
310
 
    # conceptually a single operation -- get me the branches that match these
311
 
    # URLs. Unfortunately, Launchpad's support for such operations is poor, so
312
 
    # we have to allow multiple roundtrips.
313
 
    for url in branch.get_public_branch(), branch.get_push_location():
314
 
        lp_branch = launchpad.branches.getByUrl(url=url)
315
 
        if lp_branch:
316
 
            return lp_branch
317
 
    raise NotLaunchpadBranch(url)
318
 
 
319
 
 
320
299
def canonical_url(object):
321
300
    """Return the canonical URL for a branch."""
322
301
    scheme, netloc, path, params, query, fragment = urlparse.urlparse(