move commandAction out of CmdLine.Seek
This is groundwork for nested seek loops, eg seeking over all files and then performing commandActions on a list of remotes, which can be done concurrently. This commit was sponsored by Boyd Stephen Smith Jr. on Patreon.
This commit is contained in:
parent
47707608b1
commit
53526136e8
80 changed files with 169 additions and 156 deletions
|
@ -78,6 +78,9 @@ commandAction a = go =<< Annex.getState Annex.concurrency
|
||||||
go NonConcurrent = run
|
go NonConcurrent = run
|
||||||
run = void $ includeCommandAction a
|
run = void $ includeCommandAction a
|
||||||
|
|
||||||
|
commandActions :: [CommandStart] -> Annex ()
|
||||||
|
commandActions = mapM_ commandAction
|
||||||
|
|
||||||
{- Waits for any forked off command actions to finish.
|
{- Waits for any forked off command actions to finish.
|
||||||
-
|
-
|
||||||
- Merge together the cleanup actions of all the AnnexStates used by
|
- Merge together the cleanup actions of all the AnnexStates used by
|
||||||
|
|
|
@ -22,7 +22,6 @@ import qualified Git.LsTree as LsTree
|
||||||
import Git.FilePath
|
import Git.FilePath
|
||||||
import qualified Limit
|
import qualified Limit
|
||||||
import CmdLine.GitAnnex.Options
|
import CmdLine.GitAnnex.Options
|
||||||
import CmdLine.Action
|
|
||||||
import Logs.Location
|
import Logs.Location
|
||||||
import Logs.Unused
|
import Logs.Unused
|
||||||
import Types.Transfer
|
import Types.Transfer
|
||||||
|
@ -34,11 +33,11 @@ import Annex.Content
|
||||||
import Annex.InodeSentinal
|
import Annex.InodeSentinal
|
||||||
import qualified Database.Keys
|
import qualified Database.Keys
|
||||||
|
|
||||||
withFilesInGit :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
|
withFilesInGit :: (FilePath -> CommandSeek) -> [WorkTreeItem] -> CommandSeek
|
||||||
withFilesInGit a l = seekActions $ prepFiltered a $
|
withFilesInGit a l = seekActions $ prepFiltered a $
|
||||||
seekHelper LsFiles.inRepo l
|
seekHelper LsFiles.inRepo l
|
||||||
|
|
||||||
withFilesInGitNonRecursive :: String -> (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
|
withFilesInGitNonRecursive :: String -> (FilePath -> CommandSeek) -> [WorkTreeItem] -> CommandSeek
|
||||||
withFilesInGitNonRecursive needforce a l = ifM (Annex.getState Annex.force)
|
withFilesInGitNonRecursive needforce a l = ifM (Annex.getState Annex.force)
|
||||||
( withFilesInGit a l
|
( withFilesInGit a l
|
||||||
, if null l
|
, if null l
|
||||||
|
@ -58,7 +57,7 @@ withFilesInGitNonRecursive needforce a l = ifM (Annex.getState Annex.force)
|
||||||
getfiles c ps
|
getfiles c ps
|
||||||
_ -> giveup needforce
|
_ -> giveup needforce
|
||||||
|
|
||||||
withFilesNotInGit :: Bool -> (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
|
withFilesNotInGit :: Bool -> (FilePath -> CommandSeek) -> [WorkTreeItem] -> CommandSeek
|
||||||
withFilesNotInGit skipdotfiles a l
|
withFilesNotInGit skipdotfiles a l
|
||||||
| skipdotfiles = do
|
| skipdotfiles = do
|
||||||
{- dotfiles are not acted on unless explicitly listed -}
|
{- dotfiles are not acted on unless explicitly listed -}
|
||||||
|
@ -78,7 +77,7 @@ withFilesNotInGit skipdotfiles a l
|
||||||
go fs = seekActions $ prepFiltered a $
|
go fs = seekActions $ prepFiltered a $
|
||||||
return $ concat $ segmentPaths (map (\(WorkTreeItem f) -> f) l) fs
|
return $ concat $ segmentPaths (map (\(WorkTreeItem f) -> f) l) fs
|
||||||
|
|
||||||
withFilesInRefs :: (FilePath -> Key -> CommandStart) -> [Git.Ref] -> CommandSeek
|
withFilesInRefs :: ((FilePath, Key) -> CommandSeek) -> [Git.Ref] -> CommandSeek
|
||||||
withFilesInRefs a = mapM_ go
|
withFilesInRefs a = mapM_ go
|
||||||
where
|
where
|
||||||
go r = do
|
go r = do
|
||||||
|
@ -89,16 +88,17 @@ withFilesInRefs a = mapM_ go
|
||||||
catKey (LsTree.sha i) >>= \case
|
catKey (LsTree.sha i) >>= \case
|
||||||
Nothing -> noop
|
Nothing -> noop
|
||||||
Just k -> whenM (matcher $ MatchingKey k) $
|
Just k -> whenM (matcher $ MatchingKey k) $
|
||||||
commandAction $ a f k
|
a (f, k)
|
||||||
liftIO $ void cleanup
|
liftIO $ void cleanup
|
||||||
|
|
||||||
withPathContents :: ((FilePath, FilePath) -> CommandStart) -> CmdParams -> CommandSeek
|
withPathContents :: ((FilePath, FilePath) -> CommandSeek) -> CmdParams -> CommandSeek
|
||||||
withPathContents a params = do
|
withPathContents a params = do
|
||||||
matcher <- Limit.getMatcher
|
matcher <- Limit.getMatcher
|
||||||
forM_ params $ \p -> do
|
forM_ params $ \p -> do
|
||||||
fs <- liftIO $ get p
|
fs <- liftIO $ get p
|
||||||
forM fs $ \f -> whenM (checkmatch matcher f) $
|
forM fs $ \f ->
|
||||||
commandAction (a f)
|
whenM (checkmatch matcher f) $
|
||||||
|
a f
|
||||||
where
|
where
|
||||||
get p = ifM (isDirectory <$> getFileStatus p)
|
get p = ifM (isDirectory <$> getFileStatus p)
|
||||||
( map (\f -> (f, makeRelative (parentDir p) f))
|
( map (\f -> (f, makeRelative (parentDir p) f))
|
||||||
|
@ -110,24 +110,24 @@ withPathContents a params = do
|
||||||
, matchFile = relf
|
, matchFile = relf
|
||||||
}
|
}
|
||||||
|
|
||||||
withWords :: ([String] -> CommandStart) -> CmdParams -> CommandSeek
|
withWords :: ([String] -> CommandSeek) -> CmdParams -> CommandSeek
|
||||||
withWords a params = seekActions $ return [a params]
|
withWords a params = seekActions $ return [a params]
|
||||||
|
|
||||||
withStrings :: (String -> CommandStart) -> CmdParams -> CommandSeek
|
withStrings :: (String -> CommandSeek) -> CmdParams -> CommandSeek
|
||||||
withStrings a params = seekActions $ return $ map a params
|
withStrings a params = seekActions $ return $ map a params
|
||||||
|
|
||||||
withPairs :: ((String, String) -> CommandStart) -> CmdParams -> CommandSeek
|
withPairs :: ((String, String) -> CommandSeek) -> CmdParams -> CommandSeek
|
||||||
withPairs a params = seekActions $ return $ map a $ pairs [] params
|
withPairs a params = seekActions $ return $ map a $ pairs [] params
|
||||||
where
|
where
|
||||||
pairs c [] = reverse c
|
pairs c [] = reverse c
|
||||||
pairs c (x:y:xs) = pairs ((x,y):c) xs
|
pairs c (x:y:xs) = pairs ((x,y):c) xs
|
||||||
pairs _ _ = giveup "expected pairs"
|
pairs _ _ = giveup "expected pairs"
|
||||||
|
|
||||||
withFilesToBeCommitted :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
|
withFilesToBeCommitted :: (FilePath -> CommandSeek) -> [WorkTreeItem] -> CommandSeek
|
||||||
withFilesToBeCommitted a l = seekActions $ prepFiltered a $
|
withFilesToBeCommitted a l = seekActions $ prepFiltered a $
|
||||||
seekHelper LsFiles.stagedNotDeleted l
|
seekHelper LsFiles.stagedNotDeleted l
|
||||||
|
|
||||||
withFilesOldUnlocked :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
|
withFilesOldUnlocked :: (FilePath -> CommandSeek) -> [WorkTreeItem] -> CommandSeek
|
||||||
withFilesOldUnlocked = withFilesOldUnlocked' LsFiles.typeChanged
|
withFilesOldUnlocked = withFilesOldUnlocked' LsFiles.typeChanged
|
||||||
|
|
||||||
{- Unlocked files before v6 have changed type from a symlink to a regular file.
|
{- Unlocked files before v6 have changed type from a symlink to a regular file.
|
||||||
|
@ -135,7 +135,7 @@ withFilesOldUnlocked = withFilesOldUnlocked' LsFiles.typeChanged
|
||||||
- Furthermore, unlocked files used to be a git-annex symlink,
|
- Furthermore, unlocked files used to be a git-annex symlink,
|
||||||
- not some other sort of symlink.
|
- not some other sort of symlink.
|
||||||
-}
|
-}
|
||||||
withFilesOldUnlocked' :: ([FilePath] -> Git.Repo -> IO ([FilePath], IO Bool)) -> (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
|
withFilesOldUnlocked' :: ([FilePath] -> Git.Repo -> IO ([FilePath], IO Bool)) -> (FilePath -> CommandSeek) -> [WorkTreeItem] -> CommandSeek
|
||||||
withFilesOldUnlocked' typechanged a l = seekActions $
|
withFilesOldUnlocked' typechanged a l = seekActions $
|
||||||
prepFiltered a unlockedfiles
|
prepFiltered a unlockedfiles
|
||||||
where
|
where
|
||||||
|
@ -145,12 +145,12 @@ isOldUnlocked :: FilePath -> Annex Bool
|
||||||
isOldUnlocked f = liftIO (notSymlink f) <&&>
|
isOldUnlocked f = liftIO (notSymlink f) <&&>
|
||||||
(isJust <$> catKeyFile f <||> isJust <$> catKeyFileHEAD f)
|
(isJust <$> catKeyFile f <||> isJust <$> catKeyFileHEAD f)
|
||||||
|
|
||||||
withFilesOldUnlockedToBeCommitted :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
|
withFilesOldUnlockedToBeCommitted :: (FilePath -> CommandSeek) -> [WorkTreeItem] -> CommandSeek
|
||||||
withFilesOldUnlockedToBeCommitted = withFilesOldUnlocked' LsFiles.typeChangedStaged
|
withFilesOldUnlockedToBeCommitted = withFilesOldUnlocked' LsFiles.typeChangedStaged
|
||||||
|
|
||||||
{- v6 unlocked pointer files that are staged, and whose content has not been
|
{- v6 unlocked pointer files that are staged, and whose content has not been
|
||||||
- modified-}
|
- modified-}
|
||||||
withUnmodifiedUnlockedPointers :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
|
withUnmodifiedUnlockedPointers :: (FilePath -> CommandSeek) -> [WorkTreeItem] -> CommandSeek
|
||||||
withUnmodifiedUnlockedPointers a l = seekActions $
|
withUnmodifiedUnlockedPointers a l = seekActions $
|
||||||
prepFiltered a unlockedfiles
|
prepFiltered a unlockedfiles
|
||||||
where
|
where
|
||||||
|
@ -163,17 +163,17 @@ isV6UnmodifiedUnlocked f = catKeyFile f >>= \case
|
||||||
Just k -> sameInodeCache f =<< Database.Keys.getInodeCaches k
|
Just k -> sameInodeCache f =<< Database.Keys.getInodeCaches k
|
||||||
|
|
||||||
{- Finds files that may be modified. -}
|
{- Finds files that may be modified. -}
|
||||||
withFilesMaybeModified :: (FilePath -> CommandStart) -> [WorkTreeItem] -> CommandSeek
|
withFilesMaybeModified :: (FilePath -> CommandSeek) -> [WorkTreeItem] -> CommandSeek
|
||||||
withFilesMaybeModified a params = seekActions $
|
withFilesMaybeModified a params = seekActions $
|
||||||
prepFiltered a $ seekHelper LsFiles.modified params
|
prepFiltered a $ seekHelper LsFiles.modified params
|
||||||
|
|
||||||
withKeys :: (Key -> CommandStart) -> CmdParams -> CommandSeek
|
withKeys :: (Key -> CommandSeek) -> CmdParams -> CommandSeek
|
||||||
withKeys a l = seekActions $ return $ map (a . parse) l
|
withKeys a l = seekActions $ return $ map (a . parse) l
|
||||||
where
|
where
|
||||||
parse p = fromMaybe (giveup "bad key") $ file2key p
|
parse p = fromMaybe (giveup "bad key") $ file2key p
|
||||||
|
|
||||||
withNothing :: CommandStart -> CmdParams -> CommandSeek
|
withNothing :: CommandSeek -> CmdParams -> CommandSeek
|
||||||
withNothing a [] = seekActions $ return [a]
|
withNothing a [] = a
|
||||||
withNothing _ _ = giveup "This command takes no parameters."
|
withNothing _ _ = giveup "This command takes no parameters."
|
||||||
|
|
||||||
{- Handles the --all, --branch, --unused, --failed, --key, and
|
{- Handles the --all, --branch, --unused, --failed, --key, and
|
||||||
|
@ -183,11 +183,12 @@ withNothing _ _ = giveup "This command takes no parameters."
|
||||||
- In a bare repo, --all is the default.
|
- In a bare repo, --all is the default.
|
||||||
-
|
-
|
||||||
- Otherwise falls back to a regular CommandSeek action on
|
- Otherwise falls back to a regular CommandSeek action on
|
||||||
- whatever params were passed. -}
|
- whatever params were passed.
|
||||||
|
-}
|
||||||
withKeyOptions
|
withKeyOptions
|
||||||
:: Maybe KeyOptions
|
:: Maybe KeyOptions
|
||||||
-> Bool
|
-> Bool
|
||||||
-> (Key -> ActionItem -> CommandStart)
|
-> ((Key, ActionItem) -> CommandSeek)
|
||||||
-> ([WorkTreeItem] -> CommandSeek)
|
-> ([WorkTreeItem] -> CommandSeek)
|
||||||
-> [WorkTreeItem]
|
-> [WorkTreeItem]
|
||||||
-> CommandSeek
|
-> CommandSeek
|
||||||
|
@ -195,14 +196,14 @@ withKeyOptions ko auto keyaction = withKeyOptions' ko auto mkkeyaction
|
||||||
where
|
where
|
||||||
mkkeyaction = do
|
mkkeyaction = do
|
||||||
matcher <- Limit.getMatcher
|
matcher <- Limit.getMatcher
|
||||||
return $ \k i ->
|
return $ \v ->
|
||||||
whenM (matcher $ MatchingKey k) $
|
whenM (matcher $ MatchingKey $ fst v) $
|
||||||
commandAction $ keyaction k i
|
keyaction v
|
||||||
|
|
||||||
withKeyOptions'
|
withKeyOptions'
|
||||||
:: Maybe KeyOptions
|
:: Maybe KeyOptions
|
||||||
-> Bool
|
-> Bool
|
||||||
-> Annex (Key -> ActionItem -> Annex ())
|
-> Annex ((Key, ActionItem) -> Annex ())
|
||||||
-> ([WorkTreeItem] -> CommandSeek)
|
-> ([WorkTreeItem] -> CommandSeek)
|
||||||
-> [WorkTreeItem]
|
-> [WorkTreeItem]
|
||||||
-> CommandSeek
|
-> CommandSeek
|
||||||
|
@ -231,14 +232,14 @@ withKeyOptions' ko auto mkkeyaction fallbackaction params = do
|
||||||
keyaction <- mkkeyaction
|
keyaction <- mkkeyaction
|
||||||
ks <- getks
|
ks <- getks
|
||||||
forM_ ks $ checker >=> maybe noop
|
forM_ ks $ checker >=> maybe noop
|
||||||
(\k -> keyaction k (mkActionItem k))
|
(\k -> keyaction (k, mkActionItem k))
|
||||||
runbranchkeys bs = do
|
runbranchkeys bs = do
|
||||||
keyaction <- mkkeyaction
|
keyaction <- mkkeyaction
|
||||||
forM_ bs $ \b -> do
|
forM_ bs $ \b -> do
|
||||||
(l, cleanup) <- inRepo $ LsTree.lsTree b
|
(l, cleanup) <- inRepo $ LsTree.lsTree b
|
||||||
forM_ l $ \i -> do
|
forM_ l $ \i -> do
|
||||||
let bfp = mkActionItem $ BranchFilePath b (LsTree.file i)
|
let bfp = mkActionItem $ BranchFilePath b (LsTree.file i)
|
||||||
maybe noop (\k -> keyaction k bfp)
|
maybe noop (\k -> keyaction (k, bfp))
|
||||||
=<< catKey (LsTree.sha i)
|
=<< catKey (LsTree.sha i)
|
||||||
unlessM (liftIO cleanup) $
|
unlessM (liftIO cleanup) $
|
||||||
error ("git ls-tree " ++ Git.fromRef b ++ " failed")
|
error ("git ls-tree " ++ Git.fromRef b ++ " failed")
|
||||||
|
@ -247,18 +248,17 @@ withKeyOptions' ko auto mkkeyaction fallbackaction params = do
|
||||||
rs <- remoteList
|
rs <- remoteList
|
||||||
ts <- concat <$> mapM (getFailedTransfers . Remote.uuid) rs
|
ts <- concat <$> mapM (getFailedTransfers . Remote.uuid) rs
|
||||||
forM_ ts $ \(t, i) ->
|
forM_ ts $ \(t, i) ->
|
||||||
keyaction (transferKey t) (mkActionItem (t, i))
|
keyaction (transferKey t, mkActionItem (t, i))
|
||||||
|
|
||||||
prepFiltered :: (FilePath -> CommandStart) -> Annex [FilePath] -> Annex [CommandStart]
|
prepFiltered :: (FilePath -> CommandSeek) -> Annex [FilePath] -> Annex [CommandSeek]
|
||||||
prepFiltered a fs = do
|
prepFiltered a fs = do
|
||||||
matcher <- Limit.getMatcher
|
matcher <- Limit.getMatcher
|
||||||
map (process matcher) <$> fs
|
map (process matcher) <$> fs
|
||||||
where
|
where
|
||||||
process matcher f = ifM (matcher $ MatchingFile $ FileInfo f f)
|
process matcher f = whenM (matcher $ MatchingFile $ FileInfo f f) $ a f
|
||||||
( a f , return Nothing )
|
|
||||||
|
|
||||||
seekActions :: Annex [CommandStart] -> Annex ()
|
seekActions :: Annex [CommandSeek] -> Annex ()
|
||||||
seekActions gen = mapM_ commandAction =<< gen
|
seekActions gen = sequence_ =<< gen
|
||||||
|
|
||||||
seekHelper :: ([FilePath] -> Git.Repo -> IO ([FilePath], IO Bool)) -> [WorkTreeItem] -> Annex [FilePath]
|
seekHelper :: ([FilePath] -> Git.Repo -> IO ([FilePath], IO Bool)) -> [WorkTreeItem] -> Annex [FilePath]
|
||||||
seekHelper a l = inRepo $ \g ->
|
seekHelper a l = inRepo $ \g ->
|
||||||
|
|
|
@ -65,7 +65,7 @@ seek o = allowConcurrentOutput $ do
|
||||||
| otherwise -> batchFilesMatching fmt gofile
|
| otherwise -> batchFilesMatching fmt gofile
|
||||||
NoBatch -> do
|
NoBatch -> do
|
||||||
l <- workTreeItems (addThese o)
|
l <- workTreeItems (addThese o)
|
||||||
let go a = a gofile l
|
let go a = a (commandAction . gofile) l
|
||||||
unless (updateOnly o) $
|
unless (updateOnly o) $
|
||||||
go (withFilesNotInGit (not $ includeDotFiles o))
|
go (withFilesNotInGit (not $ includeDotFiles o))
|
||||||
go withFilesMaybeModified
|
go withFilesMaybeModified
|
||||||
|
|
|
@ -17,7 +17,7 @@ cmd = command "commit" SectionPlumbing
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = next $ next $ do
|
start = next $ next $ do
|
||||||
|
|
|
@ -23,7 +23,7 @@ cmd = noCommit $ dontCheck repoExists $
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = do
|
start = do
|
||||||
|
|
|
@ -50,8 +50,8 @@ seek o = allowConcurrentOutput $ do
|
||||||
Batch fmt -> batchFilesMatching fmt go
|
Batch fmt -> batchFilesMatching fmt go
|
||||||
NoBatch -> withKeyOptions
|
NoBatch -> withKeyOptions
|
||||||
(keyOptions o) (autoMode o)
|
(keyOptions o) (autoMode o)
|
||||||
(Command.Move.startKey (fromToOptions o) Command.Move.RemoveNever)
|
(commandAction . Command.Move.startKey (fromToOptions o) Command.Move.RemoveNever)
|
||||||
(withFilesInGit go)
|
(withFilesInGit $ commandAction . go)
|
||||||
=<< workTreeItems (copyFiles o)
|
=<< workTreeItems (copyFiles o)
|
||||||
|
|
||||||
{- A copy is just a move that does not delete the source file.
|
{- A copy is just a move that does not delete the source file.
|
||||||
|
|
|
@ -29,7 +29,7 @@ optParser desc = (DeadRemotes <$> cmdParams desc)
|
||||||
|
|
||||||
seek :: DeadOptions -> CommandSeek
|
seek :: DeadOptions -> CommandSeek
|
||||||
seek (DeadRemotes rs) = trustCommand "dead" DeadTrusted rs
|
seek (DeadRemotes rs) = trustCommand "dead" DeadTrusted rs
|
||||||
seek (DeadKeys ks) = seekActions $ pure $ map startKey ks
|
seek (DeadKeys ks) = commandActions $ map startKey ks
|
||||||
|
|
||||||
startKey :: Key -> CommandStart
|
startKey :: Key -> CommandStart
|
||||||
startKey key = do
|
startKey key = do
|
||||||
|
|
|
@ -18,7 +18,7 @@ cmd = command "describe" SectionSetup
|
||||||
(withParams seek)
|
(withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start (name:description) = do
|
start (name:description) = do
|
||||||
|
|
|
@ -19,7 +19,7 @@ cmd = dontCheck repoExists $
|
||||||
("-- cmd --") (withParams seek)
|
("-- cmd --") (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start opts = do
|
start opts = do
|
||||||
|
|
|
@ -21,7 +21,7 @@ cmd = notBareRepo $ noDaemonRunning $
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = ifM versionSupportsDirectMode
|
start = ifM versionSupportsDirectMode
|
||||||
|
|
|
@ -56,8 +56,8 @@ seek o = allowConcurrentOutput $
|
||||||
case batchOption o of
|
case batchOption o of
|
||||||
Batch fmt -> batchFilesMatching fmt go
|
Batch fmt -> batchFilesMatching fmt go
|
||||||
NoBatch -> withKeyOptions (keyOptions o) (autoMode o)
|
NoBatch -> withKeyOptions (keyOptions o) (autoMode o)
|
||||||
(startKeys o)
|
(commandAction . startKeys o)
|
||||||
(withFilesInGit go)
|
(withFilesInGit (commandAction . go))
|
||||||
=<< workTreeItems (dropFiles o)
|
=<< workTreeItems (dropFiles o)
|
||||||
where
|
where
|
||||||
go = whenAnnexed $ start o
|
go = whenAnnexed $ start o
|
||||||
|
@ -84,8 +84,8 @@ start' o key afile ai = do
|
||||||
| autoMode o = wantDrop False (Remote.uuid <$> from) (Just key) afile
|
| autoMode o = wantDrop False (Remote.uuid <$> from) (Just key) afile
|
||||||
| otherwise = return True
|
| otherwise = return True
|
||||||
|
|
||||||
startKeys :: DropOptions -> Key -> ActionItem -> CommandStart
|
startKeys :: DropOptions -> (Key, ActionItem) -> CommandStart
|
||||||
startKeys o key = start' o key (AssociatedFile Nothing)
|
startKeys o (key, ai) = start' o key (AssociatedFile Nothing) ai
|
||||||
|
|
||||||
startLocal :: AssociatedFile -> ActionItem -> NumCopies -> Key -> [VerifiedCopy] -> CommandStart
|
startLocal :: AssociatedFile -> ActionItem -> NumCopies -> Key -> [VerifiedCopy] -> CommandStart
|
||||||
startLocal afile ai numcopies key preverified = stopUnless (inAnnex key) $ do
|
startLocal afile ai numcopies key preverified = stopUnless (inAnnex key) $ do
|
||||||
|
|
|
@ -33,7 +33,7 @@ seek :: DropKeyOptions -> CommandSeek
|
||||||
seek o = do
|
seek o = do
|
||||||
unlessM (Annex.getState Annex.force) $
|
unlessM (Annex.getState Annex.force) $
|
||||||
giveup "dropkey can cause data loss; use --force if you're sure you want to do this"
|
giveup "dropkey can cause data loss; use --force if you're sure you want to do this"
|
||||||
withKeys start (toDrop o)
|
withKeys (commandAction . start) (toDrop o)
|
||||||
case batchOption o of
|
case batchOption o of
|
||||||
Batch fmt -> batchInput fmt parsekey $ batchCommandAction . start
|
Batch fmt -> batchInput fmt parsekey $ batchCommandAction . start
|
||||||
NoBatch -> noop
|
NoBatch -> noop
|
||||||
|
|
|
@ -32,7 +32,7 @@ cmd = command "enableremote" SectionSetup
|
||||||
(withParams seek)
|
(withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start [] = unknownNameError "Specify the remote to enable."
|
start [] = unknownNameError "Specify the remote to enable."
|
||||||
|
|
|
@ -36,7 +36,7 @@ cmd = noCommit $ dontCheck repoExists $
|
||||||
"uid" (withParams seek)
|
"uid" (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
-- This runs as root, so avoid making any commits or initializing
|
-- This runs as root, so avoid making any commits or initializing
|
||||||
-- git-annex, or doing other things that create root-owned files.
|
-- git-annex, or doing other things that create root-owned files.
|
||||||
|
|
|
@ -53,7 +53,7 @@ seek o = do
|
||||||
u <- getUUID
|
u <- getUUID
|
||||||
us <- filter (/= u) . M.keys <$> uuidMap
|
us <- filter (/= u) . M.keys <$> uuidMap
|
||||||
descs <- uuidMap
|
descs <- uuidMap
|
||||||
seekActions $ pure $ map (start expire (noActOption o) actlog descs) us
|
commandActions $ map (start expire (noActOption o) actlog descs) us
|
||||||
|
|
||||||
start :: Expire -> Bool -> Log Activity -> M.Map UUID String -> UUID -> CommandStart
|
start :: Expire -> Bool -> Log Activity -> M.Map UUID String -> UUID -> CommandStart
|
||||||
start (Expire expire) noact actlog descs u =
|
start (Expire expire) noact actlog descs u =
|
||||||
|
|
|
@ -99,10 +99,12 @@ changeExport r ea db new = do
|
||||||
-- the next block of code below may have renamed some files to
|
-- the next block of code below may have renamed some files to
|
||||||
-- temp files. Diff from the incomplete tree to the new tree,
|
-- temp files. Diff from the incomplete tree to the new tree,
|
||||||
-- and delete any temp files that the new tree can't use.
|
-- and delete any temp files that the new tree can't use.
|
||||||
|
let recover diff = commandAction $
|
||||||
|
startRecoverIncomplete r ea db
|
||||||
|
(Git.DiffTree.srcsha diff)
|
||||||
|
(Git.DiffTree.file diff)
|
||||||
forM_ (concatMap incompleteExportedTreeish old) $ \incomplete ->
|
forM_ (concatMap incompleteExportedTreeish old) $ \incomplete ->
|
||||||
mapdiff (\diff -> startRecoverIncomplete r ea db (Git.DiffTree.srcsha diff) (Git.DiffTree.file diff))
|
mapdiff recover incomplete new
|
||||||
incomplete
|
|
||||||
new
|
|
||||||
|
|
||||||
-- Diff the old and new trees, and delete or rename to new name all
|
-- Diff the old and new trees, and delete or rename to new name all
|
||||||
-- changed files in the export. After this, every file that remains
|
-- changed files in the export. After this, every file that remains
|
||||||
|
@ -115,7 +117,8 @@ changeExport r ea db new = do
|
||||||
[] -> updateExportTree db emptyTree new
|
[] -> updateExportTree db emptyTree new
|
||||||
[oldtreesha] -> do
|
[oldtreesha] -> do
|
||||||
diffmap <- mkDiffMap oldtreesha new db
|
diffmap <- mkDiffMap oldtreesha new db
|
||||||
let seekdiffmap a = seekActions $ pure $ map a (M.toList diffmap)
|
let seekdiffmap a = commandActions $
|
||||||
|
map a (M.toList diffmap)
|
||||||
-- Rename old files to temp, or delete.
|
-- Rename old files to temp, or delete.
|
||||||
seekdiffmap $ \(ek, (moldf, mnewf)) -> do
|
seekdiffmap $ \(ek, (moldf, mnewf)) -> do
|
||||||
case (moldf, mnewf) of
|
case (moldf, mnewf) of
|
||||||
|
@ -144,7 +147,7 @@ changeExport r ea db new = do
|
||||||
-- Don't rename to temp, because the
|
-- Don't rename to temp, because the
|
||||||
-- content is unknown; delete instead.
|
-- content is unknown; delete instead.
|
||||||
mapdiff
|
mapdiff
|
||||||
(\diff -> startUnexport r ea db (Git.DiffTree.file diff) (unexportboth diff))
|
(\diff -> commandAction $ startUnexport r ea db (Git.DiffTree.file diff) (unexportboth diff))
|
||||||
oldtreesha new
|
oldtreesha new
|
||||||
updateExportTree db emptyTree new
|
updateExportTree db emptyTree new
|
||||||
liftIO $ recordExportTreeCurrent db new
|
liftIO $ recordExportTreeCurrent db new
|
||||||
|
@ -194,7 +197,7 @@ fillExport :: Remote -> ExportActions Annex -> ExportHandle -> Git.Ref -> Annex
|
||||||
fillExport r ea db new = do
|
fillExport r ea db new = do
|
||||||
(l, cleanup) <- inRepo $ Git.LsTree.lsTree new
|
(l, cleanup) <- inRepo $ Git.LsTree.lsTree new
|
||||||
cvar <- liftIO $ newMVar False
|
cvar <- liftIO $ newMVar False
|
||||||
seekActions $ pure $ map (startExport r ea db cvar) l
|
commandActions $ map (startExport r ea db cvar) l
|
||||||
void $ liftIO $ cleanup
|
void $ liftIO $ cleanup
|
||||||
liftIO $ takeMVar cvar
|
liftIO $ takeMVar cvar
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,8 @@ parseFormatOption =
|
||||||
|
|
||||||
seek :: FindOptions -> CommandSeek
|
seek :: FindOptions -> CommandSeek
|
||||||
seek o = case batchOption o of
|
seek o = case batchOption o of
|
||||||
NoBatch -> withFilesInGit go =<< workTreeItems (findThese o)
|
NoBatch -> withFilesInGit (commandAction . go)
|
||||||
|
=<< workTreeItems (findThese o)
|
||||||
Batch fmt -> batchFilesMatching fmt go
|
Batch fmt -> batchFilesMatching fmt go
|
||||||
where
|
where
|
||||||
go = whenAnnexed $ start o
|
go = whenAnnexed $ start o
|
||||||
|
|
|
@ -18,4 +18,5 @@ cmd = withGlobalOptions [nonWorkTreeMatchingOptions] $ Find.mkCommand $
|
||||||
paramRef (seek <$$> Find.optParser)
|
paramRef (seek <$$> Find.optParser)
|
||||||
|
|
||||||
seek :: Find.FindOptions -> CommandSeek
|
seek :: Find.FindOptions -> CommandSeek
|
||||||
seek o = Find.start o `withFilesInRefs` (map Git.Ref $ Find.findThese o)
|
seek o = (commandAction . uncurry (Find.start o))
|
||||||
|
`withFilesInRefs` (map Git.Ref $ Find.findThese o)
|
||||||
|
|
|
@ -34,8 +34,9 @@ seek ps = unlessM crippledFileSystem $ do
|
||||||
( return FixAll
|
( return FixAll
|
||||||
, return FixSymlinks
|
, return FixSymlinks
|
||||||
)
|
)
|
||||||
l <- workTreeItems ps
|
withFilesInGit
|
||||||
flip withFilesInGit l $ whenAnnexed $ start fixwhat
|
(commandAction . (whenAnnexed $ start fixwhat))
|
||||||
|
=<< workTreeItems ps
|
||||||
|
|
||||||
data FixWhat = FixSymlinks | FixAll
|
data FixWhat = FixSymlinks | FixAll
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,12 @@ optParser desc = FromKeyOptions
|
||||||
|
|
||||||
seek :: FromKeyOptions -> CommandSeek
|
seek :: FromKeyOptions -> CommandSeek
|
||||||
seek o = case (batchOption o, keyFilePairs o) of
|
seek o = case (batchOption o, keyFilePairs o) of
|
||||||
(Batch fmt, _) -> withNothing (startMass fmt) []
|
(Batch fmt, _) -> commandAction $ startMass fmt
|
||||||
-- older way of enabling batch input, does not support BatchNull
|
-- older way of enabling batch input, does not support BatchNull
|
||||||
(NoBatch, []) -> withNothing (startMass BatchLine) []
|
(NoBatch, []) -> commandAction $ startMass BatchLine
|
||||||
(NoBatch, ps) -> do
|
(NoBatch, ps) -> do
|
||||||
force <- Annex.getState Annex.force
|
force <- Annex.getState Annex.force
|
||||||
withPairs (start force) ps
|
withPairs (commandAction . start force) ps
|
||||||
|
|
||||||
start :: Bool -> (String, FilePath) -> CommandStart
|
start :: Bool -> (String, FilePath) -> CommandStart
|
||||||
start force (keyname, file) = do
|
start force (keyname, file) = do
|
||||||
|
|
|
@ -94,8 +94,8 @@ seek o = allowConcurrentOutput $ do
|
||||||
checkDeadRepo u
|
checkDeadRepo u
|
||||||
i <- prepIncremental u (incrementalOpt o)
|
i <- prepIncremental u (incrementalOpt o)
|
||||||
withKeyOptions (keyOptions o) False
|
withKeyOptions (keyOptions o) False
|
||||||
(\k ai -> startKey from i k ai =<< getNumCopies)
|
(\kai -> commandAction . startKey from i kai =<< getNumCopies)
|
||||||
(withFilesInGit $ whenAnnexed $ start from i)
|
(withFilesInGit $ commandAction . (whenAnnexed (start from i)))
|
||||||
=<< workTreeItems (fsckFiles o)
|
=<< workTreeItems (fsckFiles o)
|
||||||
cleanupIncremental i
|
cleanupIncremental i
|
||||||
void $ tryIO $ recordActivity Fsck u
|
void $ tryIO $ recordActivity Fsck u
|
||||||
|
@ -183,8 +183,8 @@ performRemote key afile backend numcopies remote =
|
||||||
)
|
)
|
||||||
dummymeter _ = noop
|
dummymeter _ = noop
|
||||||
|
|
||||||
startKey :: Maybe Remote -> Incremental -> Key -> ActionItem -> NumCopies -> CommandStart
|
startKey :: Maybe Remote -> Incremental -> (Key, ActionItem) -> NumCopies -> CommandStart
|
||||||
startKey from inc key ai numcopies =
|
startKey from inc (key, ai) numcopies =
|
||||||
case Backend.maybeLookupBackendVariety (keyVariety key) of
|
case Backend.maybeLookupBackendVariety (keyVariety key) of
|
||||||
Nothing -> stop
|
Nothing -> stop
|
||||||
Just backend -> runFsck inc ai key $
|
Just backend -> runFsck inc ai key $
|
||||||
|
|
|
@ -26,7 +26,7 @@ cmd = notBareRepo $
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = do
|
start = do
|
||||||
|
|
|
@ -19,7 +19,7 @@ cmd = dontCheck repoExists $ noCommit $
|
||||||
paramValue (withParams seek)
|
paramValue (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withStrings start
|
seek = withStrings (commandAction . start)
|
||||||
|
|
||||||
start :: String -> CommandStart
|
start :: String -> CommandStart
|
||||||
start gcryptid = next $ next $ do
|
start gcryptid = next $ next $ do
|
||||||
|
|
|
@ -44,8 +44,8 @@ seek o = allowConcurrentOutput $ do
|
||||||
case batchOption o of
|
case batchOption o of
|
||||||
Batch fmt -> batchFilesMatching fmt go
|
Batch fmt -> batchFilesMatching fmt go
|
||||||
NoBatch -> withKeyOptions (keyOptions o) (autoMode o)
|
NoBatch -> withKeyOptions (keyOptions o) (autoMode o)
|
||||||
(startKeys from)
|
(commandAction . startKeys from)
|
||||||
(withFilesInGit go)
|
(withFilesInGit (commandAction . go))
|
||||||
=<< workTreeItems (getFiles o)
|
=<< workTreeItems (getFiles o)
|
||||||
|
|
||||||
start :: GetOptions -> Maybe Remote -> FilePath -> Key -> CommandStart
|
start :: GetOptions -> Maybe Remote -> FilePath -> Key -> CommandStart
|
||||||
|
@ -57,8 +57,8 @@ start o from file key = start' expensivecheck from key afile (mkActionItem afile
|
||||||
<||> wantGet False (Just key) afile
|
<||> wantGet False (Just key) afile
|
||||||
| otherwise = return True
|
| otherwise = return True
|
||||||
|
|
||||||
startKeys :: Maybe Remote -> Key -> ActionItem -> CommandStart
|
startKeys :: Maybe Remote -> (Key, ActionItem) -> CommandStart
|
||||||
startKeys from key ai = checkFailedTransferDirection ai Download $
|
startKeys from (key, ai) = checkFailedTransferDirection ai Download $
|
||||||
start' (return True) from key (AssociatedFile Nothing) ai
|
start' (return True) from key (AssociatedFile Nothing) ai
|
||||||
|
|
||||||
start' :: Annex Bool -> Maybe Remote -> Key -> AssociatedFile -> ActionItem -> CommandStart
|
start' :: Annex Bool -> Maybe Remote -> Key -> AssociatedFile -> ActionItem -> CommandStart
|
||||||
|
|
|
@ -19,7 +19,7 @@ cmd = noMessages $ command "group" SectionSetup "add a repository to a group"
|
||||||
(paramPair paramRemote paramDesc) (withParams seek)
|
(paramPair paramRemote paramDesc) (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start (name:g:[]) = do
|
start (name:g:[]) = do
|
||||||
|
|
|
@ -18,7 +18,7 @@ cmd = noMessages $ command "groupwanted" SectionSetup
|
||||||
(withParams seek)
|
(withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start (g:[]) = next $ performGet groupPreferredContentMapRaw g
|
start (g:[]) = next $ performGet groupPreferredContentMapRaw g
|
||||||
|
|
|
@ -27,7 +27,7 @@ cmd = noCommit $ dontCheck repoExists $
|
||||||
parseparams = withParams
|
parseparams = withParams
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start params = do
|
start params = do
|
||||||
|
|
|
@ -73,7 +73,8 @@ seek o = allowConcurrentOutput $ do
|
||||||
unless (null inrepops) $ do
|
unless (null inrepops) $ do
|
||||||
giveup $ "cannot import files from inside the working tree (use git annex add instead): " ++ unwords inrepops
|
giveup $ "cannot import files from inside the working tree (use git annex add instead): " ++ unwords inrepops
|
||||||
largematcher <- largeFilesMatcher
|
largematcher <- largeFilesMatcher
|
||||||
withPathContents (start largematcher (duplicateMode o)) (importFiles o)
|
(commandAction . start largematcher (duplicateMode o))
|
||||||
|
`withPathContents` importFiles o
|
||||||
|
|
||||||
start :: GetFileMatcher -> DuplicateMode -> (FilePath, FilePath) -> CommandStart
|
start :: GetFileMatcher -> DuplicateMode -> (FilePath, FilePath) -> CommandStart
|
||||||
start largematcher mode (srcfile, destfile) =
|
start largematcher mode (srcfile, destfile) =
|
||||||
|
|
|
@ -67,7 +67,7 @@ optParser desc = ImportFeedOptions
|
||||||
seek :: ImportFeedOptions -> CommandSeek
|
seek :: ImportFeedOptions -> CommandSeek
|
||||||
seek o = do
|
seek o = do
|
||||||
cache <- getCache (templateOption o)
|
cache <- getCache (templateOption o)
|
||||||
withStrings (start o cache) (feedUrls o)
|
withStrings (commandAction . start o cache) (feedUrls o)
|
||||||
|
|
||||||
start :: ImportFeedOptions -> Cache -> URLString -> CommandStart
|
start :: ImportFeedOptions -> Cache -> URLString -> CommandStart
|
||||||
start opts cache url = do
|
start opts cache url = do
|
||||||
|
|
|
@ -18,7 +18,7 @@ cmd = noCommit $
|
||||||
(withParams seek)
|
(withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withKeys start
|
seek = withKeys (commandAction . start)
|
||||||
|
|
||||||
start :: Key -> CommandStart
|
start :: Key -> CommandStart
|
||||||
start key = inAnnexSafe key >>= dispatch
|
start key = inAnnexSafe key >>= dispatch
|
||||||
|
|
|
@ -27,7 +27,7 @@ cmd = notBareRepo $ noDaemonRunning $
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = ifM isDirect
|
start = ifM isDirect
|
||||||
|
|
|
@ -132,7 +132,7 @@ optParser desc = InfoOptions
|
||||||
|
|
||||||
seek :: InfoOptions -> CommandSeek
|
seek :: InfoOptions -> CommandSeek
|
||||||
seek o = case batchOption o of
|
seek o = case batchOption o of
|
||||||
NoBatch -> withWords (start o) (infoFor o)
|
NoBatch -> withWords (commandAction . start o) (infoFor o)
|
||||||
Batch fmt -> batchInput fmt Right (itemInfo o)
|
Batch fmt -> batchInput fmt Right (itemInfo o)
|
||||||
|
|
||||||
start :: InfoOptions -> [String] -> CommandStart
|
start :: InfoOptions -> [String] -> CommandStart
|
||||||
|
|
|
@ -24,7 +24,7 @@ cmd = command "initremote" SectionSetup
|
||||||
(withParams seek)
|
(withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start [] = giveup "Specify a name for the remote."
|
start [] = giveup "Specify a name for the remote."
|
||||||
|
|
|
@ -38,7 +38,8 @@ seek o = do
|
||||||
then forM_ ts $ commandAction . start'
|
then forM_ ts $ commandAction . start'
|
||||||
else do
|
else do
|
||||||
let s = S.fromList ts
|
let s = S.fromList ts
|
||||||
withFilesInGit (whenAnnexed (start s))
|
withFilesInGit
|
||||||
|
(commandAction . (whenAnnexed (start s)))
|
||||||
=<< workTreeItems (inprogressFiles o)
|
=<< workTreeItems (inprogressFiles o)
|
||||||
|
|
||||||
start :: S.Set Key -> FilePath -> Key -> CommandStart
|
start :: S.Set Key -> FilePath -> Key -> CommandStart
|
||||||
|
|
|
@ -44,7 +44,8 @@ seek :: ListOptions -> CommandSeek
|
||||||
seek o = do
|
seek o = do
|
||||||
list <- getList o
|
list <- getList o
|
||||||
printHeader list
|
printHeader list
|
||||||
withFilesInGit (whenAnnexed $ start list)
|
withFilesInGit
|
||||||
|
(commandAction . (whenAnnexed $ start list))
|
||||||
=<< workTreeItems (listThese o)
|
=<< workTreeItems (listThese o)
|
||||||
|
|
||||||
getList :: ListOptions -> Annex [(UUID, RemoteName, TrustLevel)]
|
getList :: ListOptions -> Annex [(UUID, RemoteName, TrustLevel)]
|
||||||
|
|
|
@ -32,10 +32,10 @@ seek :: CmdParams -> CommandSeek
|
||||||
seek ps = do
|
seek ps = do
|
||||||
l <- workTreeItems ps
|
l <- workTreeItems ps
|
||||||
ifM versionSupportsUnlockedPointers
|
ifM versionSupportsUnlockedPointers
|
||||||
( withFilesInGit (whenAnnexed startNew) l
|
( withFilesInGit (commandAction . (whenAnnexed startNew)) l
|
||||||
, do
|
, do
|
||||||
withFilesOldUnlocked startOld l
|
withFilesOldUnlocked (commandAction . startOld) l
|
||||||
withFilesOldUnlockedToBeCommitted startOld l
|
withFilesOldUnlockedToBeCommitted (commandAction . startOld) l
|
||||||
)
|
)
|
||||||
|
|
||||||
startNew :: FilePath -> Key -> CommandStart
|
startNew :: FilePath -> Key -> CommandStart
|
||||||
|
|
|
@ -20,7 +20,7 @@ cmd = noCommit $
|
||||||
(withParams seek)
|
(withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
-- First, lock the content, then print out "OK".
|
-- First, lock the content, then print out "OK".
|
||||||
-- Wait for the caller to send a line before dropping the lock.
|
-- Wait for the caller to send a line before dropping the lock.
|
||||||
|
|
|
@ -91,7 +91,8 @@ seek o = do
|
||||||
zone <- liftIO getCurrentTimeZone
|
zone <- liftIO getCurrentTimeZone
|
||||||
let outputter = mkOutputter m zone o
|
let outputter = mkOutputter m zone o
|
||||||
case (logFiles o, allOption o) of
|
case (logFiles o, allOption o) of
|
||||||
(fs, False) -> withFilesInGit (whenAnnexed $ start o outputter)
|
(fs, False) -> withFilesInGit
|
||||||
|
(commandAction . (whenAnnexed $ start o outputter))
|
||||||
=<< workTreeItems fs
|
=<< workTreeItems fs
|
||||||
([], True) -> commandAction (startAll o outputter)
|
([], True) -> commandAction (startAll o outputter)
|
||||||
(_, True) -> giveup "Cannot specify both files and --all"
|
(_, True) -> giveup "Cannot specify both files and --all"
|
||||||
|
|
|
@ -37,7 +37,7 @@ cmd = dontCheck repoExists $
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = do
|
start = do
|
||||||
|
|
|
@ -80,8 +80,8 @@ seek o = case batchOption o of
|
||||||
Set _ -> withFilesInGitNonRecursive
|
Set _ -> withFilesInGitNonRecursive
|
||||||
"Not recursively setting metadata. Use --force to do that."
|
"Not recursively setting metadata. Use --force to do that."
|
||||||
withKeyOptions (keyOptions o) False
|
withKeyOptions (keyOptions o) False
|
||||||
(startKeys c o)
|
(commandAction . startKeys c o)
|
||||||
(seeker $ whenAnnexed $ start c o)
|
(seeker (commandAction . (whenAnnexed (start c o))))
|
||||||
=<< workTreeItems (forFiles o)
|
=<< workTreeItems (forFiles o)
|
||||||
Batch fmt -> withMessageState $ \s -> case outputType s of
|
Batch fmt -> withMessageState $ \s -> case outputType s of
|
||||||
JSONOutput _ -> ifM limited
|
JSONOutput _ -> ifM limited
|
||||||
|
@ -92,12 +92,12 @@ seek o = case batchOption o of
|
||||||
_ -> giveup "--batch is currently only supported in --json mode"
|
_ -> giveup "--batch is currently only supported in --json mode"
|
||||||
|
|
||||||
start :: VectorClock -> MetaDataOptions -> FilePath -> Key -> CommandStart
|
start :: VectorClock -> MetaDataOptions -> FilePath -> Key -> CommandStart
|
||||||
start c o file k = startKeys c o k (mkActionItem afile)
|
start c o file k = startKeys c o (k, mkActionItem afile)
|
||||||
where
|
where
|
||||||
afile = AssociatedFile (Just file)
|
afile = AssociatedFile (Just file)
|
||||||
|
|
||||||
startKeys :: VectorClock -> MetaDataOptions -> Key -> ActionItem -> CommandStart
|
startKeys :: VectorClock -> MetaDataOptions -> (Key, ActionItem) -> CommandStart
|
||||||
startKeys c o k ai = case getSet o of
|
startKeys c o (k, ai) = case getSet o of
|
||||||
Get f -> do
|
Get f -> do
|
||||||
l <- S.toList . currentMetaDataValues f <$> getCurrentMetaData k
|
l <- S.toList . currentMetaDataValues f <$> getCurrentMetaData k
|
||||||
liftIO $ forM_ l $
|
liftIO $ forM_ l $
|
||||||
|
|
|
@ -26,7 +26,7 @@ cmd = notDirect $ withGlobalOptions [annexedMatchingOptions] $
|
||||||
paramPaths (withParams seek)
|
paramPaths (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek ps = withFilesInGit (whenAnnexed start) =<< workTreeItems ps
|
seek = withFilesInGit (commandAction . (whenAnnexed start)) <=< workTreeItems
|
||||||
|
|
||||||
start :: FilePath -> Key -> CommandStart
|
start :: FilePath -> Key -> CommandStart
|
||||||
start file key = do
|
start file key = do
|
||||||
|
|
|
@ -43,17 +43,17 @@ instance DeferredParseClass MirrorOptions where
|
||||||
seek :: MirrorOptions -> CommandSeek
|
seek :: MirrorOptions -> CommandSeek
|
||||||
seek o = allowConcurrentOutput $
|
seek o = allowConcurrentOutput $
|
||||||
withKeyOptions (keyOptions o) False
|
withKeyOptions (keyOptions o) False
|
||||||
(startKey o (AssociatedFile Nothing))
|
(commandAction . startKey o (AssociatedFile Nothing))
|
||||||
(withFilesInGit $ whenAnnexed $ start o)
|
(withFilesInGit (commandAction . (whenAnnexed $ start o)))
|
||||||
=<< workTreeItems (mirrorFiles o)
|
=<< workTreeItems (mirrorFiles o)
|
||||||
|
|
||||||
start :: MirrorOptions -> FilePath -> Key -> CommandStart
|
start :: MirrorOptions -> FilePath -> Key -> CommandStart
|
||||||
start o file k = startKey o afile k (mkActionItem afile)
|
start o file k = startKey o afile (k, mkActionItem afile)
|
||||||
where
|
where
|
||||||
afile = AssociatedFile (Just file)
|
afile = AssociatedFile (Just file)
|
||||||
|
|
||||||
startKey :: MirrorOptions -> AssociatedFile -> Key -> ActionItem -> CommandStart
|
startKey :: MirrorOptions -> AssociatedFile -> (Key, ActionItem) -> CommandStart
|
||||||
startKey o afile key ai = onlyActionOn key $ case fromToOptions o of
|
startKey o afile (key, ai) = onlyActionOn key $ case fromToOptions o of
|
||||||
ToRemote r -> checkFailedTransferDirection ai Upload $ ifM (inAnnex key)
|
ToRemote r -> checkFailedTransferDirection ai Upload $ ifM (inAnnex key)
|
||||||
( Command.Move.toStart Command.Move.RemoveNever afile key ai =<< getParsed r
|
( Command.Move.toStart Command.Move.RemoveNever afile key ai =<< getParsed r
|
||||||
, do
|
, do
|
||||||
|
|
|
@ -59,8 +59,8 @@ seek o = allowConcurrentOutput $ do
|
||||||
case batchOption o of
|
case batchOption o of
|
||||||
Batch fmt -> batchFilesMatching fmt go
|
Batch fmt -> batchFilesMatching fmt go
|
||||||
NoBatch -> withKeyOptions (keyOptions o) False
|
NoBatch -> withKeyOptions (keyOptions o) False
|
||||||
(startKey (fromToOptions o) (removeWhen o))
|
(commandAction . startKey (fromToOptions o) (removeWhen o))
|
||||||
(withFilesInGit go)
|
(withFilesInGit (commandAction . go))
|
||||||
=<< workTreeItems (moveFiles o)
|
=<< workTreeItems (moveFiles o)
|
||||||
|
|
||||||
start :: FromToHereOptions -> RemoveWhen -> FilePath -> Key -> CommandStart
|
start :: FromToHereOptions -> RemoveWhen -> FilePath -> Key -> CommandStart
|
||||||
|
@ -69,8 +69,9 @@ start fromto removewhen f k =
|
||||||
where
|
where
|
||||||
afile = AssociatedFile (Just f)
|
afile = AssociatedFile (Just f)
|
||||||
|
|
||||||
startKey :: FromToHereOptions -> RemoveWhen -> Key -> ActionItem -> CommandStart
|
startKey :: FromToHereOptions -> RemoveWhen -> (Key, ActionItem) -> CommandStart
|
||||||
startKey fromto removewhen = start' fromto removewhen (AssociatedFile Nothing)
|
startKey fromto removewhen =
|
||||||
|
uncurry $ start' fromto removewhen (AssociatedFile Nothing)
|
||||||
|
|
||||||
start' :: FromToHereOptions -> RemoveWhen -> AssociatedFile -> Key -> ActionItem -> CommandStart
|
start' :: FromToHereOptions -> RemoveWhen -> AssociatedFile -> Key -> ActionItem -> CommandStart
|
||||||
start' fromto removewhen afile key ai = onlyActionOn key $
|
start' fromto removewhen afile key ai = onlyActionOn key $
|
||||||
|
|
|
@ -21,7 +21,7 @@ cmd = noCommit $
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = go =<< watchChangedRefs
|
start = go =<< watchChangedRefs
|
||||||
|
|
|
@ -17,7 +17,7 @@ cmd = noMessages $ command "numcopies" SectionSetup
|
||||||
paramNumber (withParams seek)
|
paramNumber (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start [] = startGet
|
start [] = startGet
|
||||||
|
|
|
@ -39,7 +39,7 @@ seek :: CmdParams -> CommandSeek
|
||||||
seek ps = lockPreCommitHook $ ifM isDirect
|
seek ps = lockPreCommitHook $ ifM isDirect
|
||||||
( do
|
( do
|
||||||
-- update direct mode mappings for committed files
|
-- update direct mode mappings for committed files
|
||||||
withWords startDirect ps
|
withWords (commandAction . startDirect) ps
|
||||||
runAnnexHook preCommitAnnexHook
|
runAnnexHook preCommitAnnexHook
|
||||||
, do
|
, do
|
||||||
ifM (not <$> versionSupportsUnlockedPointers <&&> liftIO Git.haveFalseIndex)
|
ifM (not <$> versionSupportsUnlockedPointers <&&> liftIO Git.haveFalseIndex)
|
||||||
|
@ -51,14 +51,14 @@ seek ps = lockPreCommitHook $ ifM isDirect
|
||||||
, do
|
, do
|
||||||
l <- workTreeItems ps
|
l <- workTreeItems ps
|
||||||
-- fix symlinks to files being committed
|
-- fix symlinks to files being committed
|
||||||
flip withFilesToBeCommitted l $ \f ->
|
flip withFilesToBeCommitted l $ \f -> commandAction $
|
||||||
maybe stop (Command.Fix.start Command.Fix.FixSymlinks f)
|
maybe stop (Command.Fix.start Command.Fix.FixSymlinks f)
|
||||||
=<< isAnnexLink f
|
=<< isAnnexLink f
|
||||||
-- inject unlocked files into the annex
|
-- inject unlocked files into the annex
|
||||||
-- (not needed when repo version uses
|
-- (not needed when repo version uses
|
||||||
-- unlocked pointer files)
|
-- unlocked pointer files)
|
||||||
unlessM versionSupportsUnlockedPointers $
|
unlessM versionSupportsUnlockedPointers $
|
||||||
withFilesOldUnlockedToBeCommitted startInjectUnlocked l
|
withFilesOldUnlockedToBeCommitted (commandAction . startInjectUnlocked) l
|
||||||
)
|
)
|
||||||
runAnnexHook preCommitAnnexHook
|
runAnnexHook preCommitAnnexHook
|
||||||
-- committing changes to a view updates metadata
|
-- committing changes to a view updates metadata
|
||||||
|
|
|
@ -27,7 +27,7 @@ cmd = notBareRepo $
|
||||||
("-- git command") (withParams seek)
|
("-- git command") (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start [] = giveup "Did not specify command to run."
|
start [] = giveup "Did not specify command to run."
|
||||||
|
|
|
@ -50,7 +50,7 @@ batchParser s = case separate (== ' ') (reverse s) of
|
||||||
seek :: ReKeyOptions -> CommandSeek
|
seek :: ReKeyOptions -> CommandSeek
|
||||||
seek o = case batchOption o of
|
seek o = case batchOption o of
|
||||||
Batch fmt -> batchInput fmt batchParser (batchCommandAction . start)
|
Batch fmt -> batchInput fmt batchParser (batchCommandAction . start)
|
||||||
NoBatch -> withPairs (start . parsekey) (reKeyThese o)
|
NoBatch -> withPairs (commandAction . start . parsekey) (reKeyThese o)
|
||||||
where
|
where
|
||||||
parsekey (file, skey) =
|
parsekey (file, skey) =
|
||||||
(file, fromMaybe (giveup "bad key") (file2key skey))
|
(file, fromMaybe (giveup "bad key") (file2key skey))
|
||||||
|
|
|
@ -18,7 +18,7 @@ cmd = noCommit $
|
||||||
(withParams seek)
|
(withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start (ks:us:[]) = do
|
start (ks:us:[]) = do
|
||||||
|
|
|
@ -23,7 +23,7 @@ cmd = noCommit $ command "recvkey" SectionPlumbing
|
||||||
paramKey (withParams seek)
|
paramKey (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withKeys start
|
seek = withKeys (commandAction . start)
|
||||||
|
|
||||||
start :: Key -> CommandStart
|
start :: Key -> CommandStart
|
||||||
start key = fieldTransfer Download key $ \_p -> do
|
start key = fieldTransfer Download key $ \_p -> do
|
||||||
|
|
|
@ -33,10 +33,10 @@ optParser desc = RegisterUrlOptions
|
||||||
|
|
||||||
seek :: RegisterUrlOptions -> CommandSeek
|
seek :: RegisterUrlOptions -> CommandSeek
|
||||||
seek o = case (batchOption o, keyUrlPairs o) of
|
seek o = case (batchOption o, keyUrlPairs o) of
|
||||||
(Batch fmt, _) -> withNothing (startMass fmt) []
|
(Batch fmt, _) -> commandAction $ startMass fmt
|
||||||
-- older way of enabling batch input, does not support BatchNull
|
-- older way of enabling batch input, does not support BatchNull
|
||||||
(NoBatch, []) -> withNothing (startMass BatchLine) []
|
(NoBatch, []) -> commandAction $ startMass BatchLine
|
||||||
(NoBatch, ps) -> withWords start ps
|
(NoBatch, ps) -> withWords (commandAction . start) ps
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start (keyname:url:[]) = do
|
start (keyname:url:[]) = do
|
||||||
|
|
|
@ -21,7 +21,7 @@ cmd = dontCheck repoExists $
|
||||||
(withParams seek)
|
(withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start ws = do
|
start ws = do
|
||||||
|
|
|
@ -35,8 +35,8 @@ optParser desc = ReinjectOptions
|
||||||
|
|
||||||
seek :: ReinjectOptions -> CommandSeek
|
seek :: ReinjectOptions -> CommandSeek
|
||||||
seek os
|
seek os
|
||||||
| knownOpt os = withStrings startKnown (params os)
|
| knownOpt os = withStrings (commandAction . startKnown) (params os)
|
||||||
| otherwise = withWords startSrcDest (params os)
|
| otherwise = withWords (commandAction . startSrcDest) (params os)
|
||||||
|
|
||||||
startSrcDest :: [FilePath] -> CommandStart
|
startSrcDest :: [FilePath] -> CommandStart
|
||||||
startSrcDest (src:dest:[])
|
startSrcDest (src:dest:[])
|
||||||
|
|
|
@ -22,7 +22,7 @@ cmd = noCommit $ dontCheck repoExists $
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = next $ next $ runRepair =<< Annex.getState Annex.force
|
start = next $ next $ runRepair =<< Annex.getState Annex.force
|
||||||
|
|
|
@ -19,7 +19,7 @@ cmd = command "resolvemerge" SectionPlumbing
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = do
|
start = do
|
||||||
|
|
|
@ -31,7 +31,7 @@ optParser desc = RmUrlOptions
|
||||||
seek :: RmUrlOptions -> CommandSeek
|
seek :: RmUrlOptions -> CommandSeek
|
||||||
seek o = case batchOption o of
|
seek o = case batchOption o of
|
||||||
Batch fmt -> batchInput fmt batchParser (batchCommandAction . start)
|
Batch fmt -> batchInput fmt batchParser (batchCommandAction . start)
|
||||||
NoBatch -> withPairs start (rmThese o)
|
NoBatch -> withPairs (commandAction . start) (rmThese o)
|
||||||
|
|
||||||
-- Split on the last space, since a FilePath can contain whitespace,
|
-- Split on the last space, since a FilePath can contain whitespace,
|
||||||
-- but a url should not.
|
-- but a url should not.
|
||||||
|
|
|
@ -20,7 +20,7 @@ cmd = noMessages $ command "schedule" SectionSetup "get or set scheduled jobs"
|
||||||
(withParams seek)
|
(withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start = parse
|
start = parse
|
||||||
|
|
|
@ -24,7 +24,7 @@ cmd = noCommit $
|
||||||
paramKey (withParams seek)
|
paramKey (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withKeys start
|
seek = withKeys (commandAction . start)
|
||||||
|
|
||||||
start :: Key -> CommandStart
|
start :: Key -> CommandStart
|
||||||
start key = do
|
start key = do
|
||||||
|
|
|
@ -17,7 +17,7 @@ cmd = command "setkey" SectionPlumbing "sets annexed content for a key"
|
||||||
(withParams seek)
|
(withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start (keyname:file:[]) = do
|
start (keyname:file:[]) = do
|
||||||
|
|
|
@ -37,7 +37,7 @@ optParser desc = StatusOptions
|
||||||
))
|
))
|
||||||
|
|
||||||
seek :: StatusOptions -> CommandSeek
|
seek :: StatusOptions -> CommandSeek
|
||||||
seek o = withWords (start o) (statusFiles o)
|
seek o = withWords (commandAction . start o) (statusFiles o)
|
||||||
|
|
||||||
start :: StatusOptions -> [FilePath] -> CommandStart
|
start :: StatusOptions -> [FilePath] -> CommandStart
|
||||||
start o locs = do
|
start o locs = do
|
||||||
|
|
|
@ -595,7 +595,7 @@ seekSyncContent o rs = do
|
||||||
where
|
where
|
||||||
seekworktree mvar l bloomfeeder = seekHelper LsFiles.inRepo l >>=
|
seekworktree mvar l bloomfeeder = seekHelper LsFiles.inRepo l >>=
|
||||||
mapM_ (\f -> ifAnnexed f (go (Right bloomfeeder) mvar (AssociatedFile (Just f))) noop)
|
mapM_ (\f -> ifAnnexed f (go (Right bloomfeeder) mvar (AssociatedFile (Just f))) noop)
|
||||||
seekkeys mvar bloom k _ = go (Left bloom) mvar (AssociatedFile Nothing) k
|
seekkeys mvar bloom (k, _) = go (Left bloom) mvar (AssociatedFile Nothing) k
|
||||||
go ebloom mvar af k = commandAction $ do
|
go ebloom mvar af k = commandAction $ do
|
||||||
whenM (syncFile ebloom rs af k) $
|
whenM (syncFile ebloom rs af k) $
|
||||||
void $ liftIO $ tryPutMVar mvar ()
|
void $ liftIO $ tryPutMVar mvar ()
|
||||||
|
|
|
@ -22,7 +22,7 @@ cmd = noCommit $
|
||||||
paramKey (withParams seek)
|
paramKey (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
{- Security:
|
{- Security:
|
||||||
-
|
-
|
||||||
|
|
|
@ -42,7 +42,7 @@ instance DeferredParseClass TransferKeyOptions where
|
||||||
<*> pure (fileOption v)
|
<*> pure (fileOption v)
|
||||||
|
|
||||||
seek :: TransferKeyOptions -> CommandSeek
|
seek :: TransferKeyOptions -> CommandSeek
|
||||||
seek o = withKeys (start o) (keyOptions o)
|
seek o = withKeys (commandAction . start o) (keyOptions o)
|
||||||
|
|
||||||
start :: TransferKeyOptions -> Key -> CommandStart
|
start :: TransferKeyOptions -> Key -> CommandStart
|
||||||
start o key = case fromToOptions o of
|
start o key = case fromToOptions o of
|
||||||
|
|
|
@ -25,7 +25,7 @@ cmd = command "transferkeys" SectionPlumbing "transfers keys"
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = do
|
start = do
|
||||||
|
|
|
@ -23,7 +23,7 @@ seek :: CmdParams -> CommandSeek
|
||||||
seek = trustCommand "trust" Trusted
|
seek = trustCommand "trust" Trusted
|
||||||
|
|
||||||
trustCommand :: String -> TrustLevel -> CmdParams -> CommandSeek
|
trustCommand :: String -> TrustLevel -> CmdParams -> CommandSeek
|
||||||
trustCommand c level = withWords start
|
trustCommand c level = withWords (commandAction . start)
|
||||||
where
|
where
|
||||||
start ws = do
|
start ws = do
|
||||||
let name = unwords ws
|
let name = unwords ws
|
||||||
|
|
|
@ -31,7 +31,7 @@ cmd = withGlobalOptions [annexedMatchingOptions] $
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek ps = wrapUnannex $
|
seek ps = wrapUnannex $
|
||||||
(withFilesInGit $ whenAnnexed start) =<< workTreeItems ps
|
(withFilesInGit $ commandAction . whenAnnexed start) =<< workTreeItems ps
|
||||||
|
|
||||||
wrapUnannex :: Annex a -> Annex a
|
wrapUnannex :: Annex a -> Annex a
|
||||||
wrapUnannex a = ifM (versionSupportsUnlockedPointers <||> isDirect)
|
wrapUnannex a = ifM (versionSupportsUnlockedPointers <||> isDirect)
|
||||||
|
|
|
@ -43,7 +43,7 @@ seek ps = do
|
||||||
void $ Command.Sync.commitStaged Git.Branch.ManualCommit
|
void $ Command.Sync.commitStaged Git.Branch.ManualCommit
|
||||||
"commit before undo"
|
"commit before undo"
|
||||||
|
|
||||||
withStrings start ps
|
withStrings (commandAction . start) ps
|
||||||
|
|
||||||
start :: FilePath -> CommandStart
|
start :: FilePath -> CommandStart
|
||||||
start p = do
|
start p = do
|
||||||
|
|
|
@ -19,7 +19,7 @@ cmd = command "ungroup" SectionSetup "remove a repository from a group"
|
||||||
(paramPair paramRemote paramDesc) (withParams seek)
|
(paramPair paramRemote paramDesc) (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start (name:g:[]) = do
|
start (name:g:[]) = do
|
||||||
|
|
|
@ -41,9 +41,9 @@ check = do
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek ps = do
|
seek ps = do
|
||||||
l <- workTreeItems ps
|
l <- workTreeItems ps
|
||||||
withFilesNotInGit False (whenAnnexed startCheckIncomplete) l
|
withFilesNotInGit False (commandAction . whenAnnexed startCheckIncomplete) l
|
||||||
Annex.changeState $ \s -> s { Annex.fast = True }
|
Annex.changeState $ \s -> s { Annex.fast = True }
|
||||||
withFilesInGit (whenAnnexed Command.Unannex.start) l
|
withFilesInGit (commandAction . whenAnnexed Command.Unannex.start) l
|
||||||
finish
|
finish
|
||||||
|
|
||||||
{- git annex symlinks that are not checked into git could be left by an
|
{- git annex symlinks that are not checked into git could be left by an
|
||||||
|
|
|
@ -30,7 +30,7 @@ mkcmd n d = notDirect $
|
||||||
command n SectionCommon d paramPaths (withParams seek)
|
command n SectionCommon d paramPaths (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek ps = withFilesInGit (whenAnnexed start) =<< workTreeItems ps
|
seek ps = withFilesInGit (commandAction . whenAnnexed start) =<< workTreeItems ps
|
||||||
|
|
||||||
{- Before v6, the unlock subcommand replaces the symlink with a copy of
|
{- Before v6, the unlock subcommand replaces the symlink with a copy of
|
||||||
- the file's content. In v6 and above, it converts the file from a symlink
|
- the file's content. In v6 and above, it converts the file from a symlink
|
||||||
|
|
|
@ -303,8 +303,7 @@ withUnusedMaps a params = do
|
||||||
unusedtmp <- readUnusedMap "tmp"
|
unusedtmp <- readUnusedMap "tmp"
|
||||||
let m = unused `M.union` unusedbad `M.union` unusedtmp
|
let m = unused `M.union` unusedbad `M.union` unusedtmp
|
||||||
let unusedmaps = UnusedMaps unused unusedbad unusedtmp
|
let unusedmaps = UnusedMaps unused unusedbad unusedtmp
|
||||||
seekActions $ return $ map (a unusedmaps) $
|
commandActions $ map (a unusedmaps) $ concatMap (unusedSpec m) params
|
||||||
concatMap (unusedSpec m) params
|
|
||||||
|
|
||||||
unusedSpec :: UnusedMap -> String -> [Int]
|
unusedSpec :: UnusedMap -> String -> [Int]
|
||||||
unusedSpec m spec
|
unusedSpec m spec
|
||||||
|
|
|
@ -19,7 +19,7 @@ cmd = dontCheck repoExists $ -- because an old version may not seem to exist
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = do
|
start = do
|
||||||
|
|
|
@ -19,7 +19,7 @@ cmd = notBareRepo $ notDirect $
|
||||||
(withParams seek)
|
(withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start params = do
|
start params = do
|
||||||
|
|
|
@ -20,7 +20,7 @@ cmd = notBareRepo $ notDirect $
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start ::CommandStart
|
start ::CommandStart
|
||||||
start = go =<< currentView
|
start = go =<< currentView
|
||||||
|
|
|
@ -17,7 +17,7 @@ cmd = notBareRepo $ notDirect $
|
||||||
paramView (withParams seek)
|
paramView (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start params = do
|
start params = do
|
||||||
|
|
|
@ -21,7 +21,7 @@ cmd = notBareRepo $ notDirect $
|
||||||
paramNumber (withParams seek)
|
paramNumber (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start ps = go =<< currentView
|
start ps = go =<< currentView
|
||||||
|
|
|
@ -37,7 +37,7 @@ cmd = command "vicfg" SectionSetup "edit configuration in git-annex branch"
|
||||||
paramNothing (withParams seek)
|
paramNothing (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withNothing start
|
seek = withNothing (commandAction start)
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = do
|
start = do
|
||||||
|
|
|
@ -25,7 +25,7 @@ cmd = notBareRepo $ notDirect $
|
||||||
paramView (withParams seek)
|
paramView (withParams seek)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
seek :: CmdParams -> CommandSeek
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start [] = giveup "Specify metadata to include in view"
|
start [] = giveup "Specify metadata to include in view"
|
||||||
|
|
|
@ -30,7 +30,7 @@ cmd' name desc getter setter = noMessages $
|
||||||
where
|
where
|
||||||
pdesc = paramPair paramRemote (paramOptional paramExpression)
|
pdesc = paramPair paramRemote (paramOptional paramExpression)
|
||||||
|
|
||||||
seek = withWords start
|
seek = withWords (commandAction . start)
|
||||||
|
|
||||||
start (rname:[]) = go rname (performGet getter)
|
start (rname:[]) = go rname (performGet getter)
|
||||||
start (rname:expr:[]) = go rname $ \uuid -> do
|
start (rname:expr:[]) = go rname $ \uuid -> do
|
||||||
|
|
|
@ -43,17 +43,17 @@ seek o = do
|
||||||
Batch fmt -> batchFilesMatching fmt go
|
Batch fmt -> batchFilesMatching fmt go
|
||||||
NoBatch ->
|
NoBatch ->
|
||||||
withKeyOptions (keyOptions o) False
|
withKeyOptions (keyOptions o) False
|
||||||
(startKeys m)
|
(commandAction . startKeys m)
|
||||||
(withFilesInGit go)
|
(withFilesInGit (commandAction . go))
|
||||||
=<< workTreeItems (whereisFiles o)
|
=<< workTreeItems (whereisFiles o)
|
||||||
|
|
||||||
start :: M.Map UUID Remote -> FilePath -> Key -> CommandStart
|
start :: M.Map UUID Remote -> FilePath -> Key -> CommandStart
|
||||||
start remotemap file key = startKeys remotemap key (mkActionItem afile)
|
start remotemap file key = startKeys remotemap (key, mkActionItem afile)
|
||||||
where
|
where
|
||||||
afile = AssociatedFile (Just file)
|
afile = AssociatedFile (Just file)
|
||||||
|
|
||||||
startKeys :: M.Map UUID Remote -> Key -> ActionItem -> CommandStart
|
startKeys :: M.Map UUID Remote -> (Key, ActionItem) -> CommandStart
|
||||||
startKeys remotemap key ai = do
|
startKeys remotemap (key, ai) = do
|
||||||
showStartKey "whereis" key ai
|
showStartKey "whereis" key ai
|
||||||
next $ perform remotemap key
|
next $ perform remotemap key
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue