bzrlib in zeitgeist

Martin Pool mbp at canonical.com
Tue May 26 16:53:49 BST 2009


(Zeitgeist wants to use bzrlib to store versions of files over time;
here's some notes on how they could use bzrlib to store them.)

So basically:

import bzrlib # :)

There is api documentation here:
<http://starship.python.net/crew/mwh/bzrlibapi/bzrlib.html> and some
more developer documentation here
<http://doc.bazaar-vcs.org/bzr.dev/developers/index.html> including,
particularly relevant to you, this guide to writing python programs
that use bzrlib <http://bazaar-vcs.org/Integrating_with_Bazaar>.  I'm
sure all of them could be improved so please ask if something is
missing or not clearly explained.

I think you'll want to create just one branch and repository under say
~/.zeitgeist (or maybe ~/.local or ~/.cache) and then commit into it
when you're notified something has changed.  Under that directory,
when you decide you want to store say /home/mbp/travel/2009-05-Spain,
copy that to ~/.zeitgeist/travel/2009-05-Spain, ie the
homedir-relative path, then bzr add and bzr commit.

(It would be possible through the api to tell bzr to commit the file
into that branch without the file actually being present there, but
it's probably easiest to start with to actually copy it.)

Then you can look back through the history of that file by just
running 'bzr log $file' to see all the versions that are stored, and
to pull out a particular previous version to display or restore by
running 'bzr cat -r$ver $file'.

You might also look at the bzr-search content-indexing plugin
http://launchpad.net/bzr-search which should be adaptable to give you
a fulltext index across files in the branch.

-- 
Martin <http://launchpad.net/~mbp/>



More information about the bazaar mailing list