From 5463fc4d8df52be0c0232f1c44956b2227ad193c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 22 Feb 2014 16:09:00 -0400 Subject: views: add automatically constructed file location metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When constructing views, metadata is available about the location of the file in the view's reference branch. Allows incorporating parts of the directory hierarchy in a view. For example `git annex view tag=* podcasts/=*` makes a view in the form tag/showname. Performance impact: I benchmarked git annex view tag=* in the conference proceedings repo to take 6.459s before this change, and 6.544s after. FWIW, I considered making the syntax for this be podcasts/*, which might be easier for the user to learn. However, I think it's not as good: * The user has to then juggle two different syntaxes, and podcasts/* will be expanded by the shell so they also need to quote it, while podcasts/=* is unlikely to be expanded by the shell. * It would allow for things like podcasts/*/* and *.mp3 which do not map well into views. This commit was sponsored by Aurélien Pinceaux. --- Command/VAdd.hs | 6 +++--- Command/View.hs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'Command') diff --git a/Command/VAdd.hs b/Command/VAdd.hs index 3dc1fd4cf..6b53aa7ea 100644 --- a/Command/VAdd.hs +++ b/Command/VAdd.hs @@ -10,11 +10,11 @@ module Command.VAdd where import Common.Annex import Command import Annex.View -import Command.View (paramView, parseViewParam, checkoutViewBranch) +import Command.View (parseViewParam, checkoutViewBranch) def :: [Command] -def = [notBareRepo $ notDirect $ - command "vadd" paramView seek SectionMetaData "add subdirs to current view"] +def = [notBareRepo $ notDirect $ command "vadd" (paramRepeating "FIELD=GLOB") + seek SectionMetaData "add subdirs to current view"] seek :: CommandSeek seek = withWords start diff --git a/Command/View.hs b/Command/View.hs index 17e136f7b..ea63d39fd 100644 --- a/Command/View.hs +++ b/Command/View.hs @@ -43,7 +43,7 @@ perform view = do next $ checkoutViewBranch view applyView paramView :: String -paramView = paramPair (paramRepeating "FIELD=VALUE") (paramRepeating "TAG") +paramView = paramPair (paramRepeating "TAG") (paramRepeating "FIELD=VALUE") parseViewParam :: String -> (MetaField, String) parseViewParam s = case separate (== '=') s of -- cgit v1.2.3