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:
parent
b9341fd4c0
commit
8861e270be
10 changed files with 22 additions and 17 deletions
|
@ -48,18 +48,19 @@ modifyDaemonStatus a = do
|
||||||
calcSyncRemotes :: Annex (DaemonStatus -> DaemonStatus)
|
calcSyncRemotes :: Annex (DaemonStatus -> DaemonStatus)
|
||||||
calcSyncRemotes = do
|
calcSyncRemotes = do
|
||||||
rs <- filter (remoteAnnexSync . Remote.gitconfig) .
|
rs <- filter (remoteAnnexSync . Remote.gitconfig) .
|
||||||
concat . Remote.byCost <$> Remote.enabledRemoteList
|
concat . Remote.byCost <$> Remote.remoteList
|
||||||
alive <- trustExclude DeadTrusted (map Remote.uuid rs)
|
alive <- trustExclude DeadTrusted (map Remote.uuid rs)
|
||||||
let good r = Remote.uuid r `elem` alive
|
let good r = Remote.uuid r `elem` alive
|
||||||
let syncable = filter good rs
|
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
|
return $ \dstatus -> dstatus
|
||||||
{ syncRemotes = syncable
|
{ syncRemotes = syncable
|
||||||
, syncGitRemotes =
|
, syncGitRemotes =
|
||||||
filter (not . Remote.specialRemote) syncable
|
filter (not . Remote.specialRemote) syncable
|
||||||
, syncDataRemotes = nonxmpp
|
, syncDataRemotes = syncdata
|
||||||
, syncingToCloudRemote = any iscloud nonxmpp
|
, syncingToCloudRemote = any iscloud syncdata
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
iscloud r = not (Remote.readonly r) && Remote.globallyAvailable r
|
iscloud r = not (Remote.readonly r) && Remote.globallyAvailable r
|
||||||
|
|
|
@ -68,7 +68,9 @@ reconnectRemotes notifypushes rs = void $ do
|
||||||
go = do
|
go = do
|
||||||
(failed, diverged) <- sync
|
(failed, diverged) <- sync
|
||||||
=<< liftAnnex (inRepo Git.Branch.current)
|
=<< liftAnnex (inRepo Git.Branch.current)
|
||||||
addScanRemotes diverged nonxmppremotes
|
addScanRemotes diverged $
|
||||||
|
filter (not . remoteAnnexIgnore . Remote.gitconfig)
|
||||||
|
nonxmppremotes
|
||||||
return failed
|
return failed
|
||||||
|
|
||||||
{- Updates the local sync branch, then pushes it to all remotes, in
|
{- Updates the local sync branch, then pushes it to all remotes, in
|
||||||
|
|
|
@ -157,7 +157,7 @@ handleMount :: FilePath -> Assistant ()
|
||||||
handleMount dir = do
|
handleMount dir = do
|
||||||
debug ["detected mount of", dir]
|
debug ["detected mount of", dir]
|
||||||
rs <- filter (Git.repoIsLocal . Remote.repo) <$> remotesUnder 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.
|
{- Finds remotes located underneath the mount point.
|
||||||
-
|
-
|
||||||
|
|
|
@ -128,4 +128,4 @@ handleConnection = reconnectRemotes True =<< networkRemotes
|
||||||
{- Finds network remotes. -}
|
{- Finds network remotes. -}
|
||||||
networkRemotes :: Assistant [Remote]
|
networkRemotes :: Assistant [Remote]
|
||||||
networkRemotes = liftAnnex $
|
networkRemotes = liftAnnex $
|
||||||
filter (isNothing . Remote.localpath) <$> enabledRemoteList
|
filter (isNothing . Remote.localpath) <$> remoteList
|
||||||
|
|
|
@ -133,7 +133,7 @@ repoList reposelector
|
||||||
unwanted <- S.fromList
|
unwanted <- S.fromList
|
||||||
<$> filterM inUnwantedGroup (S.toList syncing)
|
<$> filterM inUnwantedGroup (S.toList syncing)
|
||||||
rs <- filter selectedrepo . concat . Remote.byCost
|
rs <- filter selectedrepo . concat . Remote.byCost
|
||||||
<$> Remote.enabledRemoteList
|
<$> Remote.remoteList
|
||||||
let us = map Remote.uuid rs
|
let us = map Remote.uuid rs
|
||||||
let maker u
|
let maker u
|
||||||
| u `S.member` unwanted = mkUnwantedRepoActions u
|
| u `S.member` unwanted = mkUnwantedRepoActions u
|
||||||
|
|
|
@ -73,7 +73,7 @@ syncRemotes rs = ifM (Annex.getState Annex.fast) ( nub <$> pickfast , wanted )
|
||||||
return l
|
return l
|
||||||
available = filter (not . Remote.specialRemote)
|
available = filter (not . Remote.specialRemote)
|
||||||
. filter (remoteAnnexSync . Types.Remote.gitconfig)
|
. filter (remoteAnnexSync . Types.Remote.gitconfig)
|
||||||
<$> Remote.enabledRemoteList
|
<$> Remote.remoteList
|
||||||
good = filterM $ Remote.Git.repoAvail . Types.Remote.repo
|
good = filterM $ Remote.Git.repoAvail . Types.Remote.repo
|
||||||
fastest = fromMaybe [] . headMaybe . Remote.byCost
|
fastest = fromMaybe [] . headMaybe . Remote.byCost
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ module Remote (
|
||||||
|
|
||||||
remoteTypes,
|
remoteTypes,
|
||||||
remoteList,
|
remoteList,
|
||||||
enabledRemoteList,
|
|
||||||
specialRemote,
|
specialRemote,
|
||||||
remoteMap,
|
remoteMap,
|
||||||
uuidDescriptions,
|
uuidDescriptions,
|
||||||
|
@ -211,7 +210,8 @@ keyPossibilities' key trusted = do
|
||||||
let validtrusteduuids = validuuids `intersect` trusted
|
let validtrusteduuids = validuuids `intersect` trusted
|
||||||
|
|
||||||
-- remotes that match uuids that have the key
|
-- remotes that match uuids that have the key
|
||||||
allremotes <- enabledRemoteList
|
allremotes <- filter (not . remoteAnnexIgnore . gitconfig)
|
||||||
|
<$> remoteList
|
||||||
let validremotes = remotesWithUUID allremotes validuuids
|
let validremotes = remotesWithUUID allremotes validuuids
|
||||||
|
|
||||||
return (sortBy (comparing cost) validremotes, validtrusteduuids)
|
return (sortBy (comparing cost) validremotes, validtrusteduuids)
|
||||||
|
|
|
@ -98,10 +98,6 @@ updateRemote remote = do
|
||||||
Remote.Git.configRead r
|
Remote.Git.configRead r
|
||||||
| otherwise = return 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 -}
|
{- Checks if a remote is a special remote -}
|
||||||
specialRemote :: Remote -> Bool
|
specialRemote :: Remote -> Bool
|
||||||
specialRemote r = remotetype r /= Remote.Git.remote
|
specialRemote r = remotetype r /= Remote.Git.remote
|
||||||
|
|
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -6,6 +6,9 @@ git-annex (4.20130418) UNRELEASED; urgency=low
|
||||||
* webapp: Don't default to making repository in cwd when started
|
* webapp: Don't default to making repository in cwd when started
|
||||||
from within a directory containing a git-annex file (eg, standalone
|
from within a directory containing a git-annex file (eg, standalone
|
||||||
tarball directory).
|
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
|
-- Joey Hess <joeyh@debian.org> Thu, 18 Apr 2013 16:22:48 -0400
|
||||||
|
|
||||||
|
|
|
@ -904,14 +904,17 @@ Here are all the supported configuration settings.
|
||||||
* `remote.<name>.annex-ignore`
|
* `remote.<name>.annex-ignore`
|
||||||
|
|
||||||
If set to `true`, prevents git-annex
|
If set to `true`, prevents git-annex
|
||||||
from using this remote by default. (You can still request it be used
|
from storing file contents on this remote by default.
|
||||||
by the --from and --to options.)
|
(You can still request it be used by the --from and --to options.)
|
||||||
|
|
||||||
This is, for example, useful if the remote is located somewhere
|
This is, for example, useful if the remote is located somewhere
|
||||||
without git-annex-shell. (For example, if it's on GitHub).
|
without git-annex-shell. (For example, if it's on GitHub).
|
||||||
Or, it could be used if the network connection between two
|
Or, it could be used if the network connection between two
|
||||||
repositories is too slow to be used normally.
|
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`
|
* `remote.<name>.annex-sync`
|
||||||
|
|
||||||
If set to `false`, prevents git-annex sync (and the git-annex assistant)
|
If set to `false`, prevents git-annex sync (and the git-annex assistant)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue