add vadd command

This commit is contained in:
Joey Hess 2014-02-18 20:01:56 -04:00
parent 5790acc19f
commit f603692a72
5 changed files with 53 additions and 9 deletions

View file

@ -28,6 +28,7 @@ import qualified Command.TransferKeys
import qualified Command.ReKey
import qualified Command.MetaData
import qualified Command.View
import qualified Command.VAdd
import qualified Command.VPop
import qualified Command.Reinject
import qualified Command.Fix
@ -139,6 +140,7 @@ cmds = concat
, Command.ReKey.def
, Command.MetaData.def
, Command.View.def
, Command.VAdd.def
, Command.VPop.def
, Command.Fix.def
, Command.Fsck.def

47
Command/VAdd.hs Normal file
View file

@ -0,0 +1,47 @@
{- git-annex command
-
- Copyright 2014 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.VAdd where
import Common.Annex
import Command
import Types.View
import Annex.View
import Logs.View
import Command.View (paramView, parseViewParam, checkoutViewBranch)
def :: [Command]
def = [notBareRepo $ notDirect $
command "vadd" paramView seek SectionUtility "refine current view"]
seek :: CommandSeek
seek = withWords start
start :: [String] -> CommandStart
start params = do
showStart "vadd" ""
go =<< currentView
where
go Nothing = error "Not in a view."
go (Just view) = do
let (view', change) = calc view Unchanged (reverse params)
case change of
Unchanged -> do
showNote "unchanged"
next $ next $ return True
Widening -> error "Widening view to match more files is not currently supported."
Narrowing -> next $ perform view'
calc v c [] = (v, c)
calc v c (p:ps) =
let (v', c') = uncurry (refineView v) (parseViewParam p)
in calc v' (max c c') ps
perform :: View -> CommandPerform
perform view = do
branch <- narrowView view
next $ checkoutViewBranch view branch

View file

@ -39,7 +39,7 @@ start params = do
perform :: View -> CommandPerform
perform view = do
showSideAction "calculating"
showSideAction "searching"
branch <- applyView view
next $ checkoutViewBranch view branch

2
debian/changelog vendored
View file

@ -7,7 +7,7 @@ git-annex (5.20140211) UNRELEASED; urgency=medium
to limit them to acting on files that have particular metadata.
* view: New command that creates and checks out a branch that provides
a structured view of selected metadata.
* vadd, vrm, vpop: New commands for operating within views.
* vadd, vpop: New commands for operating within views.
* Add progress display for transfers to/from external special remotes.
* Windows webapp: Can set up box.com, Amazon S3, and rsync.net remotes
* Windows webapp: Can create repos on removable drives.

View file

@ -328,13 +328,8 @@ subdirectories).
* `vadd [field=value ...] [tag ...]`
Can be used when already in a view to add additional fields or tags
to the view.
* `vrm [field=value ...] [tag ...]`
Can be used when already in a view to remove fields or tags from the
view.
Refines the currently checked out view branch, adding additional fields
or tags.
* `vpop`