Mark Needham

Thoughts on Software Development

Archive for the ‘hg’ tag

Mercurial: hg push to Google Code

with one comment

I wanted to make a change to add flatMap to Option in totallylazy so I had to clone the repository and make the change.

I thought I’d then be able to just push the change using my Google user name and password but instead ended up with the following error:

➜  mhneedham-totally-lazy  hg push
pushing to https://m.h.needham@code.google.com/r/mhneedham-totally-lazy/
searching for changes
1 changesets found
http authorization required
realm: Google Code hg Repository
user: m.h.needham
password: 
abort: HTTP Error 403: Forbidden

It turns out that you need to specifically set an option to use your Google account from the settings page:

Googlecode

And then it works!

Written by Mark Needham

March 14th, 2012 at 9:25 pm

Posted in Version Control

Tagged with ,

Mercurial: hg bisect

with 3 comments

We’ve been using Mercurial locally on the project I’ve been working on and Phil showed me a cool feature called ‘bisect‘ a couple of weeks ago which can be helpful for working out which revision we managed to break our code in.

It’s been ported across from Git and is included in Mercurial from version 1.0.0 rather than just being an extension.

From the bisect extension page:

Its behaviour is fairly simple: it takes a first revision known to be correct (i.e. without the bug) and a last revision known to be bad (i.e. with the bug). The bisect extension ouputs a revision halfway between the good and the bad ones and lets you test it. If this revision is a good one, you mark it as good with hg bisect good, otherwise you mark it as bad with hg bisect bad. In both cases, bisect outputs a new revision to test, halfway between the good and the bad ones. You repeat until only one revision is left: the culprit.

The usage has changed a bit now that it’s included as part of the initial download.

I was working on something yesterday and checking in fairly regularly before realising that I’d broken something.

I was fairly sure that the break had happened in the tip (revision 98) but I could only remember it definitely working in revision 96.

I defined the good and bad revisions like this:

hg bisect -b tip
hg bisect -g 96

In this case revision 97 was now checked out and I checked that the code was working with that revision before marking it:

hg bisect -g

It’s now able to work out that the problem is in fact in revision 98:

The first bad revision is:
changeset:   98:86260809c309
tag:         tip
user:        mneedham
date:        Fri Nov 13 16:31:02 2009 +1100
summary:     seem to have screwed up the graphs. Not sure how

I managed to mess up setting up the good and bad revisions a few times – I somehow had the impression that I needed to manually update to the original good and bad revisions which isn’t the case.

The reset command was my friend before I worked out what I was doing wrong:

hg bisect -r

It seems like a neat little feature. I’m sure there are lots of other cool things like this in Mercurial so if you know any let me know!

* Update *
As Rob points out in the comments the command is ‘bisect’ rather than ‘bisec’ as I had it originally. Both commands work for the moment though!

Written by Mark Needham

November 14th, 2009 at 11:20 am

Posted in Version Control

Tagged with , ,