summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CmdLine/GitAnnex.hs2
-rw-r--r--Command/VCycle.hs45
-rw-r--r--debian/changelog2
-rw-r--r--doc/git-annex.mdwn11
4 files changed, 57 insertions, 3 deletions
diff --git a/CmdLine/GitAnnex.hs b/CmdLine/GitAnnex.hs
index 2bbab6eb0..c8325872d 100644
--- a/CmdLine/GitAnnex.hs
+++ b/CmdLine/GitAnnex.hs
@@ -30,6 +30,7 @@ import qualified Command.MetaData
import qualified Command.View
import qualified Command.VAdd
import qualified Command.VPop
+import qualified Command.VCycle
import qualified Command.Reinject
import qualified Command.Fix
import qualified Command.Init
@@ -142,6 +143,7 @@ cmds = concat
, Command.View.def
, Command.VAdd.def
, Command.VPop.def
+ , Command.VCycle.def
, Command.Fix.def
, Command.Fsck.def
, Command.Repair.def
diff --git a/Command/VCycle.hs b/Command/VCycle.hs
new file mode 100644
index 000000000..c32ce2eb1
--- /dev/null
+++ b/Command/VCycle.hs
@@ -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
diff --git a/debian/changelog b/debian/changelog
index 167d026cc..f1afdb821 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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, 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.
* Windows webapp: Can set up box.com, Amazon S3, and rsync.net remotes
* Windows webapp: Can create repos on removable drives.
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index b96cedbfe..3b9a227be 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -326,14 +326,21 @@ subdirectories).
When multiple field values match, the view branch will have a
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 ...]`
Refines the currently checked out view branch, adding additional fields
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