Mercurial > hgbook
diff examples/hg-interdiff @ 106:9cbc5d0db542
Finish off advanced MQ chapter (maybe).
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Mon, 23 Oct 2006 15:43:04 -0700 |
parents | |
children | ba2334e2ba9a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/hg-interdiff Mon Oct 23 15:43:04 2006 -0700 @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# +# Adapter for using interdiff with mercurial's extdiff extension. +# Copyright 2006 Bryan O'Sullivan <bos@serpentine.com> + +import os, sys + +def walk(base): + # yield all non-directories below the base path. + for root, dirs, files in os.walk(base): + for f in files: + path = os.path.join(root, f) + yield path[len(base)+1:], path + +# create list of unique file names under both directories. +files = dict(walk(sys.argv[1])) +files.update(walk(sys.argv[2])) +files = files.keys() +files.sort() + +def name(base, f): + # interdiff requires two files; use /dev/null if one is missing. + path = os.path.join(base, f) + if os.path.exists(path): + return path + return '/dev/null' + +ret = 0 + +for f in files: + if os.system('interdiff "%s" "%s"' % (name(sys.argv[1], f), + name(sys.argv[2], f))): + ret = 1 + +sys.exit(ret)