codem - blog

Posts Tagged ‘bazaar’

Use Github without using Git (and without really trying)

I’m probably on the outer when it comes to using Git. I find Bzr much easier to use, just as fast and prefer it over Git unless absolutely necessary.

One plus Git has over Bzr is Github which is an awesome solution to sharing code, especially within Open Source projects. Bzr has Launchpad but I’ve often found it slow and cumbersome. Github has presence as well and really makes a good effort to promote sharing of code.

I wanted to use Github to share some of the Open Source libraries and modules we develop but didn’t want to change version control systems to do so. The solution is simple:

  1. Log in to Github
  2. Create a repository – give it a name and description.
  3. Grab the URL to the repo – it will look something like git@github.com:user/repo.git
  4. Ignore the instructions Github gives you, just grab that URL
  5. On your dev machine, switch to the Bzr branch you want to host on Github
  6. Run the command bzr dpush git+ssh://git@github.com/user/repo.git
  7. Wait for a result and that’s it. If you browse to Github page for your repo, you’ll see the source
  8. If you have troubles at step #6 run the command but with a -Derror switch. One common error is to not switch that “:user/repo.git to “/user/repo.git”

The above relies on you having Bzr installed (2.4 is the latest), the bzr-git plugin and also assumes you’ve already set up your SSH keys with Github

Branching from Github is just as easy:

  1. bzr branch git+ssh://git@github.com/user/repo.git feature_directory
  2. hack away
  3. push back to the same branch or a different one

Too easy!

Related to this – check out our new project “DisplayAnything” – an image gallery module for Silverstripe

providing patches in feature-based web development

A while back, I did a presentation to the Sydney PHP Group on feature based web development using Bazaar, a distributed version control system. At the time is was quite interesting to see the number of attendees who a) didn’t know about or use version control or b) were using CVS (the instant coffee of version control).

If you are doing web development amongst a team and want a really solid branching system without headache inducing conflict/merge issues then Bazaar is a really valuable tool. One of the best things about patching in Bazaar is the send command:

$ bzr help send
Purpose: Mail or create a merge-directive for submitting changes.
Usage:   bzr send [SUBMIT_BRANCH] [PUBLIC_BRANCH]

The send command enables you by default to mail a patch file to the patch manager, who can then test and merge it into a centralised mainline branch. If you don’t want to mail patches they can be uploaded to the remote server in one go, even though send doesn’t as yet support saving to remote locations.
The trick is to provide ‘-’ (stdout) as the output file then pipe it to ssh for upload to your remote directives location.

bzr send -o - sftp://me@someserver/path/to/remote/branch | ssh me@someserver "cat > /path/to/directives/my.patch"

After bzr does it’s stuff and you’ve logged in to the remote server, a patch file is available (my.patch) that can be applied, tested and either reverted or committed using bzr merge, pull, commit and revert.

Tip 1: if you don’t have SSH access to your server try the bzr upload plugin
Tip 2: storing your public ssh key on the remote server will allow you to perform the send without password prompts.