It’s sometimes useful to be able to revert a branch to a previous known state. For example, I recently updated a bzr plugin to its latest and greatest to discover a severe regression. If I had had some foresight, I might have recorded the revision (or the “tip”) before the update to allow me to rollback to the previous stable version. But as I rarely have such foresight, and have more important uses for my little grey cells, I set out to create ‘tiplog’, a new bzr plugin for recording and referencing the history of a branch’s tip.

‘tiplog’ is inspired by git’s ‘reflog’, and records commits, uncommits, pushes (to the branch), pulls (into the branch) — basically any change that causes the tip to change. ‘tiplog’ only records pushes to local branches. But the plugin can also be run within the smart server, although it cannot distinguish the causes of the tip change.

In my updating scenario described above, for example, say the plugin was at revision 20. Running ‘bzr pull‘ pulls in revision 40. ‘bzr tiplog‘ will inform me that my plugin was previously at r20:

$ bzr tiplog
2011-09-23 tip:0 40 [pull] update version numbers
2011-08-25 tip:1 20 [pull] fix bug #12009
2011-06-23 tip:2 1 [pull] initial commit

Better yet, I can easily return to that previous stable revision using the new ‘tip:‘ revspec, with ‘bzr pull -r tip:1‘. ‘tip:0 is the current tip.

I also find tiplog useful when developing with others, as I can quickly review the changes since I last pulled:

$ bzr log --line -r tip:1..
17705: 2011-09-27 fixes #1474
17704: 2011-09-27 fixing Job Cost
17703: 2011-09-25 fixes #1377

And in fact I have that bound to an alias.

To install tiplog, simply perform the following:

$ bzr branch lp:bzr-tiplog ~/.bazaar/plugins/tiplog

Please direct report any bugs or questions through the plugin’s Launchpad page.