#!/usr/bin/env python """Run diff3 and an interactive tool if this fails. """ __copyright__ = """ Copyright (C) 2006, Catalin Marinas This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ import sys, os if len(sys.argv) != 5: print >> sys.stderr, 'Usage: %s ancestor branch1 branch2 output' \ % sys.argv[0] sys.exit(1) ancestor = sys.argv[1] branch1 = sys.argv[2] branch2 = sys.argv[3] output = sys.argv[4] # default merger if os.system('diff3 -L current -L ancestor -L patched -m -E ' '"%s" "%s" "%s" > "%s"' % (branch1, ancestor, branch2, output)): # interactive merge if os.path.exists(output): mtime = os.path.getmtime(output) else: mtime = 0 ret = os.system('emacs --eval \'(ediff-merge-files-with-ancestor ' '"%s" "%s" "%s" nil "%s")\'' % (branch1, branch2, ancestor, output)) #ret = os.system( # 'xxdiff --title1 current --title2 ancestor --title3 patched ' # '--show-merged-pane -m -E -O -X -M "%s" "%s" "%s" "%s"' # % (output, branch1, ancestor, branch2)) # error in the interactive merger, just exit if ret: sys.exit(2) # check for file modification if not os.path.exists(output) or mtime == os.path.getmtime(output): sys.exit(3) # everything's fine sys.exit(0)