hgbook

view examples/hg-interdiff @ 279:3c14c304d823

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