Skip to content

Instantly share code, notes, and snippets.

@nielsmadan
Last active December 10, 2015 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nielsmadan/4420243 to your computer and use it in GitHub Desktop.
Save nielsmadan/4420243 to your computer and use it in GitHub Desktop.
Small python script to call hg status in a mercurial repo, get the names of all modified files and open the diff for each one using gvimdiff. Similar to how git behaves. .hgdiff needs to be configured for this to work (see comment at bottom of file). See here for more verbose explanation: http://www.pushingbits.net/posts/hg-diff-with-gvimdiff/
#!/usr/bin/python
import subprocess
output = subprocess.check_output(["hg", "status", "-m"])
files = [line.split(' ', 1)[1] for line in output.split('\n') if line != '']
for f in files:
subprocess.call(["hg", "d", f])
# add this to hgrc
#[extensions]
#hgext.extdiff =
#
#[extdiff]
#cmd.d = gvimdiff
#opts.d = --nofork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment