~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jonathan Lange
  • Date: 2009-12-16 07:35:44 UTC
  • mto: This revision was merged to the branch mainline in revision 4907.
  • Revision ID: jml@canonical.com-20091216073544-uookc486hsmle3pm
Remove the ugly _service hack by using getByUrl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
    # XXX: Work-around a minor security bug in launchpadlib 1.5.1, which would
97
97
    # create this directory with default umask.
98
98
    os.chmod(cache_directory, 0700)
99
 
    # XXX: Why does this set the private member of a class?
100
 
    launchpad._service = service
101
99
    return launchpad
102
100
 
103
101
 
110
108
        `branch`.
111
109
    :return: A launchpadlib Branch object.
112
110
    """
113
 
    # XXX: Why does this need service and _guess_branch_path?
114
 
    service = launchpad._service
 
111
    # XXX: This duplicates the "What are possible URLs for the branch that
 
112
    # Launchpad might recognize" logic found in cmd_lp_open.
 
113
 
 
114
    # XXX: This makes multiple roundtrips to Launchpad for what is
 
115
    # conceptually a single operation -- get me the branches that match these
 
116
    # URLs. Unfortunately, Launchpad's support for such operations is poor, so
 
117
    # we have to allow multiple roundtrips.
115
118
    for url in branch.get_public_branch(), branch.get_push_location():
116
 
        if url is None:
117
 
            continue
118
 
        try:
119
 
            path = service._guess_branch_path(url)
120
 
        except (errors.InvalidURL, NotLaunchpadBranch):
121
 
            pass
122
 
        else:
123
 
            trace.mutter('Guessing path: %s', path)
124
 
            uri = launchpad._root_uri.append(path)
125
 
            uri_str = str(uri)
126
 
            trace.mutter('Guessing url: %s', uri_str)
127
 
            return launchpad.load(uri_str)
 
119
        lp_branch = launchpad.branches.getByUrl(url=url)
 
120
        if lp_branch:
 
121
            return lp_branch
128
122
    raise NotLaunchpadBranch(url)