#!/usr/bin/env python import sys import re import subprocess # Configure your favorite diff program here. DIFF = "/usr/bin/xmldiff" # Subversion provides the paths we need as the last two parameters. LEFT = sys.argv[-2] RIGHT = sys.argv[-1] # Ignore non-XML files LFILE = sys.argv[3] filename = re.sub('\t.*$', '', LFILE) if not filename.endswith('.xml'): print "%s is not XML" % filename exit(0) # Call the diff command (change the following line to make sense for # your diff program). #cmd = [DIFF, '--not-normalize-spaces', '--exclude-comments', LEFT, RIGHT] cmd = [DIFF, LEFT, RIGHT] rc = subprocess.call(cmd) # Return an errorcode of 0 if no differences were detected, 1 if some were. # Any other errorcode will be treated as fatal. if rc > 1: exit(1)