view, vfilter: Add support for filtering tags and values out of a view, using !tag and field!=value.

Note that negated globs are not supported. Would have complicated the code
to add them, without changing the data type serialization in a
non-backwards-compatable way.

This commit was sponsored by Denver Gingerich.
This commit is contained in:
Joey Hess 2014-03-02 14:53:19 -04:00
parent 2432ecbdcc
commit c2e8c21ca6
8 changed files with 82 additions and 40 deletions

View file

@ -13,8 +13,6 @@ import qualified Git
import qualified Git.Command
import qualified Git.Ref
import qualified Git.Branch
import Types.MetaData
import Annex.MetaData
import Types.View
import Annex.View
import Logs.View
@ -46,18 +44,6 @@ perform view = do
paramView :: String
paramView = paramPair (paramRepeating "TAG") (paramRepeating "FIELD=VALUE")
{- Parse field=value
-
- Note that the field may not be a legal metadata field name,
- but it's let through anyway.
- This is useful when matching on directory names with spaces,
- which are not legal MetaFields.
-}
parseViewParam :: String -> (MetaField, String)
parseViewParam s = case separate (== '=') s of
(tag, []) -> (tagMetaField, tag)
(field, wanted) -> (mkMetaFieldUnchecked field, wanted)
mkView :: [String] -> Annex View
mkView params = do
v <- View <$> viewbranch <*> pure []