Many of Bazaar's dirty little secrets are hidden away in options you can set
in ~/.bazaar/bazaar.conf and ~/.bazaar/locations.conf. Here are some
fun things to configure to streamline your hacking with Launchpad and with
other projects.
First, some background. I have a rather detailed and involved setup and
workflow (which I'll detail later), so I'm going to do my best to make this as
simple as possible. For the sake of this example, I'm going to lay out my
folders this way:
~/
~/Projects
~/Projects/bzr
~/Projects/bzr/bzr.dev
~/Projects/bzr/foo
~/Projects/bzr/bar
~/Projects/bzr/baz
~/Projects/entertainer
~/Projects/entertainer/entertainer
~/Projects/+junk
~/Projects/private
~/Projects/private/ironlion
So I have put all my branches into a ~/Projects directory, inside a dir
each for various projects I work on that are hosted on Launchpad(bzr and
Entertainer for the sake of this example). I also have two other folders,
one called +junk (for junk branches), a folder called private which,
as you may have guessed, will be for things I don't push to Launchpad (like,
say, for instance, the source for this blog, which contains db passwords all
sorts of fun info... :)
To start out, let's look at my ~/.bazaar/bazaar.conf:
[DEFAULT]
email = Paul Hummer <paul@myemaildomain.com>
create_signatures = always
gpg_signing_command = /usr/bin/gpg
launchpad_username = rockstar
This where you put all the things about your general use of bzr. The
email line will usually get set by doing bzr whoami which you should
generally run the first time you run bzr, so that bzr knows your name and your
email address. If you've ever seen your revisions on Launchpad saying
something like rockstar <rockstar@megatron> it's probably because you
haven't set your email config line, and so it's taking your user name and host
name of the system you're working on (in this case, my system's name is
megatron). I've also set my launchpad username. This is also important, and
would get set when doing bzr launchpad-login rockstar Confused yet? If
so, just skip down to the next block. create_signatures and
gpg_signing_command are both to allow me to sign my revisions.
[ALIASES]
cbranch = cbranch --lightweight
ci = commit --strict
diff = diff --diff-options -p
diff-thread = cdiff -r thread:
ll = log --line -r-10..-1
lpsend = send --no-bundle
recentlog = log -r-20..-1 --short
sdiff = cdiff -r submit:
st = status --short
unpushed = missing --mine-only :push
These are my aliases. Think of them like shell aliases. The details you don't
have to worry about too much, but when find yourself running the same commands
over and over, add them to your aliases.
locations.conf is where all the fun happens. It's what tells bzr, based on
the location of the branch, where to push, where to submit, etc. So let's
start with a generic blanket statement that'll be used for all projects pushed
to Launchpad. So let's start with:
[/home/rockstar/Projects]
push_location = lp:~rockstar/
push_location:policy = appendpath
public_branch = lp:~rockstar/
public_branch:policy = appendpath
The secret here is in the appendpath. Basically, bzr looks at the relationship
of the current branch, say ~/Projects/entertainer/entertainer to this
config section, and, using the appendpath policy, decides it needs to be
pushed to lp:/~rockstar/entertainer/entertainer Hooray! Now, if I create
a new branch at ~/Projects/entertainer/fix-bug-123465 and just call
bzr push, bzr is smart enough to push it to
lp:~rockstar/entertainer/fix-bug-123456 This even works with junk branches
(branches that aren't attached to a project), provided you just put your
branch in the +junk folder.
But wait! What if I don't want to push to Launchpad? I first ask "Why don't
you? It's so great!" :) As locations.conf stands now, if you put something
in your private area, Launchpad is going to tell you there is no project named
private when yo utry to push. Well, let's fix that.
[/home/rockstar/Projects/private]
push_location = bzr+ssh://bzr.eventuallyanyway.com/code/
push_location:policy = appendpath
public_branch = bzr+ssh://bzr.eventuallyanyway.com/code/
public_branch:policy = appendpath
As you can see, I push my private branches to bzr.eventuallyanyway.com/code.
It uses the same tricks as I showed before, so the same idea can be assumed.
It's important that I point out that there's no order required in how these
config sections get put into locations.conf because bzr is smart enough to
find the most specific config and use it.
This concludes this session of bzr-lp hackery. Comments welcome.