aboutsummaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-11-22 17:51:55 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-11-22 17:51:55 -0400
commiteeae91024285c85a7e77b1b44e501a63bced7154 (patch)
treeece6c1d1e670e04001dd570a375ed9954078da0a /Command
parent57adb0347bf4eb71ab846a2947680a20263449a2 (diff)
finished hlinting
Diffstat (limited to 'Command')
-rw-r--r--Command/Add.hs4
-rw-r--r--Command/Drop.hs6
-rw-r--r--Command/DropKey.hs6
-rw-r--r--Command/Find.hs2
-rw-r--r--Command/Fix.hs2
-rw-r--r--Command/FromKey.hs4
-rw-r--r--Command/Fsck.hs2
-rw-r--r--Command/FsckFile.hs2
-rw-r--r--Command/Get.hs4
-rw-r--r--Command/Init.hs10
-rw-r--r--Command/Move.hs25
-rw-r--r--Command/PreCommit.hs2
-rw-r--r--Command/SetKey.hs2
-rw-r--r--Command/Unannex.hs2
-rw-r--r--Command/Unused.hs8
15 files changed, 40 insertions, 41 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index 586807b53..cf32a8d64 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -28,7 +28,7 @@ seek = [withFilesNotInGit start, withFilesUnlocked start]
start :: SubCmdStartBackendFile
start pair@(file, _) = notAnnexed file $ do
s <- liftIO $ getSymbolicLinkStatus file
- if ((isSymbolicLink s) || (not $ isRegularFile s))
+ if (isSymbolicLink s) || (not $ isRegularFile s)
then return Nothing
else do
showStart "add" file
@@ -37,7 +37,7 @@ start pair@(file, _) = notAnnexed file $ do
perform :: (FilePath, Maybe Backend) -> SubCmdPerform
perform (file, backend) = do
stored <- Backend.storeFileKey file backend
- case (stored) of
+ case stored of
Nothing -> return Nothing
Just (key, _) -> return $ Just $ cleanup file key
diff --git a/Command/Drop.hs b/Command/Drop.hs
index 1e73d8b82..fbe66f584 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -24,7 +24,7 @@ seek = [withFilesInGit start]
start :: SubCmdStartString
start file = isAnnexed file $ \(key, backend) -> do
inbackend <- Backend.hasKey key
- if (not inbackend)
+ if not inbackend
then return Nothing
else do
showStart "drop" file
@@ -33,13 +33,13 @@ start file = isAnnexed file $ \(key, backend) -> do
perform :: Key -> Backend -> SubCmdPerform
perform key backend = do
success <- Backend.removeKey backend key
- if (success)
+ if success
then return $ Just $ cleanup key
else return Nothing
cleanup :: Key -> SubCmdCleanup
cleanup key = do
inannex <- inAnnex key
- when (inannex) $ removeAnnex key
+ when inannex $ removeAnnex key
logStatus key ValueMissing
return True
diff --git a/Command/DropKey.hs b/Command/DropKey.hs
index 34010481d..aa72e1bbd 100644
--- a/Command/DropKey.hs
+++ b/Command/DropKey.hs
@@ -22,12 +22,12 @@ seek = [withKeys start]
start :: SubCmdStartString
start keyname = do
backends <- Backend.list
- let key = genKey (backends !! 0) keyname
+ let key = genKey (head backends) keyname
present <- inAnnex key
force <- Annex.flagIsSet "force"
- if (not present)
+ if not present
then return Nothing
- 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"
else do
showStart "dropkey" keyname
diff --git a/Command/Find.hs b/Command/Find.hs
index db0589fea..7b3c8c463 100644
--- a/Command/Find.hs
+++ b/Command/Find.hs
@@ -20,5 +20,5 @@ seek = [withDefault "." withFilesInGit start]
start :: SubCmdStartString
start file = isAnnexed file $ \(key, _) -> do
exists <- inAnnex key
- when (exists) $ liftIO $ putStrLn file
+ when exists $ liftIO $ putStrLn file
return Nothing
diff --git a/Command/Fix.hs b/Command/Fix.hs
index 323aca95e..33630031f 100644
--- a/Command/Fix.hs
+++ b/Command/Fix.hs
@@ -25,7 +25,7 @@ start :: SubCmdStartString
start file = isAnnexed file $ \(key, _) -> do
link <- calcGitLink file key
l <- liftIO $ readSymbolicLink file
- if (link == l)
+ if link == l
then return Nothing
else do
showStart "fix" file
diff --git a/Command/FromKey.hs b/Command/FromKey.hs
index f25de23a2..eb9ad5e51 100644
--- a/Command/FromKey.hs
+++ b/Command/FromKey.hs
@@ -29,10 +29,10 @@ start file = do
keyname <- Annex.flagGet "key"
when (null keyname) $ error "please specify the key with --key"
backends <- Backend.list
- let key = genKey (backends !! 0) keyname
+ let key = genKey (head backends) keyname
inbackend <- Backend.hasKey key
- unless (inbackend) $ error $
+ unless inbackend $ error $
"key ("++keyname++") is not present in backend"
showStart "fromkey" file
return $ Just $ perform file key
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 6291d5ba3..dc0168801 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -24,6 +24,6 @@ start file = isAnnexed file $ \(key, backend) -> do
perform :: Key -> Backend -> SubCmdPerform
perform key backend = do
success <- Backend.fsckKey backend key
- if (success)
+ if success
then return $ Just $ return True
else return Nothing
diff --git a/Command/FsckFile.hs b/Command/FsckFile.hs
index c74e94e62..e7c3d4915 100644
--- a/Command/FsckFile.hs
+++ b/Command/FsckFile.hs
@@ -24,6 +24,6 @@ start file = isAnnexed file $ \(key, backend) -> do
perform :: Key -> Backend -> SubCmdPerform
perform key backend = do
success <- Backend.fsckKey backend key
- if (success)
+ if success
then return $ Just $ return True
else return Nothing
diff --git a/Command/Get.hs b/Command/Get.hs
index 13d137537..628ed6293 100644
--- a/Command/Get.hs
+++ b/Command/Get.hs
@@ -20,7 +20,7 @@ seek = [withFilesInGit start]
start :: SubCmdStartString
start file = isAnnexed file $ \(key, backend) -> do
inannex <- inAnnex key
- if (inannex)
+ if inannex
then return Nothing
else do
showStart "get" file
@@ -29,7 +29,7 @@ start file = isAnnexed file $ \(key, backend) -> do
perform :: Key -> Backend -> SubCmdPerform
perform key backend = do
ok <- getViaTmp key (Backend.retrieveKeyFile backend key)
- if (ok)
+ if ok
then return $ Just $ return True -- no cleanup needed
else return Nothing
diff --git a/Command/Init.hs b/Command/Init.hs
index c928647a5..eb5c58696 100644
--- a/Command/Init.hs
+++ b/Command/Init.hs
@@ -25,8 +25,8 @@ seek = [withString start]
{- Stores description for the repository etc. -}
start :: SubCmdStartString
start description = do
- when (null description) $ error $
- "please specify a description of this repository\n"
+ when (null description) $
+ error "please specify a description of this repository\n"
showStart "init" description
return $ Just $ perform description
@@ -38,7 +38,7 @@ perform description = do
setVersion
liftIO $ gitAttributes g
liftIO $ gitPreCommitHook g
- return $ Just $ cleanup
+ return $ Just cleanup
cleanup :: SubCmdCleanup
cleanup = do
@@ -53,7 +53,7 @@ cleanup = do
gitAttributes :: Git.Repo -> IO ()
gitAttributes repo = do
exists <- doesFileExist attributes
- if (not exists)
+ if not exists
then do
writeFile attributes $ attrLine ++ "\n"
commit
@@ -76,7 +76,7 @@ gitPreCommitHook repo = do
let hook = Git.workTree repo ++ "/" ++ Git.gitDir repo ++
"/hooks/pre-commit"
exists <- doesFileExist hook
- if (exists)
+ if exists
then putStrLn $ "pre-commit hook (" ++ hook ++ ") already exists, not configuring"
else do
writeFile hook $ "#!/bin/sh\n" ++
diff --git a/Command/Move.hs b/Command/Move.hs
index 7f8f40737..c18054c90 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -7,8 +7,7 @@
module Command.Move where
-import Control.Monad.State (liftIO)
-import Monad (when)
+import Control.Monad.State (liftIO, when)
import Command
import qualified Command.Drop
@@ -53,7 +52,7 @@ start file = do
moveToStart :: SubCmdStartString
moveToStart file = isAnnexed file $ \(key, _) -> do
ishere <- inAnnex key
- if (not ishere)
+ if not ishere
then return Nothing -- not here, so nothing to do
else do
showStart "move" file
@@ -68,10 +67,10 @@ moveToPerform key = do
showNote $ show err
return Nothing
Right False -> do
- showNote $ "moving to " ++ (Git.repoDescribe remote) ++ "..."
- let tmpfile = (annexTmpLocation remote) ++ (keyFile key)
+ showNote $ "moving to " ++ Git.repoDescribe remote ++ "..."
+ let tmpfile = annexTmpLocation remote ++ keyFile key
ok <- Remotes.copyToRemote remote key tmpfile
- if (ok)
+ if ok
then return $ Just $ moveToCleanup remote key tmpfile
else return Nothing -- failed
Right True -> return $ Just $ Command.Drop.cleanup key
@@ -79,7 +78,7 @@ moveToCleanup :: Git.Repo -> Key -> FilePath -> SubCmdCleanup
moveToCleanup remote key tmpfile = do
-- Tell remote to use the transferred content.
ok <- Remotes.runCmd remote "git-annex" ["setkey", "--quiet",
- "--backend=" ++ (backendName key),
+ "--backend=" ++ backendName key,
"--key=" ++ keyName key,
tmpfile]
if ok
@@ -104,7 +103,7 @@ moveFromStart :: SubCmdStartString
moveFromStart file = isAnnexed file $ \(key, _) -> do
remote <- Remotes.commandLineRemote
l <- Remotes.keyPossibilities key
- if (null $ filter (\r -> Remotes.same r remote) l)
+ if null $ filter (\r -> Remotes.same r remote) l
then return Nothing
else do
showStart "move" file
@@ -113,18 +112,18 @@ moveFromPerform :: Key -> SubCmdPerform
moveFromPerform key = do
remote <- Remotes.commandLineRemote
ishere <- inAnnex key
- if (ishere)
+ if ishere
then return $ Just $ moveFromCleanup remote key
else do
- showNote $ "moving from " ++ (Git.repoDescribe remote) ++ "..."
- ok <- getViaTmp key (Remotes.copyFromRemote remote key)
- if (ok)
+ showNote $ "moving from " ++ Git.repoDescribe remote ++ "..."
+ ok <- getViaTmp key $ Remotes.copyFromRemote remote key
+ if ok
then return $ Just $ moveFromCleanup remote key
else return Nothing -- fail
moveFromCleanup :: Git.Repo -> Key -> SubCmdCleanup
moveFromCleanup remote key = do
ok <- Remotes.runCmd remote "git-annex" ["dropkey", "--quiet", "--force",
- "--backend=" ++ (backendName key),
+ "--backend=" ++ backendName key,
keyName key]
when ok $ do
-- Record locally that the key is not on the remote.
diff --git a/Command/PreCommit.hs b/Command/PreCommit.hs
index a15510bd9..d4e5c04b9 100644
--- a/Command/PreCommit.hs
+++ b/Command/PreCommit.hs
@@ -28,7 +28,7 @@ start file = return $ Just $ perform file
perform :: FilePath -> SubCmdPerform
perform file = do
pairs <- Backend.chooseBackends [file]
- ok <- doSubCmd $ Command.Add.start $ pairs !! 0
+ ok <- doSubCmd $ Command.Add.start $ head pairs
if ok
then return $ Just $ cleanup file
else error $ "failed to add " ++ file ++ "; canceling commit"
diff --git a/Command/SetKey.hs b/Command/SetKey.hs
index e8d407b83..685872f73 100644
--- a/Command/SetKey.hs
+++ b/Command/SetKey.hs
@@ -28,7 +28,7 @@ start file = do
keyname <- Annex.flagGet "key"
when (null keyname) $ error "please specify the key with --key"
backends <- Backend.list
- let key = genKey (backends !! 0) keyname
+ let key = genKey (head backends) keyname
showStart "setkey" file
return $ Just $ perform file key
perform :: FilePath -> Key -> SubCmdPerform
diff --git a/Command/Unannex.hs b/Command/Unannex.hs
index e85e8486f..90ae55058 100644
--- a/Command/Unannex.hs
+++ b/Command/Unannex.hs
@@ -34,7 +34,7 @@ perform file key backend = do
-- force backend to always remove
Annex.flagChange "force" $ FlagBool True
ok <- Backend.removeKey backend key
- if (ok)
+ if ok
then return $ Just $ cleanup file key
else return Nothing
diff --git a/Command/Unused.hs b/Command/Unused.hs
index ae189550c..de34ceae9 100644
--- a/Command/Unused.hs
+++ b/Command/Unused.hs
@@ -35,7 +35,7 @@ checkUnused :: Annex Bool
checkUnused = do
showNote "checking for unused data..."
unused <- unusedKeys
- if (null unused)
+ if null unused
then return True
else do
let list = number 1 unused
@@ -48,9 +48,10 @@ checkUnused = do
w u = unlines $
["Some annexed data is no longer pointed to by any files in the repository:",
" NUMBER KEY"]
- ++ (map (\(n, k) -> " " ++ (pad 6 $ show n) ++ " " ++ show k) u) ++
+ ++ map cols u ++
["(To see where data was previously used, try: git log --stat -S'KEY')",
"(To remove unwanted data: git-annex dropunused NUMBER)"]
+ cols (n,k) = " " ++ pad 6 (show n) ++ " " ++ show k
pad n s = s ++ replicate (n - length s) ' '
number :: Integer -> [a] -> [(Integer, a)]
@@ -71,8 +72,7 @@ unusedKeys = do
let unused_m = remove referenced present_m
return $ M.keys unused_m
where
- remove [] m = m
- remove (x:xs) m = remove xs $ M.delete x m
+ remove a b = foldl (flip M.delete) b a
existsMap :: Ord k => [k] -> M.Map k Int
existsMap l = M.fromList $ map (\k -> (k, 1)) l