Tips and best practices for using bzr
Faster access to remote branches
Improving remote access speed is a high priority. In the meantime there are some things you can do to work around the problem.
Have a fast nameserver
bzr currently makes more dns lookups than it should. You can benefit by using a local caching nameserver.
Branch locally first
To download a branch related to a branch you already have, make a local branch from a common ancestor, then pull in those changes:
% bzr branch -r 900 ~/work/bzr ~/work/bzr.abentley % cd bzr.abentley % bzr pull http://panoramicfeedback.com/opensource/bzr.merge4/
If you want to look at or integrate a remote branch, bring down a local branch of it first for easy access.
Operating on only a subdirectory
Several bzr commands like "commit" and "status" operate on the whole tree, but can optionally operate on only a subdirectory if it is given as a parameter.
% bzr status . % bzr commit .
Reducing the need to enter passwords
When using Bazaar you may be requested for a password for each command when operating on remote locations. The following tips will help to minimize this as much as possible.
Provide the password as part of the location
This is the simplest, but least secure, way to prevent being asked for the password. For example, if you want to push a branch to ftp server you could do this:
% bzr push ftp://user:password@host/dir
This may not work in the case of ssh or sftp connections as Bazaar may use the ssh client program to make the connection. In this case it is the ssh client program that will ask for the password and not Bazaar itself. To prevent the password prompt in this case you will have to use mechanisms specific to the ssh program (see below).
When using ssh or sftp
If Bazaar is using the ssh client program to connect to remote locations then there are three ways that you can eliminate the need to enter the password.
The first is to use public key authentification and the ssh-agent program. You can find instructions on how to do this here.
The other approach, which makes sense if public key authentification is not possible on the server, is to use one connection to the server that stays open all the time and all ssh access goes through this one connection. This means you only have to enter your password once in order to make the connection to the server and then Bazaar will reuse this connection every time it needs to access the server.
You need to add an option to your $HOME/.ssh/config to tell ssh clients how they can communicate with the master connection:
Host remote-host-to-connect-to.org ControlPath /tmp/some_unique_file_name
When you make the master connection it will create a socket called /tmp/some_unique_file_name that ssh clients can talk to and share the same connection to the server.
To create the master connection you use the -M option to ssh:
% ssh -fMN firstname.lastname@example.org
The -f and -N options tell the master connection to run in the background and not to execute a command when the connection is made.
You should be asked for your password when you make the master connection to the server. Now all future connections will go through this connection and you should not be asked for your password again.
Using the ''fuse'' file system with ssh
Another option is to use the ssh fuse file system. What this does is that it mounts a remote share to a local location. This way you are only prompted once for the password. In order to make this work you must install the fuse file system, your distro may already include it, see your OS docs for details on how to do this.
% mkdir -p /virt/svr1 % sshfs -oworkaround=rename email@example.com:/remote/path/ /virt/svr1
Now /virt/svr1 is just another directory on your local computer, but it's contents are actually on another computer. Make sure that "user" has permission to create files on the remote computer.