aboutsummaryrefslogtreecommitdiff
path: root/Command/VAdd.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Command/VAdd.hs')
-rw-r--r--Command/VAdd.hs22
1 files changed, 8 insertions, 14 deletions
diff --git a/Command/VAdd.hs b/Command/VAdd.hs
index d7dee9fb7..3dc1fd4cf 100644
--- a/Command/VAdd.hs
+++ b/Command/VAdd.hs
@@ -10,12 +10,11 @@ module Command.VAdd where
import Common.Annex
import Command
import Annex.View
-import Logs.View
import Command.View (paramView, parseViewParam, checkoutViewBranch)
def :: [Command]
def = [notBareRepo $ notDirect $
- command "vadd" paramView seek SectionMetaData "refine current view"]
+ command "vadd" paramView seek SectionMetaData "add subdirs to current view"]
seek :: CommandSeek
seek = withWords start
@@ -23,20 +22,15 @@ 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)
+ withCurrentView $ \view -> do
+ let (view', change) = refineView view $
+ map parseViewParam $ reverse params
case change of
Unchanged -> do
showNote "unchanged"
next $ next $ return True
- Narrowing -> next $ next $
- checkoutViewBranch view' narrowView
+ Narrowing -> next $ next $ do
+ if visibleViewSize view' == visibleViewSize view
+ then error "That would not add an additional level of directory structure to the view. To filter the view, use vfilter instead of vadd."
+ else checkoutViewBranch view' narrowView
Widening -> error "Widening view to match more files is not currently supported."
-
- 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