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.
This commit is contained in:
Joey Hess 2013-04-22 14:57:09 -04:00
parent b9341fd4c0
commit 8861e270be
10 changed files with 22 additions and 17 deletions

View file

@ -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

View file

@ -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

View file

@ -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.
-

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

3
debian/changelog vendored
View file

@ -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 <joeyh@debian.org> Thu, 18 Apr 2013 16:22:48 -0400

View file

@ -904,14 +904,17 @@ Here are all the supported configuration settings.
* `remote.<name>.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.<name>.annex-sync`
If set to `false`, prevents git-annex sync (and the git-annex assistant)