hgbook-ru / contrib / hg-interdiff

#!/usr/bin/env python
# Adapter for using interdiff with mercurial's extdiff extension.
# Copyright 2006 Bryan O'Sullivan <>
# This software may be used and distributed according to the terms of
# the GNU General Public License, incorporated herein by reference.

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
        if os.path.isfile(base):
            yield '', base

# create list of unique file names under both directories.
files = dict(walk(sys.argv[1]))
files = files.keys()

def name(base, f):
    if f:
        path = os.path.join(base, f)
        path = base
    # interdiff requires two files; use /dev/null if one is missing.
    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

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.