comparison 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
comparison
equal deleted inserted replaced
105:ecacb6b4c9fd 106:9cbc5d0db542
1 #!/usr/bin/env python
2 #
3 # Adapter for using interdiff with mercurial's extdiff extension.
4 # Copyright 2006 Bryan O'Sullivan <bos@serpentine.com>
5
6 import os, sys
7
8 def walk(base):
9 # yield all non-directories below the base path.
10 for root, dirs, files in os.walk(base):
11 for f in files:
12 path = os.path.join(root, f)
13 yield path[len(base)+1:], path
14
15 # create list of unique file names under both directories.
16 files = dict(walk(sys.argv[1]))
17 files.update(walk(sys.argv[2]))
18 files = files.keys()
19 files.sort()
20
21 def name(base, f):
22 # interdiff requires two files; use /dev/null if one is missing.
23 path = os.path.join(base, f)
24 if os.path.exists(path):
25 return path
26 return '/dev/null'
27
28 ret = 0
29
30 for f in files:
31 if os.system('interdiff "%s" "%s"' % (name(sys.argv[1], f),
32 name(sys.argv[2], f))):
33 ret = 1
34
35 sys.exit(ret)