]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add a simple script which drives 'kdiff3' through a large source tree
authorJulian Seward <jseward@acm.org>
Tue, 17 Oct 2006 21:04:15 +0000 (21:04 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 17 Oct 2006 21:04:15 +0000 (21:04 +0000)
(3 such trees, really).  This makes it easy to do 3 way merges of such
trees and easily stop and resume without losing work.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6312

auxprogs/Makefile.am
auxprogs/Merge3Way.hs [new file with mode: 0644]

index 58057661bf025ae7dbbfe239acc2a81de128fd95..7d547773da77829da7e9004deaf06cfd1b8a0147 100644 (file)
@@ -3,7 +3,7 @@ include $(top_srcdir)/Makefile.core.am
 
 bin_PROGRAMS = valgrind-listener
 
-noinst_SCRIPTS = gen-mdg DotToScc.hs primes.c \
+noinst_SCRIPTS = gen-mdg DotToScc.hs Merge3Way.hs primes.c \
                gsl16test gsl16-badfree.patch gsl16-wavelet.patch \
                ppcfround.c ppc64shifts.c libmpiwrap.c mpiwrap_type_test.c \
                aix5_VKI_info.c libmpiwrap_aix5.exp \
diff --git a/auxprogs/Merge3Way.hs b/auxprogs/Merge3Way.hs
new file mode 100644 (file)
index 0000000..5ca6f06
--- /dev/null
@@ -0,0 +1,66 @@
+
+module Main where
+
+import IO
+import Directory
+import System
+
+dirAA = "in-AAcommon-6077-1660"
+dirBB = "in-BBtrunk"
+dirCC = "in-CCaixbranch"
+dirRR = "RESULT"
+
+maybe_do :: String -> IO ()
+maybe_do f
+   = let r = dirRR ++ "/" ++ f
+         a = dirAA ++ "/" ++ f
+         b = dirBB ++ "/" ++ f
+         c = dirCC ++ "/" ++ f
+     in
+     do x <- doesFileExist r
+        if x
+         then hPutStrLn stderr ("done: " ++ f)
+         else 
+          do hPutStrLn stderr ("  do: " ++ f)
+             xx <- system ("mkdir -p " ++ basename r)
+             rs <- merge3 r a b c
+             hPutStrLn stderr (rs ++ f)
+
+
+merge3 :: String -> String -> String -> String -> IO String
+merge3 r a b c
+   = do ca <- readFile a
+        cb <- readFile b
+        cc <- readFile c
+        let same = identical3 ca cb cc
+        if same
+         then 
+          do ec <- system ("/bin/cp " ++ a ++ " " ++ r)
+             if ec == ExitSuccess
+              then return "COPY: "
+              else barf "/bin/cp failed"
+         else 
+          do ec <- system ("kdiff3 -m -o " ++ r ++ " -b " 
+                           ++ a ++ " " ++ b ++ " " ++ c ++ " &> /dev/null" )
+             if ec == ExitSuccess
+              then return "  ok: "
+              else barf "kdiff3 failed"
+
+barf :: String -> IO a
+barf who
+   = do hPutStrLn stderr ("FAIL: " ++ who)
+        exitWith ExitSuccess
+
+identical3 :: String -> String -> String -> Bool
+identical3 [] [] [] = True
+identical3 (x:xs) (y:ys) (z:zs)
+   = x == y && y == z && identical3 xs ys zs
+identical3 _ _ _ = False
+
+main :: IO ()
+main
+   = do t <- readFile "FILEScba"
+        let fs = lines t
+        mapM_ maybe_do fs
+
+basename = reverse . drop 1 . dropWhile (/= '/') . reverse