Thursday, September 30, 2010

Mercurial diff folding in Vim

I use Merurial a TON these days. One of the things I like to do is to view incoming patches before I pull and update them. Typically, I would hg in --patch | gvim - and browse the diff that way. However, when pulling in several of changesets which modify potentially dozens of files, the output can be quite lengthy.

At first I started to tackle this by just folding hunks, files, and changsets as I browsed through the output. This got to be ridiculously time consuming though. So, one afternoon, I decided to figure out how to make a vim plugin which would do this for me. Here is the result.

Pretty soon, I found myself using this for diffing changesets and managing my mq patches as well. Try it out and let me know what you think!

The script is also in my vimstuff bitbucket repo.

P.S. Be gentle as I am definitely still a beginner when it comes to writing vim scripts :)