Friday, February 9, 2007

Mercurial Head Scratcher

I'm trying to generate a patch to send to a project that uses Mercurial for their scm. In the middle of some commits, I did an 'hg pull' and 'hg merge'. Since I did not have 'git rebase' available, I now have the merged code right in the middle of my commits. If all of my commits were adjacent, I could run 'hg diff -r a -r b' to get a patch containing all of the changes. They're not, so I can't.

In git, I could run 'git diff master' to compare my branch to the master branch, and get a single diff containing all the changes. I tried to find a similar command for hg. The closest I could find was 'hg outgoing -p'; but this still contains the changes from the merged upstream code. Other examples for accomplishing this on the hg website are so convoluted as to make the average perl programmer balk.

In the end, I had to do a fresh clone, then diff the two directories.

Maybe I'm missing something, but how is it people can think that Mercurial is easier than git?

3 comments:

  1. The Cobbler Team is seriously considering moving to git.

    ReplyDelete
  2. The Cobbler Team would be wise to do so. Has the Cobbler Executive Software Configuration Management Steering Committee produced any reports yet?

    ReplyDelete
  3. It's actually not so different in Mercurial. You do your development on a named branch, and you import the work from the master repository on another, like so:

    hg diff -r my-branch -r master

    The one irritating gotcha is that the default branch isn't named by default, and unless you have added a name to it, you don't have any obvious way to select it (it's not always 'tip'), and have to search through the log for that revision. But the named branches are separate, and the above is equivalent to 'git diff master'.

    ReplyDelete

© 2012 James Bowes. Icons by glyphicons. Powered by Blogger.