summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-08-05 13:49:54 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-08-05 13:49:58 -0400
commita43686b9847c19efebd1f15519083436ac155a8e (patch)
tree98abed3386788da3002142a1053cdce09789c023 /Remote
parent0ad42412dbc981969e0847b498701e6b9ca6dd17 (diff)
Simplify setup process for a ssh remote.
Now it suffices to run git remote add, followed by git-annex sync. Now the remote is automatically initialized for use by git-annex, where before the git-annex branch had to manually be pushed before using git-annex sync. Note that this involved changes to git-annex-shell, so if the remote is using an old version, the manual push is still needed. Implementation required git-annex-shell be changed, so configlist can autoinit a repository even when no git-annex branch has been pushed yet. Unfortunate because we'll have to wait for it to get deployed to servers before being able to rely on this change in the documentation. Did consider making git-annex sync push the git-annex branch to repos that didn't have a uuid, but this seemed difficult to do without complicating it in messy ways. It would be cleaner to split a command out from configlist to handle the initialization. But this is difficult without sacrificing backwards compatability, for users of old git-annex versions which would not use the new command.
Diffstat (limited to 'Remote')
-rw-r--r--Remote/BitTorrent.hs4
-rw-r--r--Remote/Bup.hs2
-rw-r--r--Remote/Ddar.hs2
-rw-r--r--Remote/Directory.hs2
-rw-r--r--Remote/External.hs2
-rw-r--r--Remote/GCrypt.hs2
-rw-r--r--Remote/Git.hs25
-rw-r--r--Remote/Glacier.hs2
-rw-r--r--Remote/Hook.hs2
-rw-r--r--Remote/List.hs19
-rw-r--r--Remote/Rsync.hs2
-rw-r--r--Remote/S3.hs2
-rw-r--r--Remote/Tahoe.hs2
-rw-r--r--Remote/Web.hs4
-rw-r--r--Remote/WebDAV.hs2
15 files changed, 42 insertions, 32 deletions
diff --git a/Remote/BitTorrent.hs b/Remote/BitTorrent.hs
index a4ec11bf1..d3963a918 100644
--- a/Remote/BitTorrent.hs
+++ b/Remote/BitTorrent.hs
@@ -43,8 +43,8 @@ remote = RemoteType {
}
-- There is only one bittorrent remote, and it always exists.
-list :: Annex [Git.Repo]
-list = do
+list :: Bool -> Annex [Git.Repo]
+list _autoinit = do
r <- liftIO $ Git.Construct.remoteNamed "bittorrent" (pure Git.Construct.fromUnknown)
return [r]
diff --git a/Remote/Bup.hs b/Remote/Bup.hs
index 0c156345e..92ff7ab68 100644
--- a/Remote/Bup.hs
+++ b/Remote/Bup.hs
@@ -36,7 +36,7 @@ type BupRepo = String
remote :: RemoteType
remote = RemoteType {
typename = "bup",
- enumerate = findSpecialRemotes "buprepo",
+ enumerate = const (findSpecialRemotes "buprepo"),
generate = gen,
setup = bupSetup
}
diff --git a/Remote/Ddar.hs b/Remote/Ddar.hs
index a24960935..b616093a3 100644
--- a/Remote/Ddar.hs
+++ b/Remote/Ddar.hs
@@ -31,7 +31,7 @@ data DdarRepo = DdarRepo
remote :: RemoteType
remote = RemoteType {
typename = "ddar",
- enumerate = findSpecialRemotes "ddarrepo",
+ enumerate = const (findSpecialRemotes "ddarrepo"),
generate = gen,
setup = ddarSetup
}
diff --git a/Remote/Directory.hs b/Remote/Directory.hs
index c0bbcf544..ab4137d75 100644
--- a/Remote/Directory.hs
+++ b/Remote/Directory.hs
@@ -33,7 +33,7 @@ import Utility.Metered
remote :: RemoteType
remote = RemoteType {
typename = "directory",
- enumerate = findSpecialRemotes "directory",
+ enumerate = const (findSpecialRemotes "directory"),
generate = gen,
setup = directorySetup
}
diff --git a/Remote/External.hs b/Remote/External.hs
index d09e1f9b3..6c36d879a 100644
--- a/Remote/External.hs
+++ b/Remote/External.hs
@@ -34,7 +34,7 @@ import qualified Data.Map as M
remote :: RemoteType
remote = RemoteType {
typename = "external",
- enumerate = findSpecialRemotes "externaltype",
+ enumerate = const (findSpecialRemotes "externaltype"),
generate = gen,
setup = externalSetup
}
diff --git a/Remote/GCrypt.hs b/Remote/GCrypt.hs
index 8a1dcc41a..51dfed4f4 100644
--- a/Remote/GCrypt.hs
+++ b/Remote/GCrypt.hs
@@ -54,7 +54,7 @@ remote = RemoteType {
typename = "gcrypt",
-- Remote.Git takes care of enumerating gcrypt remotes too,
-- and will call our gen on them.
- enumerate = return [],
+ enumerate = const (return []),
generate = gen,
setup = gCryptSetup
}
diff --git a/Remote/Git.hs b/Remote/Git.hs
index 5ac79df6d..4505c14ff 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -67,11 +67,11 @@ remote = RemoteType {
setup = gitSetup
}
-list :: Annex [Git.Repo]
-list = do
+list :: Bool -> Annex [Git.Repo]
+list autoinit = do
c <- fromRepo Git.config
rs <- mapM (tweakurl c) =<< fromRepo Git.remotes
- mapM configRead rs
+ mapM (configRead autoinit) rs
where
annexurl n = "remote." ++ n ++ ".annexurl"
tweakurl c r = do
@@ -116,14 +116,14 @@ gitSetup (Just u) _ c = do
-
- Conversely, the config of an URL remote is only read when there is no
- cached UUID value. -}
-configRead :: Git.Repo -> Annex Git.Repo
-configRead r = do
+configRead :: Bool -> Git.Repo -> Annex Git.Repo
+configRead autoinit r = do
gc <- Annex.getRemoteGitConfig r
u <- getRepoUUID r
case (repoCheap r, remoteAnnexIgnore gc, u) of
(_, True, _) -> return r
- (True, _, _) -> tryGitConfigRead r
- (False, _, NoUUID) -> tryGitConfigRead r
+ (True, _, _) -> tryGitConfigRead autoinit r
+ (False, _, NoUUID) -> tryGitConfigRead autoinit r
_ -> return r
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote)
@@ -196,11 +196,12 @@ repoAvail r
{- Tries to read the config for a specified remote, updates state, and
- returns the updated repo. -}
-tryGitConfigRead :: Git.Repo -> Annex Git.Repo
-tryGitConfigRead r
+tryGitConfigRead :: Bool -> Git.Repo -> Annex Git.Repo
+tryGitConfigRead autoinit r
| haveconfig r = return r -- already read
| Git.repoIsSsh r = store $ do
- v <- Ssh.onRemote r (pipedconfig, return (Left $ error "configlist failed")) "configlist" [] []
+ liftIO $ print autoinit
+ v <- Ssh.onRemote r (pipedconfig, return (Left $ error "configlist failed")) "configlist" [] configlistfields
case v of
Right r'
| haveconfig r' -> return r'
@@ -302,6 +303,10 @@ tryGitConfigRead r
Annex.BranchState.disableUpdate
void $ tryNonAsync $ ensureInitialized
Annex.getState Annex.repo
+
+ configlistfields = if autoinit
+ then [(Fields.autoInit, "1")]
+ else []
{- Checks if a given remote has the content for a key in its annex. -}
inAnnex :: Remote -> Key -> Annex Bool
diff --git a/Remote/Glacier.hs b/Remote/Glacier.hs
index 75b264bac..98b7d6fad 100644
--- a/Remote/Glacier.hs
+++ b/Remote/Glacier.hs
@@ -31,7 +31,7 @@ type Archive = FilePath
remote :: RemoteType
remote = RemoteType {
typename = "glacier",
- enumerate = findSpecialRemotes "glacier",
+ enumerate = const (findSpecialRemotes "glacier"),
generate = gen,
setup = glacierSetup
}
diff --git a/Remote/Hook.hs b/Remote/Hook.hs
index 9abc4e303..259a44bcd 100644
--- a/Remote/Hook.hs
+++ b/Remote/Hook.hs
@@ -27,7 +27,7 @@ type HookName = String
remote :: RemoteType
remote = RemoteType {
typename = "hook",
- enumerate = findSpecialRemotes "hooktype",
+ enumerate = const (findSpecialRemotes "hooktype"),
generate = gen,
setup = hookSetup
}
diff --git a/Remote/List.hs b/Remote/List.hs
index 49b0a35f2..5472059bd 100644
--- a/Remote/List.hs
+++ b/Remote/List.hs
@@ -72,14 +72,19 @@ remoteList :: Annex [Remote]
remoteList = do
rs <- Annex.getState Annex.remotes
if null rs
- then do
- m <- readRemoteLog
- rs' <- concat <$> mapM (process m) remoteTypes
- Annex.changeState $ \s -> s { Annex.remotes = rs' }
- return rs'
+ then remoteList' False
else return rs
+
+remoteList' :: Bool -> Annex [Remote]
+remoteList' autoinit = do
+ m <- readRemoteLog
+ rs <- concat <$> mapM (process m) remoteTypes
+ Annex.changeState $ \s -> s { Annex.remotes = rs }
+ return rs
where
- process m t = enumerate t >>= mapM (remoteGen m t) >>= return . catMaybes
+ process m t = enumerate t autoinit
+ >>= mapM (remoteGen m t)
+ >>= return . catMaybes
{- Forces the remoteList to be re-generated, re-reading the git config. -}
remoteListRefresh :: Annex [Remote]
@@ -109,7 +114,7 @@ updateRemote remote = do
where
updaterepo r
| Git.repoIsLocal r || Git.repoIsLocalUnknown r =
- Remote.Git.configRead r
+ Remote.Git.configRead False r
| otherwise = return r
{- Checks if a remote is syncable using git. -}
diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs
index c610938a9..be9629b26 100644
--- a/Remote/Rsync.hs
+++ b/Remote/Rsync.hs
@@ -44,7 +44,7 @@ import qualified Data.Map as M
remote :: RemoteType
remote = RemoteType {
typename = "rsync",
- enumerate = findSpecialRemotes "rsyncurl",
+ enumerate = const (findSpecialRemotes "rsyncurl"),
generate = gen,
setup = rsyncSetup
}
diff --git a/Remote/S3.hs b/Remote/S3.hs
index 0e7606139..1290e784a 100644
--- a/Remote/S3.hs
+++ b/Remote/S3.hs
@@ -54,7 +54,7 @@ type BucketName = String
remote :: RemoteType
remote = RemoteType {
typename = "S3",
- enumerate = findSpecialRemotes "s3",
+ enumerate = const (findSpecialRemotes "s3"),
generate = gen,
setup = s3Setup
}
diff --git a/Remote/Tahoe.hs b/Remote/Tahoe.hs
index f2649fa4b..1357a0183 100644
--- a/Remote/Tahoe.hs
+++ b/Remote/Tahoe.hs
@@ -53,7 +53,7 @@ type Capability = String
remote :: RemoteType
remote = RemoteType {
typename = "tahoe",
- enumerate = findSpecialRemotes "tahoe",
+ enumerate = const (findSpecialRemotes "tahoe"),
generate = gen,
setup = tahoeSetup
}
diff --git a/Remote/Web.hs b/Remote/Web.hs
index 102972b02..9892f4c98 100644
--- a/Remote/Web.hs
+++ b/Remote/Web.hs
@@ -36,8 +36,8 @@ remote = RemoteType {
-- There is only one web remote, and it always exists.
-- (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 = do
+list :: Bool -> Annex [Git.Repo]
+list _autoinit = do
r <- liftIO $ Git.Construct.remoteNamed "web" (pure Git.Construct.fromUnknown)
return [r]
diff --git a/Remote/WebDAV.hs b/Remote/WebDAV.hs
index 3c414f003..6cc53964e 100644
--- a/Remote/WebDAV.hs
+++ b/Remote/WebDAV.hs
@@ -36,7 +36,7 @@ import Remote.WebDAV.DavLocation
remote :: RemoteType
remote = RemoteType {
typename = "webdav",
- enumerate = findSpecialRemotes "webdav",
+ enumerate = const (findSpecialRemotes "webdav"),
generate = gen,
setup = webdavSetup
}