Tuesday, December 22, 2009

Committing to SVN using Bazaar

Ejat and I were working on how to do the above for MyMeeting codes and we did it! I have asked ejat to put this down in writing in his blog, but sadly the blog is not available anymore (alaa ejat bukan susah sangat cari hosting punnnnn.. susah2 ko host sendiri jek kat umah :P)

MyMeeting is also on Launchpad that makes use of Bazaar. We wanted to find a way how to send changes to both its main repo (using SVN) and Launchpad.

So we've been using SVN for MyMeeting hosted at OSCC. A typical way for us would be like this.

$ svn co https://svn.oscc.org.my/mymeeting/trunk trunk
$ cd trunk
(hack hack hack...)
$ svn status #see our changes
$ svn ci -m 'added feature ABC' #commit to SVN repository




To use Bazaar to work with SVN repo, you have to install bzr and bzr-svn. Excellent doc on bzr-szv is here.

$ sudo apt-get bzr bzr-svn




SVN-like


Working with Bazaar, the way would be something like this.

$ mkdir dev
$ bzr init-repo --default-rich-root dev
$ cd dev
$ bzr co https://svn.oscc.org.my/mymeeting/trunk trunk
$ cd trunk
(hack hack hack...)
$ bzr update #get changes done by others
$ bzr ci -m 'added form for feature ABC' #commit to SVN repository
$ bzr push lp:mymeeting #push to Launchpad, only have to provide location once
(hack hack hack...)
$ bzr update #get changes done by others
$ bzr ci -m 'added list for feature ABC' #commit to SVN repository
$ bzr push




Decentralized Bazaar way


If we were to take advantage of Bazaar's decentralised way of doing it (so you can work offline, for example), it's like this.

$ mkdir dev
$ bzr init-repo --default-rich-root dev
$ cd dev
$ bzr co https://svn.oscc.org.my/mymeeting/trunk trunk #our copy of trunk
$ bzr branch trunk working #make a local branch to hack on
$ cd working
(hack hack hack...working offline)
$ bzr ci -m 'added form for feature ABC' #commit to local branch
(hack hack hack...working offline)
$ bzr ci -m 'added list for feature ABC' #commit to local branch

(when you get your connection back)
$ cd ../trunk
$ bzr update #get changes done by others to our copy of trunk
$ cd ../working
$ bzr pull #pull the changes to our local branch
$ bzr status #see our changes
$ cd ../trunk
$ bzr merge ../working
$ bzr ci -m 'added feature ABC'




Personally I like the centralised approach because it's similar to SVN. Local branch is great feature if I have to do my work offline sometimes. And while I can pick Bazaar from now on, the rest of the team doesn't have to switch tool. That's great!

No comments:

Post a Comment