sync: Started transition to --content being enabled by default

When used without --content or --no-content, warn about the upcoming
transition, and suggest using one of the options, or setting
annex.synccontent.

Sponsored-by: Brett Eisenberg on Patreon
This commit is contained in:
Joey Hess 2023-05-17 13:23:42 -04:00
parent af6b73a7e6
commit f93a7fce1d
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 44 additions and 13 deletions

View file

@ -57,8 +57,12 @@ git-annex (10.20230408) UNRELEASED; urgency=medium
--content. With --no-pull, avoid downloading content, and with --content. With --no-pull, avoid downloading content, and with
--no-push avoid uploading content. This was done before, but --no-push avoid uploading content. This was done before, but
inconsistently. inconsistently.
* sync: Added -g as a short option for --no-content.
* uninit: Avoid buffering the names of all annexed files in memory. * uninit: Avoid buffering the names of all annexed files in memory.
* sync: Started a transition to --content being enabled by default.
When used without --content or --no-content, warn about the upcoming
transition, and suggest using one of the options, or setting
annex.synccontent.
* sync: Added -g as a short option for --no-content.
-- Joey Hess <id@joeyh.name> Sat, 08 Apr 2023 13:57:18 -0400 -- Joey Hess <id@joeyh.name> Sat, 08 Apr 2023 13:57:18 -0400

View file

@ -106,8 +106,8 @@ data SyncOptions = SyncOptions
, messageOption :: Maybe String , messageOption :: Maybe String
, pullOption :: Bool , pullOption :: Bool
, pushOption :: Bool , pushOption :: Bool
, contentOption :: Bool , contentOption :: Maybe Bool
, noContentOption :: Bool , noContentOption :: Maybe Bool
, contentOfOption :: [FilePath] , contentOfOption :: [FilePath]
, cleanupOption :: Bool , cleanupOption :: Bool
, keyOptions :: Maybe KeyOptions , keyOptions :: Maybe KeyOptions
@ -126,8 +126,8 @@ instance Default SyncOptions where
, messageOption = Nothing , messageOption = Nothing
, pullOption = False , pullOption = False
, pushOption = False , pushOption = False
, contentOption = False , contentOption = Just False
, noContentOption = False , noContentOption = Just False
, contentOfOption = [] , contentOfOption = []
, cleanupOption = False , cleanupOption = False
, keyOptions = Nothing , keyOptions = Nothing
@ -175,15 +175,15 @@ optParser mode desc = SyncOptions
) )
PullMode -> pure False PullMode -> pure False
PushMode -> pure True PushMode -> pure True
<*> switch <*> optional (flag' True
( long "content" ( long "content"
<> help "transfer annexed file contents" <> help "transfer annexed file contents"
) ))
<*> switch <*> optional (flag' True
( long "no-content" ( long "no-content"
<> short 'g' <> short 'g'
<> help "do not transfer annexed file contents" <> help "do not transfer annexed file contents"
) ))
<*> many (strOption <*> many (strOption
( long "content-of" ( long "content-of"
<> short 'C' <> short 'C'
@ -236,9 +236,11 @@ instance DeferredParseClass SyncOptions where
seek :: SyncOptions -> CommandSeek seek :: SyncOptions -> CommandSeek
seek o = do seek o = do
warnSyncContentTransition o
prepMerge prepMerge
startConcurrency transferStages (seek' o) startConcurrency transferStages (seek' o)
seek' :: SyncOptions -> CommandSeek seek' :: SyncOptions -> CommandSeek
seek' o = do seek' o = do
let withbranch a = a =<< getCurrentBranch let withbranch a = a =<< getCurrentBranch
@ -1038,11 +1040,11 @@ cleanupRemote remote (Just b, _) =
shouldSyncContent :: SyncOptions -> Annex Bool shouldSyncContent :: SyncOptions -> Annex Bool
shouldSyncContent o shouldSyncContent o
| noContentOption o = pure False | fromMaybe False (noContentOption o) = pure False
-- For git-annex pull and git-annex push, -- For git-annex pull and git-annex push,
-- annex.syncontent defaults to True unless set -- annex.syncontent defaults to True unless set
| operationMode o /= SyncMode = annexsynccontent True | operationMode o /= SyncMode = annexsynccontent True
| contentOption o || not (null (contentOfOption o)) = pure True | fromMaybe False (contentOption o) || not (null (contentOfOption o)) = pure True
-- For git-annex sync, -- For git-annex sync,
-- annex.syncontent defaults to False unless set -- annex.syncontent defaults to False unless set
| otherwise = annexsynccontent False <||> onlyAnnex o | otherwise = annexsynccontent False <||> onlyAnnex o
@ -1053,6 +1055,24 @@ shouldSyncContent o
HasGitConfig (Just c) -> return c HasGitConfig (Just c) -> return c
_ -> return d _ -> return d
-- Transition started May 2023, should wait until that has been in a Debian
-- stable release before completing the transition.
warnSyncContentTransition :: SyncOptions -> Annex ()
warnSyncContentTransition o
| operationMode o /= SyncMode = noop
| isJust (noContentOption o) || isJust (contentOption o) = noop
| not (null (contentOfOption o)) = noop
| otherwise = getGitConfigVal' annexSyncContent >>= \case
HasGlobalConfig (Just _) -> noop
HasGitConfig (Just _) -> noop
_ -> showwarning
where
showwarning = earlyWarning $
"git-annex sync will change default behavior to operate on"
<> " --content in a future version of git-annex. Recommend"
<> " you explicitly use --no-content (or -g) to prepare for"
<> " that change. (Or you can configure annex.synccontent)"
notOnlyAnnex :: SyncOptions -> Annex Bool notOnlyAnnex :: SyncOptions -> Annex Bool
notOnlyAnnex o = not <$> onlyAnnex o notOnlyAnnex o = not <$> onlyAnnex o

View file

@ -15,7 +15,7 @@ previously been added to the repository. Then it does the equivilant of
[[git-annex-pull]](1) followed by [[git-annex-push]](1). [[git-annex-pull]](1) followed by [[git-annex-push]](1).
However, unlike those commands, this command does not transfer annexed However, unlike those commands, this command does not transfer annexed
content by default. This may change in a future version of git-annex. content by default. That will change in a future version of git-annex,
# OPTIONS # OPTIONS

View file

@ -10,3 +10,10 @@ version.
after upgrading to the repo version that enables this. Depending on the after upgrading to the repo version that enables this. Depending on the
timing of v11, this may need to be put in a v12 upgrade that is delayed timing of v11, this may need to be put in a v12 upgrade that is delayed
some amount of time (eg 1 year) after v11. some amount of time (eg 1 year) after v11.
* Finish the transition of git-annex sync defaulting to --content.
A warning was added in May 2023 when it's run in a way that will change
behavior. It would be good to wait until all git-annex users have
gotten the version with the warning, and used it for a while,
before finishing the transition. This does not need to be tied to a
repository version change really, but it would be reasonable to do so.