bos@106: #!/usr/bin/env python bos@106: # bos@106: # Adapter for using interdiff with mercurial's extdiff extension. bos@127: # bos@106: # Copyright 2006 Bryan O'Sullivan bos@127: # bos@127: # This software may be used and distributed according to the terms of bos@127: # the GNU General Public License, incorporated herein by reference. bos@106: bos@106: import os, sys bos@106: bos@106: def walk(base): bos@106: # yield all non-directories below the base path. bos@106: for root, dirs, files in os.walk(base): bos@106: for f in files: bos@106: path = os.path.join(root, f) bos@106: yield path[len(base)+1:], path njriley@286: else: njriley@286: if os.path.isfile(base): njriley@286: yield '', base bos@106: bos@106: # create list of unique file names under both directories. bos@106: files = dict(walk(sys.argv[1])) bos@106: files.update(walk(sys.argv[2])) bos@106: files = files.keys() bos@106: files.sort() bos@106: bos@106: def name(base, f): njriley@286: if f: njriley@286: path = os.path.join(base, f) njriley@286: else: njriley@286: path = base bos@106: # interdiff requires two files; use /dev/null if one is missing. bos@106: if os.path.exists(path): bos@106: return path bos@106: return '/dev/null' bos@106: bos@106: ret = 0 bos@106: bos@106: for f in files: bos@106: if os.system('interdiff "%s" "%s"' % (name(sys.argv[1], f), bos@106: name(sys.argv[2], f))): bos@106: ret = 1 bos@106: bos@106: sys.exit(ret)