[Pkg-haskell-commits] darcs: tools: Better error reporting in haskell-pkg-debcheck

Joachim Breitner mail at joachim-breitner.de
Mon Apr 11 09:20:35 UTC 2011


Mon Apr 11 09:20:08 UTC 2011  Joachim Breitner <mail at joachim-breitner.de>
  * Better error reporting in haskell-pkg-debcheck
  Ignore-this: 34476c1ba1a7122e5eb1353700eaaaf0

    M ./haskell-pkg-debcheck.hs -5 +13

Mon Apr 11 09:20:08 UTC 2011  Joachim Breitner <mail at joachim-breitner.de>
  * Better error reporting in haskell-pkg-debcheck
  Ignore-this: 34476c1ba1a7122e5eb1353700eaaaf0
diff -rN -u old-tools/haskell-pkg-debcheck.hs new-tools/haskell-pkg-debcheck.hs
--- old-tools/haskell-pkg-debcheck.hs	2011-04-11 09:20:34.925791740 +0000
+++ new-tools/haskell-pkg-debcheck.hs	2011-04-11 09:20:34.929791950 +0000
@@ -20,11 +20,15 @@
 import Debian.Version
 import Debian.Version.ByteString
 import qualified Data.Map as M
-import Data.Map ((!))
+-- import Data.Map ((!))
 import qualified Data.Set as S
 import Debug.Trace
 import Text.Printf
 
+m ! k = case M.lookup k m of
+    Just x -> x 
+    Nothing -> error $ "Could not find " ++ show m ++ " in map " ++ show (take 2 (M.toList m)) ++ ".."
+
 type Arch = String
 
 arches :: [Arch]
@@ -66,7 +70,7 @@
     binaryMap <- 
         fmap M.unions $
         forM arches $ \arch ->
-            toBinaryMap arch (M.keysSet bToS) <$>
+            toBinaryMap arch bToS <$>
             (either (error.show) id) <$>
             parseControl "Binary" <$>
             BS.concat <$>
@@ -191,17 +195,18 @@
     ) .
     unControl
 
-toBinaryMap arch interesting = 
+toBinaryMap arch bToS = 
     M.fromList . 
     mapMaybe (\para -> do -- Maybe monad
         p <- BS.unpack <$>
              fieldValue "Package" para
-        guard (p `S.member` interesting)
+        guard (p `M.member` bToS)
         guard (isNotIgnored p)
         v <- parseDebianVersion <$>
              fieldValue "Version" para
         s <- BS.unpack <$>
              fieldValue "Source" para
+        guard (s == bToS ! p)
         -- extract the source version if available
         let sv = case words s of
                     [_,('(':sv)] -> parseDebianVersion (init sv)
@@ -221,7 +226,10 @@
         -- Consider all the posibilities here: What if wanna-build is newer,
         -- what if it is older?
         when (v /= siVersion (sourcesMap ! s)) $ 
-            trace (printf "Version difference: %s and %s\n" (show v) (show (siVersion (sourcesMap ! s)))) $
+            trace (printf "Version difference for %s: wb knows %s and Sources knows %s\n"
+                  s
+                  (show v)
+                  (show (siVersion (sourcesMap ! s)))) $
             return ()
         guard (v == siVersion (sourcesMap ! s))
         st <- BS.unpack <$>





More information about the Pkg-haskell-commits mailing list