add vcycle command

This commit is contained in:
Joey Hess 2014-02-18 20:16:28 -04:00
parent f603692a72
commit 67a5f02a0b
4 changed files with 57 additions and 3 deletions

View file

@ -30,6 +30,7 @@ import qualified Command.MetaData
import qualified Command.View import qualified Command.View
import qualified Command.VAdd import qualified Command.VAdd
import qualified Command.VPop import qualified Command.VPop
import qualified Command.VCycle
import qualified Command.Reinject import qualified Command.Reinject
import qualified Command.Fix import qualified Command.Fix
import qualified Command.Init import qualified Command.Init
@ -142,6 +143,7 @@ cmds = concat
, Command.View.def , Command.View.def
, Command.VAdd.def , Command.VAdd.def
, Command.VPop.def , Command.VPop.def
, Command.VCycle.def
, Command.Fix.def , Command.Fix.def
, Command.Fsck.def , Command.Fsck.def
, Command.Repair.def , Command.Repair.def

45
Command/VCycle.hs Normal file
View file

@ -0,0 +1,45 @@
{- git-annex command
-
- Copyright 2014 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.VCycle where
import Common.Annex
import Command
import Annex.View
import Types.View
import Logs.View
import Command.View (checkoutViewBranch)
def :: [Command]
def = [notBareRepo $ notDirect $
command "vcycle" paramNothing seek SectionUtility
"switch view to next layout"]
seek :: CommandSeek
seek = withNothing start
start ::CommandStart
start = go =<< currentView
where
go Nothing = error "Not in a view."
go (Just v) = do
let v' = v { viewComponents = vcycle [] (viewComponents v) }
if v == v'
then do
showNote "unchanged"
next $ next $ return True
else next $ perform v'
vcycle rest (c:cs)
| multiValue (viewFilter c) = rest ++ cs ++ [c]
| otherwise = vcycle (c:rest) cs
vcycle rest c = rest ++ c
perform :: View -> CommandPerform
perform view = do
branch <- narrowView 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. to limit them to acting on files that have particular metadata.
* view: New command that creates and checks out a branch that provides * view: New command that creates and checks out a branch that provides
a structured view of selected metadata. a structured view of selected metadata.
* vadd, vpop: New commands for operating within views. * vadd, vpop, vcycle: New commands for operating within views.
* Add progress display for transfers to/from external special remotes. * 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 set up box.com, Amazon S3, and rsync.net remotes
* Windows webapp: Can create repos on removable drives. * Windows webapp: Can create repos on removable drives.

View file

@ -326,14 +326,21 @@ subdirectories).
When multiple field values match, the view branch will have a When multiple field values match, the view branch will have a
subdirectory for each value. subdirectory for each value.
* `vpop`
Switches from the currently active view back to the previous view.
Or, from the first view back to original branch.
* `vadd [field=value ...] [tag ...]` * `vadd [field=value ...] [tag ...]`
Refines the currently checked out view branch, adding additional fields Refines the currently checked out view branch, adding additional fields
or tags. or tags.
* `vpop` * `vcycle`
Switches from the currently active view back to the previous view. When a view involves nested subdirectories, this cycles the order.
For example, when the view has date/author/tag, vcycle will switch
it to author/tag/date.
# REPOSITORY SETUP COMMANDS # REPOSITORY SETUP COMMANDS