refactor some boilerplate

This commit is contained in:
Joey Hess 2011-05-15 02:02:46 -04:00
parent b400984ddf
commit 56bc3e95ca
31 changed files with 93 additions and 86 deletions

View file

@ -65,12 +65,22 @@ data Command = Command {
cmdusesrepo :: Bool cmdusesrepo :: Bool
} }
{- Most commands operate on files in a git repo. -}
repoCommand :: String -> String -> [CommandSeek] -> String -> Command repoCommand :: String -> String -> [CommandSeek] -> String -> Command
repoCommand n p s d = Command n p s d True repoCommand n p s d = Command n p s d True
{- Others can run anywhere. -}
standaloneCommand :: String -> String -> [CommandSeek] -> String -> Command standaloneCommand :: String -> String -> [CommandSeek] -> String -> Command
standaloneCommand n p s d = Command n p s d False standaloneCommand n p s d = Command n p s d False
{- For start and perform stages to indicate what step to run next. -}
next :: a -> Annex (Maybe a)
next a = return $ Just a
{- Or to indicate nothing needs to be done. -}
stop :: Annex (Maybe a)
stop = return Nothing
{- Prepares a list of actions to run to perform a command, based on {- Prepares a list of actions to run to perform a command, based on
- the parameters passed to it. -} - the parameters passed to it. -}
prepCommand :: Command -> [String] -> Annex [Annex Bool] prepCommand :: Command -> [String] -> Annex [Annex Bool]

View file

@ -34,19 +34,19 @@ start :: CommandStartBackendFile
start pair@(file, _) = notAnnexed file $ do start pair@(file, _) = notAnnexed file $ do
s <- liftIO $ getSymbolicLinkStatus file s <- liftIO $ getSymbolicLinkStatus file
if (isSymbolicLink s) || (not $ isRegularFile s) if (isSymbolicLink s) || (not $ isRegularFile s)
then return Nothing then stop
else do else do
showStart "add" file showStart "add" file
return $ Just $ perform pair next $ perform pair
perform :: BackendFile -> CommandPerform perform :: BackendFile -> CommandPerform
perform (file, backend) = do perform (file, backend) = do
stored <- Backend.storeFileKey file backend stored <- Backend.storeFileKey file backend
case stored of case stored of
Nothing -> return Nothing Nothing -> stop
Just (key, _) -> do Just (key, _) -> do
moveAnnex key file moveAnnex key file
return $ Just $ cleanup file key next $ cleanup file key
cleanup :: FilePath -> Key -> CommandCleanup cleanup :: FilePath -> Key -> CommandCleanup
cleanup file key = do cleanup file key = do

View file

@ -25,4 +25,4 @@ start = do
g <- Annex.gitRepo g <- Annex.gitRepo
u <- getUUID g u <- getUUID g
liftIO $ putStrLn $ "annex.uuid=" ++ u liftIO $ putStrLn $ "annex.uuid=" ++ u
return Nothing stop

View file

@ -29,9 +29,9 @@ start params = notBareRepo $ do
showStart "describe" name showStart "describe" name
u <- Remote.nameToUUID name u <- Remote.nameToUUID name
return $ Just $ perform u description next $ perform u description
perform :: UUID -> String -> CommandPerform perform :: UUID -> String -> CommandPerform
perform u description = do perform u description = do
describeUUID u description describeUUID u description
return $ Just $ Command.Init.cleanup next $ Command.Init.cleanup

View file

@ -29,11 +29,11 @@ seek = [withAttrFilesInGit "annex.numcopies" start]
start :: CommandStartAttrFile start :: CommandStartAttrFile
start (file, attr) = isAnnexed file $ \(key, backend) -> do start (file, attr) = isAnnexed file $ \(key, backend) -> do
inbackend <- Backend.hasKey key inbackend <- Backend.hasKey key
if not inbackend if inbackend
then return Nothing then do
else do
showStart "drop" file showStart "drop" file
return $ Just $ perform key backend numcopies next $ perform key backend numcopies
else stop
where where
numcopies = readMaybe attr :: Maybe Int numcopies = readMaybe attr :: Maybe Int
@ -41,8 +41,8 @@ perform :: Key -> Backend Annex -> Maybe Int -> CommandPerform
perform key backend numcopies = do perform key backend numcopies = do
success <- Backend.removeKey backend key numcopies success <- Backend.removeKey backend key numcopies
if success if success
then return $ Just $ cleanup key then next $ cleanup key
else return Nothing else stop
cleanup :: Key -> CommandCleanup cleanup :: Key -> CommandCleanup
cleanup key = do cleanup key = do

View file

@ -26,20 +26,19 @@ start key = do
present <- inAnnex key present <- inAnnex key
force <- Annex.getState Annex.force force <- Annex.getState Annex.force
if not present if not present
then return Nothing then stop
else if not force else if not force
then error "dropkey is can cause data loss; use --force if you're sure you want to do this" then error "dropkey is can cause data loss; use --force if you're sure you want to do this"
else do else do
showStart "dropkey" (show key) showStart "dropkey" (show key)
return $ Just $ perform key next $ perform key
perform :: Key -> CommandPerform perform :: Key -> CommandPerform
perform key = do perform key = do
removeAnnex key removeAnnex key
return $ Just $ cleanup key next $ cleanup key
cleanup :: Key -> CommandCleanup cleanup :: Key -> CommandCleanup
cleanup key = do cleanup key = do
logStatus key ValueMissing logStatus key ValueMissing
return True return True

View file

@ -49,13 +49,13 @@ start (unused, unusedbad, unusedtmp) s = notBareRepo $ search
, (unusedtmp, performOther gitAnnexTmpLocation) , (unusedtmp, performOther gitAnnexTmpLocation)
] ]
where where
search [] = return Nothing search [] = stop
search ((m, a):rest) = do search ((m, a):rest) = do
case M.lookup s m of case M.lookup s m of
Nothing -> search rest Nothing -> search rest
Just key -> do Just key -> do
showStart "dropunused" s showStart "dropunused" s
return $ Just $ a key next $ a key
perform :: Key -> CommandPerform perform :: Key -> CommandPerform
perform key = do perform key = do
@ -64,7 +64,7 @@ perform key = do
Just name -> do Just name -> do
r <- Remote.byName name r <- Remote.byName name
showNote $ "from " ++ Remote.name r ++ "..." showNote $ "from " ++ Remote.name r ++ "..."
return $ Just $ Command.Move.fromCleanup r True key next $ Command.Move.fromCleanup r True key
_ -> do _ -> do
backend <- keyBackend key backend <- keyBackend key
Command.Drop.perform key backend (Just 0) -- force drop Command.Drop.perform key backend (Just 0) -- force drop
@ -75,7 +75,7 @@ performOther filespec key = do
let f = filespec g key let f = filespec g key
e <- liftIO $ doesFileExist f e <- liftIO $ doesFileExist f
when e $ liftIO $ removeFile f when e $ liftIO $ removeFile f
return $ Just $ return True next $ return True
readUnusedLog :: FilePath -> Annex UnusedMap readUnusedLog :: FilePath -> Annex UnusedMap
readUnusedLog prefix = do readUnusedLog prefix = do

View file

@ -25,4 +25,4 @@ start :: CommandStartString
start file = isAnnexed file $ \(key, _) -> do start file = isAnnexed file $ \(key, _) -> do
exists <- inAnnex key exists <- inAnnex key
when exists $ liftIO $ putStrLn file when exists $ liftIO $ putStrLn file
return Nothing stop

View file

@ -30,17 +30,17 @@ start file = isAnnexed file $ \(key, _) -> do
link <- calcGitLink file key link <- calcGitLink file key
l <- liftIO $ readSymbolicLink file l <- liftIO $ readSymbolicLink file
if link == l if link == l
then return Nothing then stop
else do else do
showStart "fix" file showStart "fix" file
return $ Just $ perform file link next $ perform file link
perform :: FilePath -> FilePath -> CommandPerform perform :: FilePath -> FilePath -> CommandPerform
perform file link = do perform file link = do
liftIO $ createDirectoryIfMissing True (parentDir file) liftIO $ createDirectoryIfMissing True (parentDir file)
liftIO $ removeFile file liftIO $ removeFile file
liftIO $ createSymbolicLink link file liftIO $ createSymbolicLink link file
return $ Just $ cleanup file next $ cleanup file
cleanup :: FilePath -> CommandCleanup cleanup :: FilePath -> CommandCleanup
cleanup file = do cleanup file = do

View file

@ -34,7 +34,7 @@ start file = notBareRepo $ do
unless inbackend $ error $ unless inbackend $ error $
"key ("++keyName key++") is not present in backend" "key ("++keyName key++") is not present in backend"
showStart "fromkey" file showStart "fromkey" file
return $ Just $ perform file next $ perform file
perform :: FilePath -> CommandPerform perform :: FilePath -> CommandPerform
perform file = do perform file = do
@ -42,7 +42,7 @@ perform file = do
link <- calcGitLink file key link <- calcGitLink file key
liftIO $ createDirectoryIfMissing True (parentDir file) liftIO $ createDirectoryIfMissing True (parentDir file)
liftIO $ createSymbolicLink link file liftIO $ createSymbolicLink link file
return $ Just $ cleanup file next $ cleanup file
cleanup :: FilePath -> CommandCleanup cleanup :: FilePath -> CommandCleanup
cleanup file = do cleanup file = do

View file

@ -31,7 +31,7 @@ seek = [withAttrFilesInGit "annex.numcopies" start]
start :: CommandStartAttrFile start :: CommandStartAttrFile
start (file, attr) = notBareRepo $ isAnnexed file $ \(key, backend) -> do start (file, attr) = notBareRepo $ isAnnexed file $ \(key, backend) -> do
showStart "fsck" file showStart "fsck" file
return $ Just $ perform key file backend numcopies next $ perform key file backend numcopies
where where
numcopies = readMaybe attr :: Maybe Int numcopies = readMaybe attr :: Maybe Int
@ -42,8 +42,8 @@ perform key file backend numcopies = do
locationlogok <- verifyLocationLog key file locationlogok <- verifyLocationLog key file
backendok <- Backend.fsckKey backend key (Just file) numcopies backendok <- Backend.fsckKey backend key (Just file) numcopies
if locationlogok && backendok if locationlogok && backendok
then return $ Just $ return True then next $ return True
else return Nothing else stop
{- Checks that the location log reflects the current status of the key, {- Checks that the location log reflects the current status of the key,
in this repository only. -} in this repository only. -}

View file

@ -25,15 +25,14 @@ start :: CommandStartString
start file = isAnnexed file $ \(key, backend) -> do start file = isAnnexed file $ \(key, backend) -> do
inannex <- inAnnex key inannex <- inAnnex key
if inannex if inannex
then return Nothing then stop
else do else do
showStart "get" file showStart "get" file
return $ Just $ perform key backend next $ perform key backend
perform :: Key -> Backend Annex -> CommandPerform perform :: Key -> Backend Annex -> CommandPerform
perform key backend = do perform key backend = do
ok <- getViaTmp key (Backend.retrieveKeyFile backend key) ok <- getViaTmp key (Backend.retrieveKeyFile backend key)
if ok if ok
then return $ Just $ return True -- no cleanup needed then next $ return True -- no cleanup needed
else return Nothing else stop

View file

@ -24,5 +24,5 @@ start :: CommandStartKey
start key = do start key = do
present <- inAnnex key present <- inAnnex key
if present if present
then return Nothing then stop
else liftIO $ exitFailure else liftIO $ exitFailure

View file

@ -35,7 +35,7 @@ start description = do
when (null description) $ when (null description) $
error "please specify a description of this repository\n" error "please specify a description of this repository\n"
showStart "init" description showStart "init" description
return $ Just $ perform description next $ perform description
perform :: String -> CommandPerform perform :: String -> CommandPerform
perform description = do perform description = do
@ -48,12 +48,12 @@ perform description = do
"This is a bare repository, so its description cannot be committed.\n" ++ "This is a bare repository, so its description cannot be committed.\n" ++
"To record the description, run this command in a clone of this repository:\n" ++ "To record the description, run this command in a clone of this repository:\n" ++
" git annex describe " ++ show u ++ " " ++ show description ++ "\n\n" " git annex describe " ++ show u ++ " " ++ show description ++ "\n\n"
return $ Just $ return True next $ return True
else do else do
describeUUID u description describeUUID u description
liftIO $ gitAttributesWrite g liftIO $ gitAttributesWrite g
gitPreCommitHookWrite g gitPreCommitHookWrite g
return $ Just cleanup next cleanup
cleanup :: CommandCleanup cleanup :: CommandCleanup
cleanup = do cleanup = do

View file

@ -39,7 +39,7 @@ start params = notBareRepo $ do
t <- findType fullconfig t <- findType fullconfig
showStart "initremote" name showStart "initremote" name
return $ Just $ perform t u $ M.union config c next $ perform t u $ M.union config c
where where
ws = words params ws = words params
@ -49,7 +49,7 @@ start params = notBareRepo $ do
perform :: RemoteClass.RemoteType Annex -> UUID -> RemoteClass.RemoteConfig -> CommandPerform perform :: RemoteClass.RemoteType Annex -> UUID -> RemoteClass.RemoteConfig -> CommandPerform
perform t u c = do perform t u c = do
c' <- RemoteClass.setup t u c c' <- RemoteClass.setup t u c
return $ Just $ cleanup u c' next $ cleanup u c'
cleanup :: UUID -> RemoteClass.RemoteConfig -> CommandCleanup cleanup :: UUID -> RemoteClass.RemoteConfig -> CommandCleanup
cleanup u c = do cleanup u c = do

View file

@ -26,7 +26,7 @@ seek = [withFilesUnlocked start]
start :: CommandStartBackendFile start :: CommandStartBackendFile
start (file, _) = do start (file, _) = do
showStart "lock" file showStart "lock" file
return $ Just $ perform file next $ perform file
perform :: FilePath -> CommandPerform perform :: FilePath -> CommandPerform
perform file = do perform file = do
@ -36,4 +36,4 @@ perform file = do
liftIO $ Git.run g "reset" [Params "-q --", File file] liftIO $ Git.run g "reset" [Params "-q --", File file]
-- checkout the symlink -- checkout the symlink
liftIO $ Git.run g "checkout" [Param "--", File file] liftIO $ Git.run g "checkout" [Param "--", File file]
return $ Just $ return True -- no cleanup needed next $ return True -- no cleanup needed

View file

@ -45,7 +45,7 @@ start = do
showLongNote $ "running: dot -Tx11 " ++ file showLongNote $ "running: dot -Tx11 " ++ file
showProgress showProgress
r <- liftIO $ boolSystem "dot" [Param "-Tx11", File file] r <- liftIO $ boolSystem "dot" [Param "-Tx11", File file]
return $ Just $ return $ Just $ return r next $ next $ return r
where where
file = "map.dot" file = "map.dot"

View file

@ -35,9 +35,8 @@ start (file, b) = isAnnexed file $ \(key, oldbackend) -> do
if (newbackend /= oldbackend || upgradable) && exists if (newbackend /= oldbackend || upgradable) && exists
then do then do
showStart "migrate" file showStart "migrate" file
return $ Just $ perform file key newbackend next $ perform file key newbackend
else else stop
return Nothing
where where
choosebackend Nothing = do choosebackend Nothing = do
backends <- Backend.list backends <- Backend.list
@ -55,7 +54,7 @@ perform file oldkey newbackend = do
let src = gitAnnexLocation g oldkey let src = gitAnnexLocation g oldkey
stored <- Backend.storeFileKey src $ Just newbackend stored <- Backend.storeFileKey src $ Just newbackend
case stored of case stored of
Nothing -> return Nothing Nothing -> stop
Just (newkey, _) -> do Just (newkey, _) -> do
ok <- getViaTmpUnchecked newkey $ \t -> do ok <- getViaTmpUnchecked newkey $ \t -> do
-- Make a hard link to the old backend's -- Make a hard link to the old backend's
@ -68,5 +67,5 @@ perform file oldkey newbackend = do
then do then do
-- Update symlink to use the new key. -- Update symlink to use the new key.
liftIO $ removeFile file liftIO $ removeFile file
return $ Just $ Command.Add.cleanup file newkey next $ Command.Add.cleanup file newkey
else return Nothing else stop

View file

@ -73,10 +73,10 @@ toStart dest move file = isAnnexed file $ \(key, _) -> do
u <- getUUID g u <- getUUID g
ishere <- inAnnex key ishere <- inAnnex key
if not ishere || u == Remote.uuid dest if not ishere || u == Remote.uuid dest
then return Nothing -- not here, so nothing to do then stop -- not here, so nothing to do
else do else do
showAction move file showAction move file
return $ Just $ toPerform dest move key next $ toPerform dest move key
toPerform :: Remote.Remote Annex -> Bool -> Key -> CommandPerform toPerform :: Remote.Remote Annex -> Bool -> Key -> CommandPerform
toPerform dest move key = do toPerform dest move key = do
-- Checking the remote is expensive, so not done in the start step. -- Checking the remote is expensive, so not done in the start step.
@ -92,14 +92,14 @@ toPerform dest move key = do
case isthere of case isthere of
Left err -> do Left err -> do
showNote $ show err showNote $ show err
return Nothing stop
Right False -> do Right False -> do
showNote $ "to " ++ Remote.name dest ++ "..." showNote $ "to " ++ Remote.name dest ++ "..."
ok <- Remote.storeKey dest key ok <- Remote.storeKey dest key
if ok if ok
then return $ Just $ toCleanup dest move key then next $ toCleanup dest move key
else return Nothing -- failed else stop -- failed
Right True -> return $ Just $ toCleanup dest move key Right True -> next $ toCleanup dest move key
toCleanup :: Remote.Remote Annex -> Bool -> Key -> CommandCleanup toCleanup :: Remote.Remote Annex -> Bool -> Key -> CommandCleanup
toCleanup dest move key = do toCleanup dest move key = do
remoteHasKey dest key True remoteHasKey dest key True
@ -119,21 +119,21 @@ fromStart src move file = isAnnexed file $ \(key, _) -> do
u <- getUUID g u <- getUUID g
(remotes, _) <- Remote.keyPossibilities key (remotes, _) <- Remote.keyPossibilities key
if (u == Remote.uuid src) || (null $ filter (== src) remotes) if (u == Remote.uuid src) || (null $ filter (== src) remotes)
then return Nothing then stop
else do else do
showAction move file showAction move file
return $ Just $ fromPerform src move key next $ fromPerform src move key
fromPerform :: Remote.Remote Annex -> Bool -> Key -> CommandPerform fromPerform :: Remote.Remote Annex -> Bool -> Key -> CommandPerform
fromPerform src move key = do fromPerform src move key = do
ishere <- inAnnex key ishere <- inAnnex key
if ishere if ishere
then return $ Just $ fromCleanup src move key then next $ fromCleanup src move key
else do else do
showNote $ "from " ++ Remote.name src ++ "..." showNote $ "from " ++ Remote.name src ++ "..."
ok <- getViaTmp key $ Remote.retrieveKeyFile src key ok <- getViaTmp key $ Remote.retrieveKeyFile src key
if ok if ok
then return $ Just $ fromCleanup src move key then next $ fromCleanup src move key
else return Nothing -- fail else stop -- fail
fromCleanup :: Remote.Remote Annex -> Bool -> Key -> CommandCleanup fromCleanup :: Remote.Remote Annex -> Bool -> Key -> CommandCleanup
fromCleanup src True key = do fromCleanup src True key = do
ok <- Remote.removeKey src key ok <- Remote.removeKey src key

View file

@ -27,13 +27,13 @@ seek = [withFilesToBeCommitted Command.Fix.start,
withFilesUnlockedToBeCommitted start] withFilesUnlockedToBeCommitted start]
start :: CommandStartBackendFile start :: CommandStartBackendFile
start pair = return $ Just $ perform pair start pair = next $ perform pair
perform :: BackendFile -> CommandPerform perform :: BackendFile -> CommandPerform
perform pair@(file, _) = do perform pair@(file, _) = do
ok <- doCommand $ Command.Add.start pair ok <- doCommand $ Command.Add.start pair
if ok if ok
then return $ Just $ cleanup file then next $ cleanup file
else error $ "failed to add " ++ file ++ "; canceling commit" else error $ "failed to add " ++ file ++ "; canceling commit"
cleanup :: FilePath -> CommandCleanup cleanup :: FilePath -> CommandCleanup

View file

@ -24,9 +24,9 @@ start :: CommandStartString
start name = notBareRepo $ do start name = notBareRepo $ do
showStart "semitrust" name showStart "semitrust" name
u <- Remote.nameToUUID name u <- Remote.nameToUUID name
return $ Just $ perform u next $ perform u
perform :: UUID -> CommandPerform perform :: UUID -> CommandPerform
perform uuid = do perform uuid = do
trustSet uuid SemiTrusted trustSet uuid SemiTrusted
return $ Just $ return True next $ return True

View file

@ -26,7 +26,7 @@ seek = [withTempFile start]
start :: CommandStartString start :: CommandStartString
start file = do start file = do
showStart "setkey" file showStart "setkey" file
return $ Just $ perform file next $ perform file
perform :: FilePath -> CommandPerform perform :: FilePath -> CommandPerform
perform file = do perform file = do
@ -40,7 +40,7 @@ perform file = do
boolSystem "mv" [File file, File dest] boolSystem "mv" [File file, File dest]
else return True else return True
if ok if ok
then return $ Just $ cleanup then next cleanup
else error "mv failed!" else error "mv failed!"
cleanup :: CommandCleanup cleanup :: CommandCleanup

View file

@ -24,9 +24,9 @@ start :: CommandStartString
start name = notBareRepo $ do start name = notBareRepo $ do
showStart "trust" name showStart "trust" name
u <- Remote.nameToUUID name u <- Remote.nameToUUID name
return $ Just $ perform u next $ perform u
perform :: UUID -> CommandPerform perform :: UUID -> CommandPerform
perform uuid = do perform uuid = do
trustSet uuid Trusted trustSet uuid Trusted
return $ Just $ return True next $ return True

View file

@ -43,16 +43,16 @@ start file = isAnnexed file $ \(key, backend) -> do
Annex.changeState $ \s -> s { Annex.force = True } Annex.changeState $ \s -> s { Annex.force = True }
showStart "unannex" file showStart "unannex" file
return $ Just $ perform file key backend next $ perform file key backend
else return Nothing else stop
perform :: FilePath -> Key -> Backend Annex -> CommandPerform perform :: FilePath -> Key -> Backend Annex -> CommandPerform
perform file key backend = do perform file key backend = do
-- force backend to always remove -- force backend to always remove
ok <- Backend.removeKey backend key (Just 0) ok <- Backend.removeKey backend key (Just 0)
if ok if ok
then return $ Just $ cleanup file key then next $ cleanup file key
else return Nothing else stop
cleanup :: FilePath -> Key -> CommandCleanup cleanup :: FilePath -> Key -> CommandCleanup
cleanup file key = do cleanup file key = do

View file

@ -30,7 +30,7 @@ seek = [withFilesInGit Command.Unannex.start, withNothing start]
start :: CommandStartNothing start :: CommandStartNothing
start = do start = do
showStart "uninit" "" showStart "uninit" ""
return $ Just $ perform next perform
perform :: CommandPerform perform :: CommandPerform
perform = do perform = do
@ -39,7 +39,7 @@ perform = do
gitPreCommitHookUnWrite g gitPreCommitHookUnWrite g
liftIO $ gitAttributesUnWrite g liftIO $ gitAttributesUnWrite g
return $ Just $ return True next $ return True
gitPreCommitHookUnWrite :: Git.Repo -> Annex () gitPreCommitHookUnWrite :: Git.Repo -> Annex ()
gitPreCommitHookUnWrite repo = do gitPreCommitHookUnWrite repo = do

View file

@ -34,7 +34,7 @@ seek = [withFilesInGit start]
start :: CommandStartString start :: CommandStartString
start file = isAnnexed file $ \(key, _) -> do start file = isAnnexed file $ \(key, _) -> do
showStart "unlock" file showStart "unlock" file
return $ Just $ perform file key next $ perform file key
perform :: FilePath -> Key -> CommandPerform perform :: FilePath -> Key -> CommandPerform
perform dest key = do perform dest key = do
@ -52,5 +52,5 @@ perform dest key = do
if ok if ok
then do then do
liftIO $ allowWrite dest liftIO $ allowWrite dest
return $ Just $ return True next $ return True
else error "copy failed!" else error "copy failed!"

View file

@ -24,9 +24,9 @@ start :: CommandStartString
start name = notBareRepo $ do start name = notBareRepo $ do
showStart "untrust" name showStart "untrust" name
u <- Remote.nameToUUID name u <- Remote.nameToUUID name
return $ Just $ perform u next $ perform u
perform :: UUID -> CommandPerform perform :: UUID -> CommandPerform
perform uuid = do perform uuid = do
trustSet uuid UnTrusted trustSet uuid UnTrusted
return $ Just $ return True next $ return True

View file

@ -37,7 +37,7 @@ seek = [withNothing start]
start :: CommandStartNothing start :: CommandStartNothing
start = notBareRepo $ do start = notBareRepo $ do
showStart "unused" "" showStart "unused" ""
return $ Just perform next perform
perform :: CommandPerform perform :: CommandPerform
perform = do perform = do
@ -47,7 +47,7 @@ perform = do
r <- Remote.byName name r <- Remote.byName name
checkRemoteUnused r checkRemoteUnused r
_ -> checkUnused _ -> checkUnused
return $ Just $ return True next $ return True
checkUnused :: Annex () checkUnused :: Annex ()
checkUnused = do checkUnused = do

View file

@ -24,4 +24,4 @@ start = do
showStart "upgrade" "" showStart "upgrade" ""
r <- upgrade r <- upgrade
checkVersion checkVersion
return $ Just $ return $ Just $ return r next $ next $ return r

View file

@ -28,6 +28,6 @@ start = do
liftIO $ putStrLn $ "default repository version: " ++ defaultVersion liftIO $ putStrLn $ "default repository version: " ++ defaultVersion
liftIO $ putStrLn $ "supported repository versions: " ++ vs supportedVersions liftIO $ putStrLn $ "supported repository versions: " ++ vs supportedVersions
liftIO $ putStrLn $ "upgrade supported from repository versions: " ++ vs upgradableVersions liftIO $ putStrLn $ "upgrade supported from repository versions: " ++ vs upgradableVersions
return Nothing stop
where where
vs l = join " " l vs l = join " " l

View file

@ -26,7 +26,7 @@ seek = [withFilesInGit start]
start :: CommandStartString start :: CommandStartString
start file = isAnnexed file $ \(key, _) -> do start file = isAnnexed file $ \(key, _) -> do
showStart "whereis" file showStart "whereis" file
return $ Just $ perform key next $ perform key
perform :: Key -> CommandPerform perform :: Key -> CommandPerform
perform key = do perform key = do
@ -35,12 +35,12 @@ perform key = do
let num = length uuids let num = length uuids
showNote $ show num ++ " " ++ copiesplural num showNote $ show num ++ " " ++ copiesplural num
if null $ uuids if null $ uuids
then return Nothing then stop
else do else do
pp <- prettyPrintUUIDs uuids pp <- prettyPrintUUIDs uuids
showLongNote $ pp showLongNote $ pp
showProgress showProgress
return $ Just $ return True next $ return True
where where
copiesplural 1 = "copy" copiesplural 1 = "copy"
copiesplural _ = "copies" copiesplural _ = "copies"