From d467c70ef75c2af7c5a6c5ef5c5d978bc916c455 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 14 Aug 2023 13:51:35 -0400 Subject: [PATCH] change sync content transition plan and fine tune warning Only display warning when git-annex sync (without --content or --no-content) is used with repositories that have preferred content configured. Sponsored-by: Leon Schuermann on Patreon --- Command/Sync.hs | 26 +++++++++++-------- ...ing_sync_to_include_content_breaks_UX.mdwn | 2 ++ ..._bdc211b026d3b05de127f6ed5a3d19b0._comment | 21 +++++++++++++++ doc/git-annex-sync.mdwn | 1 + doc/todo/finish_sync_content_transition.mdwn | 14 ++++++++++ doc/todo/v11_changes.mdwn | 7 ----- 6 files changed, 53 insertions(+), 18 deletions(-) create mode 100644 doc/bugs/Changing_sync_to_include_content_breaks_UX/comment_19_bdc211b026d3b05de127f6ed5a3d19b0._comment create mode 100644 doc/todo/finish_sync_content_transition.mdwn diff --git a/Command/Sync.hs b/Command/Sync.hs index 7e5800b63a..30baed705f 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -256,8 +256,6 @@ instance DeferredParseClass SyncOptions where seek :: SyncOptions -> CommandSeek seek o = do - warnSyncContentTransition o - prepMerge seek' o @@ -267,6 +265,7 @@ seek' o = startConcurrency transferStages $ do let withbranch a = a =<< getCurrentBranch remotes <- syncRemotes (syncWith o) + warnSyncContentTransition o remotes -- Remotes that are git repositories, not (necesarily) special remotes. let gitremotes = filter (Remote.gitSyncableRemoteType . Remote.remotetype) remotes -- Remotes that contain annex object content. @@ -1102,23 +1101,28 @@ shouldSyncContent o HasGitConfig (Just c) -> return c _ -> 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 +-- See doc/todo/finish_sync_content_transition.mdwn +warnSyncContentTransition :: SyncOptions -> [Remote] -> Annex () +warnSyncContentTransition o remotes | 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 + _ -> do + m <- preferredContentMap + hereu <- getUUID + when (any (`M.member` m) (hereu:map Remote.uuid remotes)) $ + 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)" + "git-annex sync will change default behavior in the future to" + <> " send content to repositories that have" + <> " preferred content configured. If you do not want this to" + <> " send any content, use --no-content (or -g)" + <> " to prepare for that change." + <> " (Or you can configure annex.synccontent)" notOnlyAnnex :: SyncOptions -> Annex Bool notOnlyAnnex o = not <$> onlyAnnex o diff --git a/doc/bugs/Changing_sync_to_include_content_breaks_UX.mdwn b/doc/bugs/Changing_sync_to_include_content_breaks_UX.mdwn index ddf3d098cb..14380e6964 100644 --- a/doc/bugs/Changing_sync_to_include_content_breaks_UX.mdwn +++ b/doc/bugs/Changing_sync_to_include_content_breaks_UX.mdwn @@ -64,3 +64,5 @@ Absolutely. I've been using git-annex since nearly the beginning; and use it ex Thanks for writing git-annex. It's the reason I've been sponsoring you on Patreon for years. Please don't break backwards compatibility. Even in the user experience :-) + +> [[closing|done]] per new plan --[[Joey]] diff --git a/doc/bugs/Changing_sync_to_include_content_breaks_UX/comment_19_bdc211b026d3b05de127f6ed5a3d19b0._comment b/doc/bugs/Changing_sync_to_include_content_breaks_UX/comment_19_bdc211b026d3b05de127f6ed5a3d19b0._comment new file mode 100644 index 0000000000..611d045637 --- /dev/null +++ b/doc/bugs/Changing_sync_to_include_content_breaks_UX/comment_19_bdc211b026d3b05de127f6ed5a3d19b0._comment @@ -0,0 +1,21 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 19""" + date="2023-08-14T16:56:48Z" + content=""" +Changing the default preferred content expression to `present` rather than +`anything` would affect other things like `get --auto` and the assistant. I +don't think that is a good idea. + +My idea in comment #15 is a special case for sync and not a wider change. + +It will have a special case either way. The current special case means +that users who have set preferred content need to remember to use `sync +--content`. The new special case will only manifest as a difference in +behavior between `sync` and `sync --content` (and `get --auto` etc) +for users with no preferred content configured. + +I do think that's a valuable narrowing of the special case. + +Gone ahead and changed the warning. +"""]] diff --git a/doc/git-annex-sync.mdwn b/doc/git-annex-sync.mdwn index 8712a8bc8b..095532c0c0 100644 --- a/doc/git-annex-sync.mdwn +++ b/doc/git-annex-sync.mdwn @@ -16,6 +16,7 @@ previously been added to the repository. Then it does the equivilant of However, unlike those commands, this command does not transfer annexed content by default. That will change in a future version of git-annex, +when syncing with repositories that have preferred content configured. # OPTIONS diff --git a/doc/todo/finish_sync_content_transition.mdwn b/doc/todo/finish_sync_content_transition.mdwn new file mode 100644 index 0000000000..55994a2915 --- /dev/null +++ b/doc/todo/finish_sync_content_transition.mdwn @@ -0,0 +1,14 @@ +This transition is from `git-annex sync` needing `--content` to send +content to repositories that have preferred content configured, to sending +content by default to such repositories. + +There should be no change in behavior with repositories that don't have +preferred content configured. `sync` without `--content` won't populate them +since that would be a surprising thing and a warning based transition was +judged by the community to be not sufficient to avoid that possible large +surprise. (See [[bugs/Changing_sync_to_include_content_breaks_UX]]) + +A warning was added in August 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. diff --git a/doc/todo/v11_changes.mdwn b/doc/todo/v11_changes.mdwn index b9f9cd1c0b..2e40f0ca9b 100644 --- a/doc/todo/v11_changes.mdwn +++ b/doc/todo/v11_changes.mdwn @@ -10,10 +10,3 @@ version. 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 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.