Permalink
Browse files

Allow to diff by package name

  • Loading branch information...
1 parent 962bce9 commit eef57f0ff06efd684df086b0a7558c1e4893c1bc @kolmodin kolmodin committed Oct 4, 2008
Showing with 12 additions and 1 deletion.
  1. +11 −1 Diff.hs
  2. +1 −0 Main.hs
View
12 Diff.hs
@@ -3,6 +3,7 @@ module Diff
, DiffMode(..)
) where
+import Control.Monad ( forM_ )
import Data.Char
import qualified Data.Map as Map
import Network.URI
@@ -21,6 +22,7 @@ data DiffMode
| ShowAdditions
| ShowNewer
| ShowCommon
+ | ShowPackages [String]
deriving Eq
data DiffState a
@@ -48,7 +50,14 @@ runDiff verbosity overlayPath serverURI dm = do
overlayTree <- readPortageTree overlayPath
let (hackageTree, clashes) = indexToPortage cache overlayTree
mapM_ putStrLn clashes
- diff hackageTree overlayTree dm
+ case dm of
+ ShowPackages pkgs ->
+ forM_ pkgs $ \ pkg -> do
+ let criteria = Map.filterWithKey (\k _ -> pPackage k == pkg)
+ subHackage = criteria hackageTree
+ subOverlay = criteria overlayTree
+ diff subHackage subOverlay dm
+ _ -> diff hackageTree overlayTree dm
diff :: Portage -> Portage -> DiffMode -> IO ()
diff pt1 pt2 mode = do
@@ -73,5 +82,6 @@ diff pt1 pt2 mode = do
OnlyLeft _ -> False
Both x y -> x == y
OnlyRight _ -> False
+ ShowPackages _ -> True
let packages = filter (showFilter . snd) (Map.assocs union)
mapM_ (putStrLn . uncurry showDiffState) packages
View
@@ -211,6 +211,7 @@ diffAction flags args globalFlags = do
["additions"] -> return ShowAdditions
["newer"] -> return ShowNewer
["common"] -> return ShowCommon
+ ("package": pkgs) -> return (ShowPackages pkgs)
-- TODO: ["package",packagePattern] ->
-- return ShowPackagePattern packagePattern
_ -> die $ "Unknown mode: " ++ unwords args

0 comments on commit eef57f0

Please sign in to comment.