Is that some thing you want to see? Maybe clean up the error printing.
Chris
--- /dev/null 2003-01-30 05:24:37.000000000 -0500
+++ merge.py 2005-04-14 16:34:39.000000000 -0400
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+
+import re
+import sys
+import os
+from pprint import pprint
+
+def get_tree(commit):
+ data = os.popen("cat-file commit %s"%commit).read()
+ return re.findall(r"(?m)^tree (\w+)", data)[0]
+
+PREFIX = 0
+PATH = -1
+SHA = -2
+ORIGSHA = -3
+
+def get_difftree(old, new):
+ lines = os.popen("diff-tree %s %s"%(old, new)).read().split("\x00")
+ patterns = (r"(\*)(\d+)->(\d+)\s(\w+)\s(\w+)->(\w+)\s(.*)",
+ r"([+-])(\d+)\s(\w+)\s(\w+)\s(.*)")
+ res = {}
+ for l in lines:
+ if not l: continue
+ for p in patterns:
+ m = re.findall(p, l)
+ if m:
+ m = m[0]
+ res[m[-1]] = m
+ break
+ else:
+ raise "difftree: unknow line", l
+ return res
+
+def analyze(diff1, diff2):
+ diff1only = [ diff1[k] for k in diff1 if k not in diff2 ]
+ diff2only = [ diff2[k] for k in diff2 if k not in diff1 ]
+ both = [ (diff1[k],diff2[k]) for k in diff2 if k in diff1 ]
+
+ action(diff1only)
+ action(diff2only)
+ action_two(both)
+
+def action(diffs):
+ for act in diffs:
+ if act[PREFIX] == "*":
+ print "modify", act[PATH], act[SHA]
+ elif act[PREFIX] == '-':
+ print "remove", act[PATH], act[SHA]
+ elif act[PREFIX] == '+':
+ print "add", act[PATH], act[SHA]
+ else:
+ raise "unknow action"
+
+def action_two(diffs):
+ for act1, act2 in diffs:
+ if len(act1) == len(act2): # same kind type
+ if act1[PREFIX] == act2[PREFIX]:
+ if act1[SHA] == act2[SHA] or act1[PREFIX] == '-':
+ return action(act1)
+ if act1[PREFIX]=='*':
+ print "do_merge", act1[PATH], act1[ORIGSHA], act1[SHA],
act2[SHA]
+ return
+ print "unable to handle", act[PATH]
+ print "one side wants", act1[PREFIX]
+ print "the other side wants", act2[PREFIX]
+
+
+args = sys.argv[1:]
+if len(args)!=3:
+ print "Usage merge.py <common> <rev1> <rev2>"
+trees = map(get_tree, args)
+print "checkout-tree", trees[0]
+diff1 = get_difftree(trees[0], trees[1])
+diff2 = get_difftree(trees[0], trees[2])
+analyze(diff1, diff2)
+
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html