The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny...' --Isaac Asimov
That's Funny… random header image

Using Bazaar version control system for my Ph.D. Thesis

April 30th, 2009 by eric

I wrote my last paper in LaTeX and the submitted file was named ‘paper_v26’. Various other files with similar names are floating around and it is a chore to keep up with which is the latest version when they are split between two computers and three operating systems. For my thesis I decided to make things easier. I tried using subversion. I really did. But it just wasn’t doing it for me. So I tried Bazaar and got it to work intuitively in just a few minutes. So that’s what I’m going to start using now. To help get you (and me) started, here’s a distilled version of this tutorial and this user guide). Requirements for my setup: 1) unfrightened by the command line; 2) SSH daemon running on central repository host.

Briefly, the way it works is that you set up a central repository for your files, preferably on some computer that is connected to the internet all the time, even better if it has a static domain name. Into this repository you place the files you want to be version controlled. This works best for plain text files (like LaTeX source files) because it is simple to compare versions if necessary, but it will also work for binary files like OpenOffice documents (which have built-in version control, if you didn’t know) and images. If you are working on the computer with the central repository, great, just make sure to update the files each time before you work on them and commit them each time you are done. You could probably write a cron job to do this for you if you are liable to forget. If you are working on a different computer, you just have to ask the central repository for the files and it will give you the latest versions. After you edit them you have to commit the changes to a local repository, which can then be merged with the central repository.

To get started:

  • Install bzr
  • Make a new directory and copy the files you’ll be starting with into it. If you’re using LaTeX, you’ll probably only want the files that are not compiled, e.g. *.tex, *.bib, *.bst and NOT *.aux, *.log, etc.
  • Tell bzr who you are:
    bzr whoami "me <me@me.com>"
  • Initialize tracking in this directory:
    bzr init
  • Add all the files in the directory, recursively:
    bzr add
  • Commit the files to the first revision. Make sure to add a message (-m), or you might find yourself in ‘vi’ (shudder). Do this after every work session.
    bzr commit -m "very important message"
  • Next time you work from this computer with the central repository, make sure you are using the most recent version:
    bzr update
  • The first time you work on your project from a different computer, pull a new copy via ssh from that computer:
    bzr branch sftp://user@host.domain:port/location/to/remote/files /new/local/location
  • In future sessions, pull new edits from the central repository before working on them:
    bzr merge sftp://user@host.domain:port/location/to/remote/files
    bzr commit -m "merge from parent"
  • To submit edits to the central repository, first commit them locally, then push edits via ssh to that computer:
    bzr commit -m "local changes"
    bzr push sftp://user@host.domain:port/location/to/remote/files

Some further usage, much of which is intuitive because it works just like regular unix commands:

  • Clean up a directory by deleting non-versioned files and reloading the last commit:
    bzr commit
     rm *
    bzr revert
  • Get an old version (X) of a file:
    bzr revert -rX path/to/file
  • Make a new versioned subdirectory:
    bzr mkdir ./newdirectory
  • Add a new file to the repository:
    bzr add ./newfile.txt
  • Remove a file from the repository:
    bzr rm ./oldfile.txt
  • Rename or move a file or directory in the repository:
    bzr mv oldfile.txt newfile.txt

Tags:   · · 1 Comment

Leave A Comment

1 response so far ↓

  • 1 Juan Diego Oct 16, 2009 at 6:22 am

    I’ve found this post very useful in getting started using bzr. Thank you for sharing.