diff options
author | Joey Hess <joey@kitenet.net> | 2011-10-11 14:43:45 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-10-11 14:43:45 -0400 |
commit | b505ba83e8b62a9ed0ec2fb96448c5fc801184d9 (patch) | |
tree | 664eb4af9f274dfc13eb9abfab86421ebe38e881 /Utility | |
parent | 025ded4a2dfb58a6ec0cb47b9d625d593a4e1977 (diff) |
minor syntax changes
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/Path.hs | 21 | ||||
-rw-r--r-- | Utility/Ssh.hs | 2 |
2 files changed, 9 insertions, 14 deletions
diff --git a/Utility/Path.hs b/Utility/Path.hs index ce54fb369..1c68b87bb 100644 --- a/Utility/Path.hs +++ b/Utility/Path.hs @@ -17,10 +17,9 @@ import Control.Applicative {- Returns the parent directory of a path. Parent of / is "" -} parentDir :: FilePath -> FilePath -parentDir dir = - if not $ null dirs - then slash ++ join s (init dirs) - else "" +parentDir dir + | not $ null dirs = slash ++ join s (init dirs) + | otherwise = "" where dirs = filter (not . null) $ split s dir slash = if isAbsolute dir then s else "" @@ -72,7 +71,7 @@ relPathCwdToFile f = relPathDirToFile <$> getCurrentDirectory <*> absPath f - Both must be absolute, and normalized (eg with absNormpath). -} relPathDirToFile :: FilePath -> FilePath -> FilePath -relPathDirToFile from to = path +relPathDirToFile from to = join s $ dotdots ++ uncommon where s = [pathSeparator] pfrom = split s from @@ -82,7 +81,6 @@ relPathDirToFile from to = path uncommon = drop numcommon pto dotdots = replicate (length pfrom - numcommon) ".." numcommon = length common - path = join s $ dotdots ++ uncommon prop_relPathDirToFile_basics :: FilePath -> FilePath -> Bool prop_relPathDirToFile_basics from to @@ -99,14 +97,11 @@ prop_relPathDirToFile_basics from to - appear at the same position as it did in the input list. -} preserveOrder :: [FilePath] -> [FilePath] -> [FilePath] --- optimisation, only one item in original list, so no reordering needed -preserveOrder [_] new = new -preserveOrder orig new = collect orig new +preserveOrder [] new = new +preserveOrder [_] new = new -- optimisation +preserveOrder (l:ls) new = found ++ preserveOrder ls rest where - collect [] n = n - collect [_] n = n -- optimisation - collect (l:ls) n = found ++ collect ls rest - where (found, rest)=partition (l `dirContains`) n + (found, rest)=partition (l `dirContains`) new {- Runs an action that takes a list of FilePaths, and ensures that - its return list preserves order. diff --git a/Utility/Ssh.hs b/Utility/Ssh.hs index 4d17a47ba..a0e52507d 100644 --- a/Utility/Ssh.hs +++ b/Utility/Ssh.hs @@ -34,7 +34,7 @@ git_annex_shell :: Git.Repo -> String -> [CommandParam] -> Annex (Maybe (FilePat git_annex_shell r command params | not $ Git.repoIsUrl r = return $ Just (shellcmd, shellopts) | Git.repoIsSsh r = do - uuid <- getUUID r + uuid <- getRepoUUID r sshparams <- sshToRepo r [Param $ sshcmd uuid ] return $ Just ("ssh", sshparams) | otherwise = return Nothing |