hgbook

annotate examples/hg-interdiff @ 229:0a20b03559bf

Most stable output of bisect example seems to have changed?
author Bryan O'Sullivan <bos@serpentine.com>
date Sat May 26 12:07:03 2007 -0700 (2007-05-26)
parents 9cbc5d0db542
children f992b16d18a1
rev   line source
bos@106 1 #!/usr/bin/env python
bos@106 2 #
bos@106 3 # Adapter for using interdiff with mercurial's extdiff extension.
bos@127 4 #
bos@106 5 # Copyright 2006 Bryan O'Sullivan <bos@serpentine.com>
bos@127 6 #
bos@127 7 # This software may be used and distributed according to the terms of
bos@127 8 # the GNU General Public License, incorporated herein by reference.
bos@106 9
bos@106 10 import os, sys
bos@106 11
bos@106 12 def walk(base):
bos@106 13 # yield all non-directories below the base path.
bos@106 14 for root, dirs, files in os.walk(base):
bos@106 15 for f in files:
bos@106 16 path = os.path.join(root, f)
bos@106 17 yield path[len(base)+1:], path
bos@106 18
bos@106 19 # create list of unique file names under both directories.
bos@106 20 files = dict(walk(sys.argv[1]))
bos@106 21 files.update(walk(sys.argv[2]))
bos@106 22 files = files.keys()
bos@106 23 files.sort()
bos@106 24
bos@106 25 def name(base, f):
bos@106 26 # interdiff requires two files; use /dev/null if one is missing.
bos@106 27 path = os.path.join(base, f)
bos@106 28 if os.path.exists(path):
bos@106 29 return path
bos@106 30 return '/dev/null'
bos@106 31
bos@106 32 ret = 0
bos@106 33
bos@106 34 for f in files:
bos@106 35 if os.system('interdiff "%s" "%s"' % (name(sys.argv[1], f),
bos@106 36 name(sys.argv[2], f))):
bos@106 37 ret = 1
bos@106 38
bos@106 39 sys.exit(ret)