summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-13 15:05:07 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-13 15:06:49 -0400
commit13fff71f2019ae098c3f8532ac2734cb1ab11498 (patch)
treef37714c4089df4afac9bf9724c80757e5fd29e6f /Remote
parent46588674b081cd4ea5820680d8fc15c81ed175ad (diff)
split out three modules from Git
Constructors and configuration make sense in separate modules. A separate Git.Types is needed to avoid cycles.
Diffstat (limited to 'Remote')
-rw-r--r--Remote/Bup.hs16
-rw-r--r--Remote/Git.hs8
-rw-r--r--Remote/Helper/Special.hs3
-rw-r--r--Remote/Web.hs3
4 files changed, 18 insertions, 12 deletions
diff --git a/Remote/Bup.hs b/Remote/Bup.hs
index e705bbb34..4d63d88e1 100644
--- a/Remote/Bup.hs
+++ b/Remote/Bup.hs
@@ -15,6 +15,8 @@ import System.Process
import Common.Annex
import Types.Remote
import qualified Git
+import qualified Git.Config
+import qualified Git.Construct
import Config
import Annex.Ssh
import Remote.Helper.Special
@@ -163,8 +165,8 @@ storeBupUUID u buprepo = do
[Params $ "config annex.uuid " ++ v]
>>! error "ssh failed"
else liftIO $ do
- r' <- Git.configRead r
- let olduuid = Git.configGet "annex.uuid" "" r'
+ r' <- Git.Config.read r
+ let olduuid = Git.Config.get "annex.uuid" "" r'
when (olduuid == "") $
Git.run "config"
[Param "annex.uuid", Param v] r'
@@ -192,9 +194,9 @@ getBupUUID :: Git.Repo -> UUID -> Annex (UUID, Git.Repo)
getBupUUID r u
| Git.repoIsUrl r = return (u, r)
| otherwise = liftIO $ do
- ret <- try $ Git.configRead r
+ ret <- try $ Git.Config.read r
case ret of
- Right r' -> return (toUUID $ Git.configGet "annex.uuid" "" r', r')
+ Right r' -> return (toUUID $ Git.Config.get "annex.uuid" "" r', r')
Left _ -> return (NoUUID, r)
{- Converts a bup remote path spec into a Git.Repo. There are some
@@ -203,13 +205,13 @@ bup2GitRemote :: BupRepo -> IO Git.Repo
bup2GitRemote "" = do
-- bup -r "" operates on ~/.bup
h <- myHomeDir
- Git.repoFromAbsPath $ h </> ".bup"
+ Git.Construct.fromAbsPath $ h </> ".bup"
bup2GitRemote r
| bupLocal r =
if head r == '/'
- then Git.repoFromAbsPath r
+ then Git.Construct.fromAbsPath r
else error "please specify an absolute path"
- | otherwise = Git.repoFromUrl $ "ssh://" ++ host ++ slash dir
+ | otherwise = Git.Construct.fromUrl $ "ssh://" ++ host ++ slash dir
where
bits = split ":" r
host = head bits
diff --git a/Remote/Git.hs b/Remote/Git.hs
index 2f9288e1b..9d80f4c1c 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -16,6 +16,8 @@ import Utility.RsyncFile
import Annex.Ssh
import Types.Remote
import qualified Git
+import qualified Git.Config
+import qualified Git.Construct
import qualified Annex
import Annex.UUID
import qualified Annex.Content
@@ -44,7 +46,7 @@ list = do
case M.lookup (annexurl n) c of
Nothing -> return r
Just url -> Git.repoRemoteNameSet n <$>
- inRepo (Git.genRemote url)
+ inRepo (Git.Construct.fromRemoteLocation url)
gen :: Git.Repo -> UUID -> Maybe RemoteConfig -> Annex (Remote Annex)
gen r u _ = do
@@ -100,7 +102,7 @@ tryGitConfigRead r
pipedconfig cmd params = safely $
pOpen ReadFromPipe cmd (toCommand params) $
- Git.hConfigRead r
+ Git.Config.hRead r
geturlconfig = do
s <- Url.get (Git.repoLocation r ++ "/config")
@@ -108,7 +110,7 @@ tryGitConfigRead r
hPutStr h s
hClose h
pOpen ReadFromPipe "git" ["config", "--list", "--file", tmpfile] $
- Git.hConfigRead r
+ Git.Config.hRead r
store a = do
r' <- a
diff --git a/Remote/Helper/Special.hs b/Remote/Helper/Special.hs
index 77478eb1d..72c4842d8 100644
--- a/Remote/Helper/Special.hs
+++ b/Remote/Helper/Special.hs
@@ -12,6 +12,7 @@ import qualified Data.Map as M
import Common.Annex
import Types.Remote
import qualified Git
+import qualified Git.Construct
{- Special remotes don't have a configured url, so Git.Repo does not
- automatically generate remotes for them. This looks for a different
@@ -23,7 +24,7 @@ findSpecialRemotes s = do
return $ map construct $ remotepairs m
where
remotepairs = M.toList . M.filterWithKey match
- construct (k,_) = Git.repoRemoteNameFromKey k Git.repoFromUnknown
+ construct (k,_) = Git.repoRemoteNameFromKey k Git.Construct.fromUnknown
match k _ = startswith "remote." k && endswith (".annex-"++s) k
{- Sets up configuration for a special remote in .git/config. -}
diff --git a/Remote/Web.hs b/Remote/Web.hs
index d5acd7d86..c4e9f8bd6 100644
--- a/Remote/Web.hs
+++ b/Remote/Web.hs
@@ -10,6 +10,7 @@ module Remote.Web (remote) where
import Common.Annex
import Types.Remote
import qualified Git
+import qualified Git.Construct
import Config
import Logs.Web
import qualified Utility.Url as Url
@@ -26,7 +27,7 @@ remote = RemoteType {
-- (If the web should cease to exist, remove this module and redistribute
-- a new release to the survivors by carrier pigeon.)
list :: Annex [Git.Repo]
-list = return [Git.repoRemoteNameSet "web" Git.repoFromUnknown]
+list = return [Git.repoRemoteNameSet "web" Git.Construct.fromUnknown]
gen :: Git.Repo -> UUID -> Maybe RemoteConfig -> Annex (Remote Annex)
gen r _ _ =