--no-push and remote.name.annex-push prevent exporting trees to special remotes

Users may want sync to only export, or only import and this is broadly
analagous to push and pull, so it makes sense to use the same
configuration for it.
This commit is contained in:
Joey Hess 2019-03-09 13:21:49 -04:00
parent d9ee048d85
commit 633021e135
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 21 additions and 12 deletions

View file

@ -64,7 +64,7 @@ exportToRemotes rs = do
forM rs $ \r -> do forM rs $ \r -> do
Annex.changeState $ \st -> st { Annex.errcounter = 0 } Annex.changeState $ \st -> st { Annex.errcounter = 0 }
start <- liftIO getCurrentTime start <- liftIO getCurrentTime
void $ Command.Sync.seekExportContent rs void $ Command.Sync.seekExportContent Nothing rs
=<< getCurrentBranch =<< getCurrentBranch
-- Look at command error counter to see if the export -- Look at command error counter to see if the export
-- didn't work. -- didn't work.

View file

@ -11,6 +11,8 @@ git-annex (7.20190220) UNRELEASED; urgency=medium
themselves. themselves.
* Remote tracking branches are updated when importing and exporting to * Remote tracking branches are updated when importing and exporting to
special remotes, in ways analagous to how git fetch and git push do. special remotes, in ways analagous to how git fetch and git push do.
* sync, assistant: --no-push and remote.name.annex-push prevent exporting
trees to special remotes.
* Fix storage of metadata values containing newlines. * Fix storage of metadata values containing newlines.
(Reversion introduced in version 7.20190122.) (Reversion introduced in version 7.20190122.)
* Sped up git-annex export in repositories with lots of keys. * Sped up git-annex export in repositories with lots of keys.

View file

@ -49,6 +49,7 @@ import Annex.Content
import Command.Get (getKey') import Command.Get (getKey')
import qualified Command.Move import qualified Command.Move
import qualified Command.Export import qualified Command.Export
import qualified Command.Import
import Annex.Drop import Annex.Drop
import Annex.UUID import Annex.UUID
import Logs.UUID import Logs.UUID
@ -191,8 +192,10 @@ seek o = allowConcurrentOutput $ do
-- Send content to any exports first, in -- Send content to any exports first, in
-- case that lets content be dropped from -- case that lets content be dropped from
-- other repositories. -- other repositories.
exportedcontent <- withbranch $ seekExportContent exportremotes exportedcontent <- withbranch $
syncedcontent <- withbranch $ seekSyncContent o dataremotes seekExportContent (Just o) exportremotes
syncedcontent <- withbranch $
seekSyncContent o dataremotes
-- Transferring content can take a while, -- Transferring content can take a while,
-- and other changes can be pushed to the -- and other changes can be pushed to the
-- git-annex branch on the remotes in the -- git-annex branch on the remotes in the
@ -687,13 +690,16 @@ syncFile ebloom rs af k = onlyActionOn' k $ do
- -
- Returns True if any file transfers were made. - Returns True if any file transfers were made.
-} -}
seekExportContent :: [Remote] -> CurrBranch -> Annex Bool seekExportContent :: Maybe SyncOptions -> [Remote] -> CurrBranch -> Annex Bool
seekExportContent rs (currbranch, _) = or <$> forM rs go seekExportContent o rs (currbranch, _) = or <$> forM rs go
where where
go r = bracket go r
(Export.openDb (Remote.uuid r)) | not (maybe True pullOption o) = return False
Export.closeDb | not (remoteAnnexPush (Remote.gitconfig r)) = return False
(\db -> Export.writeLockDbWhile db (go' r db)) | otherwise = bracket
(Export.openDb (Remote.uuid r))
Export.closeDb
(\db -> Export.writeLockDbWhile db (go' r db))
go' r db = do go' r db = do
(exported, mtbcommitsha) <- case remoteAnnexTrackingBranch (Remote.gitconfig r) of (exported, mtbcommitsha) <- case remoteAnnexTrackingBranch (Remote.gitconfig r) of
Nothing -> nontracking r Nothing -> nontracking r

View file

@ -51,7 +51,8 @@ by running "git annex sync" on the remote.
* `--pull`, `--no-pull` * `--pull`, `--no-pull`
By default, git pulls from remotes. Use --no-pull to disable all pulling. By default, git pulls from remotes and imports from some special remotes.
Use --no-pull to disable all pulling.
When `remote.<name>.annex-pull` or `remote.<name>.annex-sync` When `remote.<name>.annex-pull` or `remote.<name>.annex-sync`
are set to false, pulling is disabled for those remotes, and using are set to false, pulling is disabled for those remotes, and using
@ -59,8 +60,8 @@ by running "git annex sync" on the remote.
* `--push`, `--no-push` * `--push`, `--no-push`
By default, git pushes changes to remotes. By default, git pushes changes to remotes and exports to some
Use --no-push to disable all pushing. special remotes. Use --no-push to disable all pushing.
When `remote.<name>.annex-push` or `remote.<name>.annex-sync` are When `remote.<name>.annex-push` or `remote.<name>.annex-sync` are
set to false, or `remote.<name>.annex-readonly` is set to true, set to false, or `remote.<name>.annex-readonly` is set to true,