Merge lp:~barry/bzr/609186-shortcuts into lp:bzr

Proposed by Barry Warsaw
Status: Merged
Merged at revision: 5486
Proposed branch: lp:~barry/bzr/609186-shortcuts
Merge into: lp:bzr
Diff against target: 374 lines (+276/-9)
5 files modified
NEWS (+7/-0)
bzrlib/plugins/launchpad/__init__.py (+9/-0)
bzrlib/plugins/launchpad/lp_directory.py (+47/-1)
bzrlib/plugins/launchpad/test_lp_directory.py (+178/-8)
doc/en/tutorials/using_bazaar_with_launchpad.txt (+35/-0)
To merge this branch: bzr merge lp:~barry/bzr/609186-shortcuts
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Martin Pool Needs Fixing
John A Meinel Approve
Review via email: mp+37787@code.launchpad.net

Description of the change

Add ubuntu: and debianlp: shortcuts.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

some comments, I didn't look closely:

1) Isn't 'n' already known? (natty). I realize you can't push to it, but might as well have it for future.
2) I thought having the short forms was quite useful. "u:foo" is very nice and succinct. Any way we could (potentially via configuration) keep that? The whole point of having "lp:bzr" is because how much you have to type really does matter. lp:ubuntu/maverick/bzr is a whole lot wordier than u:bzr or u:m/bzr

Revision history for this message
Martin Pool (mbp) wrote :

Having the names hardcoded into bzr is a bit ugly (though it may be
the best tradeoff.)

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On Wed, 2010-10-06 at 20:59 +0000, John A Meinel wrote:
> some comments, I didn't look closely:
>
> 1) Isn't 'n' already known? (natty). I realize you can't push to it, but might as well have it for future.
Would it perhaps be possible to have a set of shortcuts available but
not limit the possible names in general? I can imagine a dictionary like
this:

k: karmic,
l: lucid,
m: maverick

That way it will still be possible to check out ubuntu:natty/foo when
natty is opened and you're using an older version of bzr, you just won't
be able to use ubuntu:n/foo. It also means we don't have to get the list
of hardcoded names in bzr completely right.

> 2) I thought having the short forms was quite useful. "u:foo" is very
> nice and succinct. Any way we could (potentially via configuration)
> keep that? The whole point of having "lp:bzr" is because how much you
> have to type really does matter. lp:ubuntu/maverick/bzr is a whole lot
> wordier than u:bzr or u:m/bzr
I think "ubuntu:foo" is much clearer than "u:foo" or, for that matter,
"lp:ubuntu/maverick/foo" while not being that much more effort to type.

Cheers,

Jelmer

Revision history for this message
Vincent Ladeuil (vila) wrote :

>>>>> Jelmer Vernooij <email address hidden> writes:

    > On Wed, 2010-10-06 at 20:59 +0000, John A Meinel wrote:
    >> some comments, I didn't look closely:
    >>
    >> 1) Isn't 'n' already known? (natty). I realize you can't push to it, but might as well have it for future.
    > Would it perhaps be possible to have a set of shortcuts available but
    > not limit the possible names in general? I can imagine a dictionary like
    > this:

    > k: karmic,
    > l: lucid,
    > m: maverick

    > That way it will still be possible to check out ubuntu:natty/foo when
    > natty is opened and you're using an older version of bzr, you just won't
    > be able to use ubuntu:n/foo. It also means we don't have to get the list
    > of hardcoded names in bzr completely right.

+1

Also, how would this interact with drives on windows ? Should we use two
letters shortcuts instead ?

ka: karmic,
lu: lucid,

etc

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On Thu, 2010-10-07 at 09:00 -0500, John Arbash Meinel wrote:
> >> 2) I thought having the short forms was quite useful. "u:foo" is very
> >> nice and succinct. Any way we could (potentially via configuration)
> >> keep that? The whole point of having "lp:bzr" is because how much you
> >> have to type really does matter. lp:ubuntu/maverick/bzr is a whole lot
> >> wordier than u:bzr or u:m/bzr
> > I think "ubuntu:foo" is much clearer than "u:foo" or, for that matter,
> > "lp:ubuntu/maverick/foo" while not being that much more effort to type.
> Well, we don't call it "launchpad:" for a reason. We've had several
> people ask us to support "ssh:" rather than "bzr+ssh:" because it is (at
> least mentally) an overhead that seems redundant.

> I would like to see a config that would allow the short form (disabled
> by default if you prefer).

> I completely agree that "ubuntu:foo" is *clearer*, but the "not much
> more effort" is actually where I disagree. (In the absolute sense, yes,
> in the "hey this tool just does what I want without a lot of effort"
> sense, no)
I agree there's a tradeoff between readability and effort there. lp: is
an acceptable balance imo; I think having l: would be a step too far.
"bzr l l:bzr" might be short, it's also ambiguous and unreadable (does
it mean "bzr ls linaro:bzr"¸ "bzr log launchpad:bzr", ?)

I would favor a conf option to support ta short form (perhaps just a
generic mechanism alias mechanism for locations?).

Cheers,

Jelmer

Revision history for this message
John A Meinel (jameinel) wrote :

1) I think the code would be ok to land as is. We can always improve it more later.
2) To get the short form, I think you would have to always register it, and then at runtime you could see "oh, I've been disabled, fall back to the regular methods".
3) 79 + path_parts = result.path.split('/')
80 + series = distro_series.get(path_parts[0])
81 + # If there's a series, then the project name is the second part of
82 + # the path. Otherwise, it's the latest series as defined by
83 + # Launchpad.
84 + if series is None:
85 + lp_url_template = 'lp:%(distro)s/%(project)s'
86 + project = path_parts[0]
87 + else:
88 + lp_url_template = 'lp:%(distro)s/%(series)s/%(project)s'
89 + project = path_parts[1]

You throw away path parts you don't understand. For example:

  ubuntu:unknown_series/project

Why not just count the path parts instead? So you can do:

path_parts = result.path.split('/')
if len(path_parts) == 1:
 # just a project
 project = path_parts[0]
 series = None
 lp_url_template = "lp:%(distro)s/%(project)s
elif len(path_parts) == 2:
 series, project = path_parts
 lp_url_template = "lp:%(distro)s/%(series)s/%(project)s
 # [1]
else:
 # error, either 0 or >2 parts

I think the code was written this way, because you wanted to expand "m" =>
"maverick". However you could still do that at [1]. Specifically, just do:

series = _short_name_series.get(series, series)

So if the series is a known-registered value (like 'n') then it would expand to
the full value. Otherwise it falls back to the existing value (for natty, for
"o", etc.)

review: Approve
Revision history for this message
Barry Warsaw (barry) wrote :

On Oct 06, 2010, at 08:59 PM, John A Meinel wrote:

>1) Isn't 'n' already known? (natty). I realize you can't push to it,
>but might as well have it for future.

Good point. Added.

>2) I thought having the short forms was quite useful. "u:foo" is very nice
>and succinct. Any way we could (potentially via configuration) keep that? The
>whole point of having "lp:bzr" is because how much you have to type really
>does matter. lp:ubuntu/maverick/bzr is a whole lot wordier than u:bzr or
>u:m/bzr

A couple of thoughts (I agree, I like the shortcuts too :).

We could support shortcut for the distroseries name independently of the
distro name, thus giving us urls like:

    ubuntu:m/bzr
    ubuntu:n/bzr
    debianlp:l/foo
    debianlp:s/foo

I think it's pretty common to refer to Ubuntu releases by their first letter;
maybe the same is not common for Debian. Anyway 'ubuntu:n/bzr' seems okay to
me, though I still would not oppose adding u: and d: shortcuts.

Either distro or distroseries shortcuts would be easy to add (using the
hard-coded mappings). How do we decide whether to add them back or not?

Revision history for this message
Barry Warsaw (barry) wrote :

On Oct 07, 2010, at 04:43 PM, John A Meinel wrote:

>1) I think the code would be ok to land as is. We can always improve it more
>later.

Sounds good.

>2) To get the short form, I think you would have to always register it, and
>then at runtime you could see "oh, I've been disabled, fall back to the
>regular methods".

True for the scheme part, but I think we'd have to handle shortcuts in the
distroseries a little differently.

My preference would be to include Ubuntu distroseries shortcuts out of the box
- I don't think we need to disable them or add a config to handle this. Let's
not include shortcuts for Debian distroseries; these are much more rare and I
don't think Debian has quite the same history of abbreviating their releases
to just the first character (i.e. they don't use an alphabetical naming
scheme).

I think I'll add back the Ubuntu distroseries abbreviations, and see if there
is a huge outrage about them. ;)

As for shortcuts in the scheme (i.e. u: and d:), it might be better to write a
generic url rewriting plugin. Or maybe bzr-bookmarks is good enough?

>3) 79 + path_parts = result.path.split('/')
>80 + series = distro_series.get(path_parts[0])
>81 + # If there's a series, then the project name is the second part of
>82 + # the path. Otherwise, it's the latest series as defined by
>83 + # Launchpad.
>84 + if series is None:
>85 + lp_url_template = 'lp:%(distro)s/%(project)s'
>86 + project = path_parts[0]
>87 + else:
>88 + lp_url_template = 'lp:%(distro)s/%(series)s/%(project)s'
>89 + project = path_parts[1]
>
>You throw away path parts you don't understand. For example:
>
> ubuntu:unknown_series/project
>
>Why not just count the path parts instead? So you can do:
>
>path_parts = result.path.split('/')
>if len(path_parts) == 1:
> # just a project
> project = path_parts[0]
> series = None
> lp_url_template = "lp:%(distro)s/%(project)s
>elif len(path_parts) == 2:
> series, project = path_parts
> lp_url_template = "lp:%(distro)s/%(series)s/%(project)s
> # [1]
>else:
> # error, either 0 or >2 parts
>
>I think the code was written this way, because you wanted to expand "m" =>
>"maverick". However you could still do that at [1]. Specifically, just do:
>
>series = _short_name_series.get(series, series)
>
>So if the series is a known-registered value (like 'n') then it would expand to
>the full value. Otherwise it falls back to the existing value (for natty, for
>"o", etc.)

Good idea. Done.

Pushing a new version soon. BTW, I fixed some pyflakes complaints while I was
at it.

Revision history for this message
Barry Warsaw (barry) wrote :

On Oct 07, 2010, at 02:49 PM, Jelmer Vernooij wrote:

>> I would like to see a config that would allow the short form (disabled
>> by default if you prefer).
>
>> I completely agree that "ubuntu:foo" is *clearer*, but the "not much
>> more effort" is actually where I disagree. (In the absolute sense, yes,
>> in the "hey this tool just does what I want without a lot of effort"
>> sense, no)
>I agree there's a tradeoff between readability and effort there. lp: is
>an acceptable balance imo; I think having l: would be a step too far.
>"bzr l l:bzr" might be short, it's also ambiguous and unreadable (does
>it mean "bzr ls linaro:bzr"¸ "bzr log launchpad:bzr", ?)
>
>I would favor a conf option to support ta short form (perhaps just a
>generic mechanism alias mechanism for locations?).

After thinking about this more, requiring ubuntu: and not having a distro
shortcut seems fine. Adding back the Ubuntu (but not Debian!) distroseries
shortcuts seem like a win - Ubuntu has a tradition of referring to releases by
their first letter. Thus we support:

ubuntu:foo
ubuntu:maverick/foo
ubuntu:m/foo

I think this is as far as I want to go with the branch. I'd favor a generic
alias mechanism for locations, though that's out of scope for this particular
branch. There is also bzr-bookmarks which might fit the bill. My inclination
is to go with this compromise and wait for feedback from users.

Revision history for this message
Barry Warsaw (barry) wrote :

On Oct 07, 2010, at 09:52 AM, Jelmer Vernooij wrote:

>On Wed, 2010-10-06 at 20:59 +0000, John A Meinel wrote:
>> some comments, I didn't look closely:
>>
>> 1) Isn't 'n' already known? (natty). I realize you can't push to it, but might as well have it for future.
>Would it perhaps be possible to have a set of shortcuts available but
>not limit the possible names in general? I can imagine a dictionary like
>this:
>
>k: karmic,
>l: lucid,
>m: maverick
>
>That way it will still be possible to check out ubuntu:natty/foo when
>natty is opened and you're using an older version of bzr, you just won't
>be able to use ubuntu:n/foo. It also means we don't have to get the list
>of hardcoded names in bzr completely right.

With other changes suggested by JAM, this is what the branch will do now.
When Obscene Otter is opened, you'll be able to branch ubuntu:obscene/foo but
not ubuntu:o/foo (at least until a Bazaar update is issued). This seems like
a decent compromise.

Note that I did consider downloading the distroseries from Launchpad, but
since they change very infrequently, I didn't want to pay the penalty to do
this every time. We could of course cache this, but then how often do we
update the cache? Given the change above, a new distroseries is still
basically supported, just the shortcut is not. Seems good enough to me, for
now anyway.

Revision history for this message
Barry Warsaw (barry) wrote :

On Oct 07, 2010, at 11:24 AM, Vincent Ladeuil wrote:

>Also, how would this interact with drives on windows ? Should we use two
>letters shortcuts instead ?
>
>ka: karmic,
>lu: lucid,

Are you worried about interference with the scheme part? That will always be
ubuntu: or debianlp: so I don't think we have any possible collisions with the
distroseries name. It might be an argument against u: and d: but for now
we're not going to support that.

Revision history for this message
Martin Pool (mbp) wrote :

You should mention the short form in the documentation.

If the series are defined in here only for the sake of abbreviations, maybe you can delete the 'natty: natty' entries? Saying we know about certain abbreviations is cleaner for me than saying we know about all series. Probably that should be done on the server, but it's a bit harder to change that than to change bzr.

Just as a style point (and you don't have to change it now) I would have defined a helper method to do the check rather than copy&pasting

 def test_debian_default_distroseries_expansion(self):
322 + factory = self._make_factory(package='foo', distro='debian')
323 + self.assertEqual(
324 + 'http://bazaar.launchpad.net/~branch/debian/foo',
325 + self.directory._resolve('debianlp:foo', factory))

Instead something like

  self.checkExpansion('foo', 'debian', 'debianlp:foo', 'http://bazaar.launchpad.net/~branch/debian/foo')
325 + self.directory._resolve('debianlp:foo',

review: Needs Fixing
Revision history for this message
Barry Warsaw (barry) wrote :

On Oct 07, 2010, at 09:49 PM, Martin Pool wrote:

>Review: Needs Fixing
>You should mention the short form in the documentation.

Actually done, but in a following revision (which should be pushed now).

>If the series are defined in here only for the sake of abbreviations, maybe
>you can delete the 'natty: natty' entries? Saying we know about certain
>abbreviations is cleaner for me than saying we know about all series.
>Probably that should be done on the server, but it's a bit harder to change
>that than to change bzr.

Actually, we don't need any of the 'series: series' entries now, so I've
simplified the code. Pushed in r5467.

>Just as a style point (and you don't have to change it now) I would have
>defined a helper method to do the check rather than copy&pasting
>
> def test_debian_default_distroseries_expansion(self):
>322 + factory = self._make_factory(package='foo', distro='debian')
>323 + self.assertEqual(
>324 + 'http://bazaar.launchpad.net/~branch/debian/foo',
>325 + self.directory._resolve('debianlp:foo', factory))
>
>
>Instead something like
>
> self.checkExpansion('foo', 'debian', 'debianlp:foo', 'http://bazaar.launchpad.net/~branch/debian/foo')
>325 + self.directory._resolve('debianlp:foo',

Thanks. Not changed for now.

-Barry

Revision history for this message
Vincent Ladeuil (vila) wrote :

Very nice addition, I've added a helper and will land the result.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2010-10-07 12:45:51 +0000
+++ NEWS 2010-10-07 22:03:45 +0000
@@ -21,6 +21,13 @@
21New Features21New Features
22************22************
2323
24* New shortcut url schemes ``ubuntu:`` and ``debianlp:`` access source
25 branches on Launchpad. E.g. ``bzr branch ubuntu:foo`` gives you the source
26 branch for project ``foo`` in the current distroseries for Ubuntu while
27 ``bzr branch debianlp:lenny/foo`` gives you the source branch (on Launchpad)
28 for project ``foo`` in Debian Lenny.
29 (Barry Warsaw, #609186)
30
24* Add ``mainline`` revision specifier, which selects the revision that31* Add ``mainline`` revision specifier, which selects the revision that
25 merged a specified revision into the mainline. (Aaron Bentley)32 merged a specified revision into the mainline. (Aaron Bentley)
2633
2734
=== modified file 'bzrlib/plugins/launchpad/__init__.py'
--- bzrlib/plugins/launchpad/__init__.py 2010-10-05 15:52:15 +0000
+++ bzrlib/plugins/launchpad/__init__.py 2010-10-07 22:03:45 +0000
@@ -371,6 +371,15 @@
371 directories.register_lazy('lp:', 'bzrlib.plugins.launchpad.lp_directory',371 directories.register_lazy('lp:', 'bzrlib.plugins.launchpad.lp_directory',
372 'LaunchpadDirectory',372 'LaunchpadDirectory',
373 'Launchpad-based directory service',)373 'Launchpad-based directory service',)
374 directories.register_lazy(
375 'debianlp:', 'bzrlib.plugins.launchpad.lp_directory',
376 'LaunchpadDirectory',
377 'debianlp: shortcut')
378 directories.register_lazy(
379 'ubuntu:', 'bzrlib.plugins.launchpad.lp_directory',
380 'LaunchpadDirectory',
381 'ubuntu: shortcut')
382
374_register_directory()383_register_directory()
375384
376385
377386
=== modified file 'bzrlib/plugins/launchpad/lp_directory.py'
--- bzrlib/plugins/launchpad/lp_directory.py 2010-07-26 17:19:33 +0000
+++ bzrlib/plugins/launchpad/lp_directory.py 2010-10-07 22:03:45 +0000
@@ -40,6 +40,16 @@
40register_urlparse_netloc_protocol('bzr+ssh')40register_urlparse_netloc_protocol('bzr+ssh')
41register_urlparse_netloc_protocol('lp')41register_urlparse_netloc_protocol('lp')
4242
43_ubuntu_series_shortcuts = {
44 'n': 'natty',
45 'm': 'maverick',
46 'l': 'lucid',
47 'k': 'karmic',
48 'j': 'jaunty',
49 'h': 'hardy',
50 'd': 'dapper',
51 }
52
4353
44class LaunchpadDirectory(object):54class LaunchpadDirectory(object):
4555
@@ -62,8 +72,44 @@
62 _request_factory=ResolveLaunchpadPathRequest,72 _request_factory=ResolveLaunchpadPathRequest,
63 _lp_login=None):73 _lp_login=None):
64 """Resolve the base URL for this transport."""74 """Resolve the base URL for this transport."""
75 # Do ubuntu: and debianlp: expansions.
76 result = urlsplit(url)
77 if result.scheme in ('ubuntu', 'debianlp'):
78 if result.scheme == 'ubuntu':
79 distro = 'ubuntu'
80 distro_series = _ubuntu_series_shortcuts
81 elif result.scheme == 'debianlp':
82 distro = 'debian'
83 # No shortcuts for Debian distroseries.
84 distro_series = {}
85 else:
86 raise AssertionError('scheme should be ubuntu: or debianlp:')
87 # Split the path. It's either going to be 'project' or
88 # 'series/project', but recognize that it may be a series we don't
89 # know about.
90 path_parts = result.path.split('/')
91 if len(path_parts) == 1:
92 # It's just a project name.
93 lp_url_template = 'lp:%(distro)s/%(project)s'
94 project = path_parts[0]
95 series = None
96 elif len(path_parts) == 2:
97 # It's a series and project.
98 lp_url_template = 'lp:%(distro)s/%(series)s/%(project)s'
99 series, project = path_parts
100 else:
101 # There are either 0 or > 2 path parts, neither of which is
102 # supported for these schemes.
103 raise errors.InvalidURL('Bad path: %s' % result.path)
104 # Expand any series shortcuts, but keep unknown series.
105 series = distro_series.get(series, series)
106 # Hack the url and let the following do the final resolution.
107 url = lp_url_template % dict(
108 distro=distro,
109 series=series,
110 project=project)
111 result = urlsplit(url)
65 service = LaunchpadService.for_url(url)112 service = LaunchpadService.for_url(url)
66 result = urlsplit(url)
67 if _lp_login is None:113 if _lp_login is None:
68 _lp_login = get_lp_login()114 _lp_login = get_lp_login()
69 path = result[2].strip('/')115 path = result[2].strip('/')
70116
=== modified file 'bzrlib/plugins/launchpad/test_lp_directory.py'
--- bzrlib/plugins/launchpad/test_lp_directory.py 2010-07-26 17:19:33 +0000
+++ bzrlib/plugins/launchpad/test_lp_directory.py 2010-10-07 22:03:45 +0000
@@ -37,10 +37,7 @@
37from bzrlib.plugins.launchpad.lp_directory import (37from bzrlib.plugins.launchpad.lp_directory import (
38 LaunchpadDirectory)38 LaunchpadDirectory)
39from bzrlib.plugins.launchpad.account import get_lp_login, set_lp_login39from bzrlib.plugins.launchpad.account import get_lp_login, set_lp_login
40from bzrlib.tests import (40from bzrlib.tests import http_server
41 http_server,
42 http_utils,
43 )
4441
4542
46def load_tests(standard_tests, module, loader):43def load_tests(standard_tests, module, loader):
@@ -219,8 +216,8 @@
219 'bzr+ssh://bazaar.launchpad.net/~username/apt/test']))216 'bzr+ssh://bazaar.launchpad.net/~username/apt/test']))
220 self.assertIs(None, get_lp_login())217 self.assertIs(None, get_lp_login())
221 directory = LaunchpadDirectory()218 directory = LaunchpadDirectory()
222 e = self.assertRaises(errors.InvalidURL,219 self.assertRaises(errors.InvalidURL,
223 directory._resolve, 'lp:~/apt/test', factory)220 directory._resolve, 'lp:~/apt/test', factory)
224221
225222
226class DirectoryOpenBranchTests(TestCaseWithMemoryTransport):223class DirectoryOpenBranchTests(TestCaseWithMemoryTransport):
@@ -237,6 +234,8 @@
237 return '!unexpected look_up value!'234 return '!unexpected look_up value!'
238235
239 directories.remove('lp:')236 directories.remove('lp:')
237 directories.remove('ubuntu:')
238 directories.remove('debianlp:')
240 directories.register('lp:', FooService, 'Map lp URLs to local urls')239 directories.register('lp:', FooService, 'Map lp URLs to local urls')
241 self.addCleanup(_register_directory)240 self.addCleanup(_register_directory)
242 self.addCleanup(directories.remove, 'lp:')241 self.addCleanup(directories.remove, 'lp:')
@@ -259,11 +258,11 @@
259 def handle_one_request(self):258 def handle_one_request(self):
260 tcs = self.server.test_case_server259 tcs = self.server.test_case_server
261 requestline = self.rfile.readline()260 requestline = self.rfile.readline()
262 headers = self.MessageClass(self.rfile, 0)261 self.MessageClass(self.rfile, 0)
263 if requestline.startswith('POST'):262 if requestline.startswith('POST'):
264 # The body should be a single line (or we don't know where it ends263 # The body should be a single line (or we don't know where it ends
265 # and we don't want to issue a blocking read)264 # and we don't want to issue a blocking read)
266 body = self.rfile.readline()265 self.rfile.readline()
267266
268 self.wfile.write(tcs.canned_response)267 self.wfile.write(tcs.canned_response)
269268
@@ -356,3 +355,174 @@
356 # FIXME: we need to test with a real proxy, I can't find a way so simulate355 # FIXME: we need to test with a real proxy, I can't find a way so simulate
357 # CONNECT without leaving one server hanging the test :-/ Since that maybe356 # CONNECT without leaving one server hanging the test :-/ Since that maybe
358 # related to the leaking tests problems, I'll punt for now -- vila 20091030357 # related to the leaking tests problems, I'll punt for now -- vila 20091030
358
359
360class TestDebuntuExpansions(TestCaseInTempDir):
361 """Test expansions for ubuntu: and debianlp: schemes."""
362
363 def setUp(self):
364 tests.TestCase.setUp(self)
365 self.directory = LaunchpadDirectory()
366
367 def _make_factory(self, package='foo', distro='ubuntu', series=None):
368 if series is None:
369 path = '%s/%s' % (distro, package)
370 url_suffix = '~branch/%s/%s' % (distro, package)
371 else:
372 path = '%s/%s/%s' % (distro, series, package)
373 url_suffix = '~branch/%s/%s/%s' % (distro, series, package)
374 return FakeResolveFactory(
375 self, path, dict(urls=[
376 'http://bazaar.launchpad.net/' + url_suffix]))
377
378 # Bogus distro.
379
380 def test_bogus_distro(self):
381 self.assertRaises(errors.InvalidURL,
382 self.directory._resolve, 'gentoo:foo')
383
384 def test_trick_bogus_distro_u(self):
385 self.assertRaises(errors.InvalidURL,
386 self.directory._resolve, 'utube:foo')
387
388 def test_trick_bogus_distro_d(self):
389 self.assertRaises(errors.InvalidURL,
390 self.directory._resolve, 'debuntu:foo')
391
392 def test_missing_ubuntu_distroseries_without_project(self):
393 # Launchpad does not hold source packages for Intrepid. Missing or
394 # bogus distroseries with no project name is treated like a project.
395 factory = self._make_factory(package='intrepid')
396 self.assertEqual(
397 'http://bazaar.launchpad.net/~branch/ubuntu/intrepid',
398 self.directory._resolve('ubuntu:intrepid', factory))
399
400 def test_missing_ubuntu_distroseries_with_project(self):
401 # Launchpad does not hold source packages for Intrepid. Missing or
402 # bogus distroseries with a project name is treated like an unknown
403 # series (i.e. we keep it verbatim).
404 factory = self._make_factory(series='intrepid')
405 self.assertEqual(
406 'http://bazaar.launchpad.net/~branch/ubuntu/intrepid/foo',
407 self.directory._resolve('ubuntu:intrepid/foo', factory))
408
409 def test_missing_debian_distroseries(self):
410 # Launchpad does not hold source packages for unstable. Missing or
411 # bogus distroseries is treated like a project.
412 factory = self._make_factory(package='sid', distro='debian')
413 self.assertEqual(
414 'http://bazaar.launchpad.net/~branch/debian/sid',
415 self.directory._resolve('debianlp:sid', factory))
416
417 # Ubuntu Default distro series.
418
419 def test_ubuntu_default_distroseries_expansion(self):
420 factory = self._make_factory(package='foo')
421 self.assertEqual('http://bazaar.launchpad.net/~branch/ubuntu/foo',
422 self.directory._resolve('ubuntu:foo', factory)),
423
424 def test_ubuntu_natty_distroseries_expansion(self):
425 factory = self._make_factory(package='foo', series='natty')
426 self.assertEqual(
427 'http://bazaar.launchpad.net/~branch/ubuntu/natty/foo',
428 self.directory._resolve('ubuntu:natty/foo', factory)),
429
430 def test_ubuntu_n_distroseries_expansion(self):
431 factory = self._make_factory(package='foo', series='natty')
432 self.assertEqual(
433 'http://bazaar.launchpad.net/~branch/ubuntu/natty/foo',
434 self.directory._resolve('ubuntu:n/foo', factory)),
435
436 def test_ubuntu_maverick_distroseries_expansion(self):
437 factory = self._make_factory(package='foo', series='maverick')
438 self.assertEqual(
439 'http://bazaar.launchpad.net/~branch/ubuntu/maverick/foo',
440 self.directory._resolve('ubuntu:maverick/foo', factory)),
441
442 def test_ubuntu_m_distroseries_expansion(self):
443 factory = self._make_factory(package='foo', series='maverick')
444 self.assertEqual(
445 'http://bazaar.launchpad.net/~branch/ubuntu/maverick/foo',
446 self.directory._resolve('ubuntu:m/foo', factory)),
447
448 def test_ubuntu_lucid_distroseries_expansion(self):
449 factory = self._make_factory(package='foo', series='lucid')
450 self.assertEqual(
451 'http://bazaar.launchpad.net/~branch/ubuntu/lucid/foo',
452 self.directory._resolve('ubuntu:lucid/foo', factory)),
453
454 def test_ubuntu_l_distroseries_expansion(self):
455 factory = self._make_factory(package='foo', series='lucid')
456 self.assertEqual(
457 'http://bazaar.launchpad.net/~branch/ubuntu/lucid/foo',
458 self.directory._resolve('ubuntu:l/foo', factory)),
459
460 def test_ubuntu_karmic_distroseries_expansion(self):
461 factory = self._make_factory(package='foo', series='karmic')
462 self.assertEqual(
463 'http://bazaar.launchpad.net/~branch/ubuntu/karmic/foo',
464 self.directory._resolve('ubuntu:karmic/foo', factory)),
465
466 def test_ubuntu_k_distroseries_expansion(self):
467 factory = self._make_factory(package='foo', series='karmic')
468 self.assertEqual(
469 'http://bazaar.launchpad.net/~branch/ubuntu/karmic/foo',
470 self.directory._resolve('ubuntu:k/foo', factory)),
471
472 def test_ubuntu_jaunty_distroseries_expansion(self):
473 factory = self._make_factory(package='foo', series='jaunty')
474 self.assertEqual(
475 'http://bazaar.launchpad.net/~branch/ubuntu/jaunty/foo',
476 self.directory._resolve('ubuntu:jaunty/foo', factory)),
477
478 def test_ubuntu_j_distroseries_expansion(self):
479 factory = self._make_factory(package='foo', series='jaunty')
480 self.assertEqual(
481 'http://bazaar.launchpad.net/~branch/ubuntu/jaunty/foo',
482 self.directory._resolve('ubuntu:j/foo', factory)),
483
484 def test_ubuntu_hardy_distroseries_expansion(self):
485 factory = self._make_factory(package='foo', series='hardy')
486 self.assertEqual(
487 'http://bazaar.launchpad.net/~branch/ubuntu/hardy/foo',
488 self.directory._resolve('ubuntu:hardy/foo', factory)),
489
490 def test_ubuntu_h_distroseries_expansion(self):
491 factory = self._make_factory(package='foo', series='hardy')
492 self.assertEqual(
493 'http://bazaar.launchpad.net/~branch/ubuntu/hardy/foo',
494 self.directory._resolve('ubuntu:h/foo', factory)),
495
496 def test_ubuntu_dapper_distroseries_expansion(self):
497 factory = self._make_factory(package='foo', series='dapper')
498 self.assertEqual(
499 'http://bazaar.launchpad.net/~branch/ubuntu/dapper/foo',
500 self.directory._resolve('ubuntu:dapper/foo', factory)),
501
502 def test_ubuntu_d_distroseries_expansion(self):
503 factory = self._make_factory(package='foo', series='dapper')
504 self.assertEqual(
505 'http://bazaar.launchpad.net/~branch/ubuntu/dapper/foo',
506 self.directory._resolve('ubuntu:d/foo', factory)),
507
508 # Debian default distro series.
509
510 def test_debian_default_distroseries_expansion(self):
511 factory = self._make_factory(package='foo', distro='debian')
512 self.assertEqual(
513 'http://bazaar.launchpad.net/~branch/debian/foo',
514 self.directory._resolve('debianlp:foo', factory))
515
516 def test_debian_squeeze_distroseries_expansion(self):
517 factory = self._make_factory(
518 package='foo', distro='debian', series='squeeze')
519 self.assertEqual(
520 'http://bazaar.launchpad.net/~branch/debian/squeeze/foo',
521 self.directory._resolve('debianlp:squeeze/foo', factory)),
522
523 def test_debian_lenny_distroseries_expansion(self):
524 factory = self._make_factory(
525 package='foo', distro='debian', series='lenny')
526 self.assertEqual(
527 'http://bazaar.launchpad.net/~branch/debian/lenny/foo',
528 self.directory._resolve('debianlp:lenny/foo', factory)),
359529
=== modified file 'doc/en/tutorials/using_bazaar_with_launchpad.txt'
--- doc/en/tutorials/using_bazaar_with_launchpad.txt 2010-08-13 19:08:57 +0000
+++ doc/en/tutorials/using_bazaar_with_launchpad.txt 2010-10-07 22:03:45 +0000
@@ -244,6 +244,41 @@
244quality standards.244quality standards.
245245
246246
247Package source branches
248-----------------------
249
250When `maintaining packages for Ubuntu using Bazaar`_ you can easily access the
251package's source branch on Launchpad. The package's source branch in the
252current (default) series can be downloaded like this::
253
254 bzr branch ubuntu:package
255
256where *package* is the name of the Ubuntu package you want to access. To
257download the package branch for a specific series in Ubuntu (e.g. Maverick or
258Lucid), use this::
259
260 bzr branch ubuntu:maverick/package
261
262Ubuntu distroseries can also be abbreviated to just their first letter. For
263example, the above could also be written::
264
265 bzr branch ubuntu:m/package
266
267You can also download the package source branch from Launchpad for several
268Debian series. The default series can be downloaded like this::
269
270 bzr branch debianlp:package
271
272and a specific series can be downloaded like this::
273
274 bzr branch debianlp:lenny/package
275
276Note that the ``debianlp:`` scheme access the Debian source branch for a
277package from Launchpad only.
278
279.. _`maintaining packages for Ubuntu using Bazaar`: https://wiki.ubuntu.com/DistributedDevelopment
280
281
247Linking branches using Launchpad282Linking branches using Launchpad
248================================283================================
249284