Skip to content

Commit

Permalink
Allow to diff by package name
Browse files Browse the repository at this point in the history
  • Loading branch information
kolmodin committed Oct 4, 2008
1 parent 962bce9 commit eef57f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Diff.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Diff
, DiffMode(..) , DiffMode(..)
) where ) where


import Control.Monad ( forM_ )
import Data.Char import Data.Char
import qualified Data.Map as Map import qualified Data.Map as Map
import Network.URI import Network.URI
Expand All @@ -21,6 +22,7 @@ data DiffMode
| ShowAdditions | ShowAdditions
| ShowNewer | ShowNewer
| ShowCommon | ShowCommon
| ShowPackages [String]
deriving Eq deriving Eq


data DiffState a data DiffState a
Expand Down Expand Up @@ -48,7 +50,14 @@ runDiff verbosity overlayPath serverURI dm = do
overlayTree <- readPortageTree overlayPath overlayTree <- readPortageTree overlayPath
let (hackageTree, clashes) = indexToPortage cache overlayTree let (hackageTree, clashes) = indexToPortage cache overlayTree
mapM_ putStrLn clashes 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 :: Portage -> Portage -> DiffMode -> IO ()
diff pt1 pt2 mode = do diff pt1 pt2 mode = do
Expand All @@ -73,5 +82,6 @@ diff pt1 pt2 mode = do
OnlyLeft _ -> False OnlyLeft _ -> False
Both x y -> x == y Both x y -> x == y
OnlyRight _ -> False OnlyRight _ -> False
ShowPackages _ -> True
let packages = filter (showFilter . snd) (Map.assocs union) let packages = filter (showFilter . snd) (Map.assocs union)
mapM_ (putStrLn . uncurry showDiffState) packages mapM_ (putStrLn . uncurry showDiffState) packages
1 change: 1 addition & 0 deletions Main.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ diffAction flags args globalFlags = do
["additions"] -> return ShowAdditions ["additions"] -> return ShowAdditions
["newer"] -> return ShowNewer ["newer"] -> return ShowNewer
["common"] -> return ShowCommon ["common"] -> return ShowCommon
("package": pkgs) -> return (ShowPackages pkgs)
-- TODO: ["package",packagePattern] -> -- TODO: ["package",packagePattern] ->
-- return ShowPackagePattern packagePattern -- return ShowPackagePattern packagePattern
_ -> die $ "Unknown mode: " ++ unwords args _ -> die $ "Unknown mode: " ++ unwords args
Expand Down

0 comments on commit eef57f0

Please sign in to comment.