|
From: <sv...@va...> - 2006-10-17 21:04:17
|
Author: sewardj
Date: 2006-10-17 22:04:15 +0100 (Tue, 17 Oct 2006)
New Revision: 6312
Log:
Add a simple script which drives 'kdiff3' through a large source tree
(3 such trees, really). This makes it easy to do 3 way merges of such
trees and easily stop and resume without losing work.
Added:
trunk/auxprogs/Merge3Way.hs
Modified:
trunk/auxprogs/Makefile.am
Modified: trunk/auxprogs/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/auxprogs/Makefile.am 2006-10-17 20:47:13 UTC (rev 6311)
+++ trunk/auxprogs/Makefile.am 2006-10-17 21:04:15 UTC (rev 6312)
@@ -3,7 +3,7 @@
=20
bin_PROGRAMS =3D valgrind-listener
=20
-noinst_SCRIPTS =3D gen-mdg DotToScc.hs primes.c \
+noinst_SCRIPTS =3D 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 \
Added: trunk/auxprogs/Merge3Way.hs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/auxprogs/Merge3Way.hs (rev 0)
+++ trunk/auxprogs/Merge3Way.hs 2006-10-17 21:04:15 UTC (rev 6312)
@@ -0,0 +1,66 @@
+
+module Main where
+
+import IO
+import Directory
+import System
+
+dirAA =3D "in-AAcommon-6077-1660"
+dirBB =3D "in-BBtrunk"
+dirCC =3D "in-CCaixbranch"
+dirRR =3D "RESULT"
+
+maybe_do :: String -> IO ()
+maybe_do f
+ =3D let r =3D dirRR ++ "/" ++ f
+ a =3D dirAA ++ "/" ++ f
+ b =3D dirBB ++ "/" ++ f
+ c =3D dirCC ++ "/" ++ f
+ in
+ do x <- doesFileExist r
+ if x
+ then hPutStrLn stderr ("done: " ++ f)
+ else=20
+ 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
+ =3D do ca <- readFile a
+ cb <- readFile b
+ cc <- readFile c
+ let same =3D identical3 ca cb cc
+ if same
+ then=20
+ do ec <- system ("/bin/cp " ++ a ++ " " ++ r)
+ if ec =3D=3D ExitSuccess
+ then return "COPY: "
+ else barf "/bin/cp failed"
+ else=20
+ do ec <- system ("kdiff3 -m -o " ++ r ++ " -b "=20
+ ++ a ++ " " ++ b ++ " " ++ c ++ " &> /dev/nul=
l" )
+ if ec =3D=3D ExitSuccess
+ then return " ok: "
+ else barf "kdiff3 failed"
+
+barf :: String -> IO a
+barf who
+ =3D do hPutStrLn stderr ("FAIL: " ++ who)
+ exitWith ExitSuccess
+
+identical3 :: String -> String -> String -> Bool
+identical3 [] [] [] =3D True
+identical3 (x:xs) (y:ys) (z:zs)
+ =3D x =3D=3D y && y =3D=3D z && identical3 xs ys zs
+identical3 _ _ _ =3D False
+
+main :: IO ()
+main
+ =3D do t <- readFile "FILEScba"
+ let fs =3D lines t
+ mapM_ maybe_do fs
+
+basename =3D reverse . drop 1 . dropWhile (/=3D '/') . reverse
|