From 8861e270bed218a4be41c38d3dfe7a01feb6ab8f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 22 Apr 2013 14:57:09 -0400 Subject: [PATCH] sync, assistant: Sync with remotes that have annex-ignore set This is so git remotes on servers without git-annex installed can be used to keep clients' git repos in sync. This is a behavior change, but since annex-sync can be set to disable syncing with a remote, I think it's acceptable. --- Assistant/DaemonStatus.hs | 9 +++++---- Assistant/Sync.hs | 4 +++- Assistant/Threads/MountWatcher.hs | 2 +- Assistant/Threads/NetWatcher.hs | 2 +- Assistant/WebApp/RepoList.hs | 2 +- Command/Sync.hs | 2 +- Remote.hs | 4 ++-- Remote/List.hs | 4 ---- debian/changelog | 3 +++ doc/git-annex.mdwn | 7 +++++-- 10 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Assistant/DaemonStatus.hs b/Assistant/DaemonStatus.hs index c966fc93a8..f94521117d 100644 --- a/Assistant/DaemonStatus.hs +++ b/Assistant/DaemonStatus.hs @@ -48,18 +48,19 @@ modifyDaemonStatus a = do calcSyncRemotes :: Annex (DaemonStatus -> DaemonStatus) calcSyncRemotes = do rs <- filter (remoteAnnexSync . Remote.gitconfig) . - concat . Remote.byCost <$> Remote.enabledRemoteList + concat . Remote.byCost <$> Remote.remoteList alive <- trustExclude DeadTrusted (map Remote.uuid rs) let good r = Remote.uuid r `elem` alive let syncable = filter good rs - let nonxmpp = filter (not . isXMPPRemote) syncable + let syncdata = filter (not . remoteAnnexIgnore . Remote.gitconfig) $ + filter (not . isXMPPRemote) syncable return $ \dstatus -> dstatus { syncRemotes = syncable , syncGitRemotes = filter (not . Remote.specialRemote) syncable - , syncDataRemotes = nonxmpp - , syncingToCloudRemote = any iscloud nonxmpp + , syncDataRemotes = syncdata + , syncingToCloudRemote = any iscloud syncdata } where iscloud r = not (Remote.readonly r) && Remote.globallyAvailable r diff --git a/Assistant/Sync.hs b/Assistant/Sync.hs index 78fdbab1a8..727749c4ff 100644 --- a/Assistant/Sync.hs +++ b/Assistant/Sync.hs @@ -68,7 +68,9 @@ reconnectRemotes notifypushes rs = void $ do go = do (failed, diverged) <- sync =<< liftAnnex (inRepo Git.Branch.current) - addScanRemotes diverged nonxmppremotes + addScanRemotes diverged $ + filter (not . remoteAnnexIgnore . Remote.gitconfig) + nonxmppremotes return failed {- Updates the local sync branch, then pushes it to all remotes, in diff --git a/Assistant/Threads/MountWatcher.hs b/Assistant/Threads/MountWatcher.hs index c03eac4f14..143ae9cee4 100644 --- a/Assistant/Threads/MountWatcher.hs +++ b/Assistant/Threads/MountWatcher.hs @@ -157,7 +157,7 @@ handleMount :: FilePath -> Assistant () handleMount dir = do debug ["detected mount of", dir] rs <- filter (Git.repoIsLocal . Remote.repo) <$> remotesUnder dir - reconnectRemotes True $ filter (not . remoteAnnexIgnore . Remote.gitconfig) rs + reconnectRemotes True rs {- Finds remotes located underneath the mount point. - diff --git a/Assistant/Threads/NetWatcher.hs b/Assistant/Threads/NetWatcher.hs index 6d15d414eb..6ac7203b0f 100644 --- a/Assistant/Threads/NetWatcher.hs +++ b/Assistant/Threads/NetWatcher.hs @@ -128,4 +128,4 @@ handleConnection = reconnectRemotes True =<< networkRemotes {- Finds network remotes. -} networkRemotes :: Assistant [Remote] networkRemotes = liftAnnex $ - filter (isNothing . Remote.localpath) <$> enabledRemoteList + filter (isNothing . Remote.localpath) <$> remoteList diff --git a/Assistant/WebApp/RepoList.hs b/Assistant/WebApp/RepoList.hs index a14cd5f34a..6b35fdf98a 100644 --- a/Assistant/WebApp/RepoList.hs +++ b/Assistant/WebApp/RepoList.hs @@ -133,7 +133,7 @@ repoList reposelector unwanted <- S.fromList <$> filterM inUnwantedGroup (S.toList syncing) rs <- filter selectedrepo . concat . Remote.byCost - <$> Remote.enabledRemoteList + <$> Remote.remoteList let us = map Remote.uuid rs let maker u | u `S.member` unwanted = mkUnwantedRepoActions u diff --git a/Command/Sync.hs b/Command/Sync.hs index a25f6a6021..0a8ed78276 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -73,7 +73,7 @@ syncRemotes rs = ifM (Annex.getState Annex.fast) ( nub <$> pickfast , wanted ) return l available = filter (not . Remote.specialRemote) . filter (remoteAnnexSync . Types.Remote.gitconfig) - <$> Remote.enabledRemoteList + <$> Remote.remoteList good = filterM $ Remote.Git.repoAvail . Types.Remote.repo fastest = fromMaybe [] . headMaybe . Remote.byCost diff --git a/Remote.hs b/Remote.hs index 27e69a5a0e..e722542a81 100644 --- a/Remote.hs +++ b/Remote.hs @@ -19,7 +19,6 @@ module Remote ( remoteTypes, remoteList, - enabledRemoteList, specialRemote, remoteMap, uuidDescriptions, @@ -211,7 +210,8 @@ keyPossibilities' key trusted = do let validtrusteduuids = validuuids `intersect` trusted -- remotes that match uuids that have the key - allremotes <- enabledRemoteList + allremotes <- filter (not . remoteAnnexIgnore . gitconfig) + <$> remoteList let validremotes = remotesWithUUID allremotes validuuids return (sortBy (comparing cost) validremotes, validtrusteduuids) diff --git a/Remote/List.hs b/Remote/List.hs index 1cfbab8720..0651d83aac 100644 --- a/Remote/List.hs +++ b/Remote/List.hs @@ -98,10 +98,6 @@ updateRemote remote = do Remote.Git.configRead r | otherwise = return r -{- All remotes that are not ignored. -} -enabledRemoteList :: Annex [Remote] -enabledRemoteList = filter (not . remoteAnnexIgnore . gitconfig) <$> remoteList - {- Checks if a remote is a special remote -} specialRemote :: Remote -> Bool specialRemote r = remotetype r /= Remote.Git.remote diff --git a/debian/changelog b/debian/changelog index e11d5ab88c..86500c6f8a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,9 @@ git-annex (4.20130418) UNRELEASED; urgency=low * webapp: Don't default to making repository in cwd when started from within a directory containing a git-annex file (eg, standalone tarball directory). + * sync, assistant: Sync with remotes that have annex-ignore set, + so that git remotes on servers without git-annex installed can be used + to keep clients' git repos in sync. -- Joey Hess Thu, 18 Apr 2013 16:22:48 -0400 diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index b9badce9b5..1c2247654f 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -904,14 +904,17 @@ Here are all the supported configuration settings. * `remote..annex-ignore` If set to `true`, prevents git-annex - from using this remote by default. (You can still request it be used - by the --from and --to options.) + from storing file contents on this remote by default. + (You can still request it be used by the --from and --to options.) This is, for example, useful if the remote is located somewhere without git-annex-shell. (For example, if it's on GitHub). Or, it could be used if the network connection between two repositories is too slow to be used normally. + This does not prevent git-annex sync (or the git-annex assistant) from + syncing the git repository to the remote. + * `remote..annex-sync` If set to `false`, prevents git-annex sync (and the git-annex assistant)