From e66b7d2e1bac258ad4a4d282a56d3ccb62f14868 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 13 Nov 2020 14:32:06 -0400 Subject: [PATCH] rename to --unlock-present and better reverse adjusting An --unlock-present branch reverses back to a branch where all files that get modified or renamed become locked, even if they were originally unlocked. This is the same that reversing a --unlock branch works, and the new name makes that commonality more clear. --- Annex/AdjustedBranch.hs | 19 ++++++++++++------- Annex/AdjustedBranch/Name.hs | 14 +++++++------- CHANGELOG | 2 +- Command/Adjust.hs | 12 ++++++------ Types/AdjustedBranch.hs | 18 +++++++++--------- doc/git-annex-adjust.mdwn | 14 +++++++------- 6 files changed, 42 insertions(+), 37 deletions(-) diff --git a/Annex/AdjustedBranch.hs b/Annex/AdjustedBranch.hs index 2b87b307c8..e8ce0cc49f 100644 --- a/Annex/AdjustedBranch.hs +++ b/Annex/AdjustedBranch.hs @@ -11,7 +11,7 @@ module Annex.AdjustedBranch ( Adjustment(..), LinkAdjustment(..), PresenceAdjustment(..), - LinkMissingAdjustment(..), + LinkPresentAdjustment(..), adjustmentHidesFiles, OrigBranch, AdjBranch(..), @@ -77,7 +77,7 @@ instance AdjustTreeItem Adjustment where adjustTreeItem p t >>= \case Nothing -> return Nothing Just t' -> adjustTreeItem l t' - adjustTreeItem (LinkMissingAdjustment l) t = adjustTreeItem l t + adjustTreeItem (LinkPresentAdjustment l) t = adjustTreeItem l t instance AdjustTreeItem LinkAdjustment where adjustTreeItem UnlockAdjustment = @@ -95,11 +95,16 @@ instance AdjustTreeItem PresenceAdjustment where adjustTreeItem ShowMissingAdjustment = noAdjust -instance AdjustTreeItem LinkMissingAdjustment where - adjustTreeItem LockMissingAdjustment = +instance AdjustTreeItem LinkPresentAdjustment where + adjustTreeItem UnlockPresentAdjustment = ifPresent adjustToPointer adjustToSymlink - adjustTreeItem UnlockMissingAdjustment = - noAdjust + adjustTreeItem LockPresentAdjustment = + -- Turn all pointers back to symlinks, whether the content + -- is present or not. This is done because the content + -- availability may have changed and the branch not been + -- re-adjusted to keep up, so there may be pointers whose + -- content is not present. + ifSymlink noAdjust adjustToSymlink ifSymlink :: (TreeItem -> Annex a) @@ -224,7 +229,7 @@ checkoutAdjustedBranch (AdjBranch b) checkoutparams = do updateAdjustedBranch :: Adjustment -> AdjBranch -> OrigBranch -> Annex Bool updateAdjustedBranch adj@(PresenceAdjustment _ _) currbranch origbranch = updateAdjustedBranch' adj currbranch origbranch -updateAdjustedBranch adj@(LinkMissingAdjustment _) currbranch origbranch = +updateAdjustedBranch adj@(LinkPresentAdjustment _) currbranch origbranch = updateAdjustedBranch' adj currbranch origbranch updateAdjustedBranch adj@(LinkAdjustment _) _ origbranch = preventCommits $ \commitlck -> do diff --git a/Annex/AdjustedBranch/Name.hs b/Annex/AdjustedBranch/Name.hs index 49d50c5f93..e71a5f66c8 100644 --- a/Annex/AdjustedBranch/Name.hs +++ b/Annex/AdjustedBranch/Name.hs @@ -37,7 +37,7 @@ instance SerializeAdjustment Adjustment where serializeAdjustment p serializeAdjustment (PresenceAdjustment p (Just l)) = serializeAdjustment p <> "-" <> serializeAdjustment l - serializeAdjustment (LinkMissingAdjustment l) = + serializeAdjustment (LinkPresentAdjustment l) = serializeAdjustment l deserializeAdjustment s = (LinkAdjustment <$> deserializeAdjustment s) @@ -46,7 +46,7 @@ instance SerializeAdjustment Adjustment where <|> (PresenceAdjustment <$> deserializeAdjustment s <*> pure Nothing) <|> - (LinkMissingAdjustment <$> deserializeAdjustment s) + (LinkPresentAdjustment <$> deserializeAdjustment s) where (s1, s2) = separate' (== (fromIntegral (ord '-'))) s @@ -68,11 +68,11 @@ instance SerializeAdjustment PresenceAdjustment where deserializeAdjustment "showmissing" = Just ShowMissingAdjustment deserializeAdjustment _ = Nothing -instance SerializeAdjustment LinkMissingAdjustment where - serializeAdjustment LockMissingAdjustment = "lockmissing" - serializeAdjustment UnlockMissingAdjustment = "unlockmissing" - deserializeAdjustment "lockmissing" = Just LockMissingAdjustment - deserializeAdjustment "unlockmissing" = Just UnlockMissingAdjustment +instance SerializeAdjustment LinkPresentAdjustment where + serializeAdjustment UnlockPresentAdjustment = "unlockpresent" + serializeAdjustment LockPresentAdjustment = "lockpresent" + deserializeAdjustment "unlockpresent" = Just UnlockPresentAdjustment + deserializeAdjustment "lockpresent" = Just LockPresentAdjustment deserializeAdjustment _ = Nothing newtype AdjBranch = AdjBranch { adjBranch :: Branch } diff --git a/CHANGELOG b/CHANGELOG index a9ce27c8e2..a143664a1c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,7 +10,7 @@ git-annex (8.20201104) UNRELEASED; urgency=medium copied it from some other repository. * examinekey: Added two new format variables: objectpath and objectpointer * examinekey: Added --migrate-to-backend - * adjust: New --lock-missing mode which locks files whose content is not + * adjust: New --unlock-present mode which locks files whose content is not present (so the broken symlink is visible), while unlocking files whose content is present. diff --git a/Command/Adjust.hs b/Command/Adjust.hs index 29b4afc57a..6e15ef8af9 100644 --- a/Command/Adjust.hs +++ b/Command/Adjust.hs @@ -19,7 +19,7 @@ optParser :: CmdParamsDesc -> Parser Adjustment optParser _ = (LinkAdjustment <$> linkAdjustmentParser) <|> (PresenceAdjustment <$> presenceAdjustmentParser <*> maybeLinkAdjustmentParser) - <|> (LinkMissingAdjustment <$> linkMissingAdjustmentParser) + <|> (LinkPresentAdjustment <$> linkPresentAdjustmentParser) linkAdjustmentParser :: Parser LinkAdjustment linkAdjustmentParser = @@ -46,11 +46,11 @@ presenceAdjustmentParser = <> help "hide annexed files whose content is not present" ) -linkMissingAdjustmentParser :: Parser LinkMissingAdjustment -linkMissingAdjustmentParser = - flag' LockMissingAdjustment - ( long "lock-missing" - <> help "lock files whose content is present; unlock rest" +linkPresentAdjustmentParser :: Parser LinkPresentAdjustment +linkPresentAdjustmentParser = + flag' UnlockPresentAdjustment + ( long "unlock-present" + <> help "unlock files whose content is present; lock rest" ) seek :: Adjustment -> CommandSeek diff --git a/Types/AdjustedBranch.hs b/Types/AdjustedBranch.hs index e52373f11e..b6aedf4df9 100644 --- a/Types/AdjustedBranch.hs +++ b/Types/AdjustedBranch.hs @@ -10,7 +10,7 @@ module Types.AdjustedBranch where data Adjustment = LinkAdjustment LinkAdjustment | PresenceAdjustment PresenceAdjustment (Maybe LinkAdjustment) - | LinkMissingAdjustment LinkMissingAdjustment + | LinkPresentAdjustment LinkPresentAdjustment deriving (Show, Eq) data LinkAdjustment @@ -25,9 +25,9 @@ data PresenceAdjustment | ShowMissingAdjustment deriving (Show, Eq) -data LinkMissingAdjustment - = LockMissingAdjustment - | UnlockMissingAdjustment +data LinkPresentAdjustment + = UnlockPresentAdjustment + | LockPresentAdjustment deriving (Show, Eq) -- Adjustments have to be able to be reversed, so that commits made to the @@ -41,8 +41,8 @@ instance ReversableAdjustment Adjustment where LinkAdjustment (reverseAdjustment l) reverseAdjustment (PresenceAdjustment p ml) = PresenceAdjustment (reverseAdjustment p) (fmap reverseAdjustment ml) - reverseAdjustment (LinkMissingAdjustment l) = - LinkMissingAdjustment (reverseAdjustment l) + reverseAdjustment (LinkPresentAdjustment l) = + LinkPresentAdjustment (reverseAdjustment l) instance ReversableAdjustment LinkAdjustment where reverseAdjustment UnlockAdjustment = LockAdjustment @@ -55,9 +55,9 @@ instance ReversableAdjustment PresenceAdjustment where reverseAdjustment HideMissingAdjustment = ShowMissingAdjustment reverseAdjustment ShowMissingAdjustment = HideMissingAdjustment -instance ReversableAdjustment LinkMissingAdjustment where - reverseAdjustment LockMissingAdjustment = UnlockMissingAdjustment - reverseAdjustment UnlockMissingAdjustment = LockMissingAdjustment +instance ReversableAdjustment LinkPresentAdjustment where + reverseAdjustment UnlockPresentAdjustment = LockPresentAdjustment + reverseAdjustment LockPresentAdjustment = UnlockPresentAdjustment adjustmentHidesFiles :: Adjustment -> Bool adjustmentHidesFiles (PresenceAdjustment HideMissingAdjustment _) = True diff --git a/doc/git-annex-adjust.mdwn b/doc/git-annex-adjust.mdwn index 61a2a985e0..125272b86a 100644 --- a/doc/git-annex-adjust.mdwn +++ b/doc/git-annex-adjust.mdwn @@ -4,7 +4,7 @@ git-annex adjust - enter an adjusted branch # SYNOPSIS -git annex adjust `--unlock|--lock|--fix|--hide-missing [--unlock|--lock|--fix]` +git annex adjust `--unlock|--lock|--fix|--hide-missing [--unlock|--lock|--fix]|--unlock-present` # DESCRIPTION @@ -31,8 +31,8 @@ problems, use `git annex merge otherbranch`. Re-running this command with the same options while inside the adjusted branch will update the adjusted branch -as necessary (eg for `--hide-missing`), and will also propagate commits -back to the original branch. +as necessary (eg for `--hide-missing` and `--unlock-present`), +and will also propagate commits back to the original branch. # OPTIONS @@ -91,10 +91,10 @@ back to the original branch. This option can be combined with --unlock, --lock, or --fix. -* `--lock-missing` +* `--unlock-present` - Lock files whose content is not present, and unlock files whose content - is present. This provides the benefits of working with unlocked files, + Unlock files whose content is present, and lock files whose content is + missing. This provides the benefits of working with unlocked files, but makes it easier to see when the content of a file is not missing, since it will be a broken symlink. @@ -104,7 +104,7 @@ back to the original branch. not be broken symlinks. To update the adjusted branch to reflect changes to content availability, - run `git annex adjust --hide-missing` again. Or use `git-annex sync + run `git annex adjust --unlock-present` again. Or use `git-annex sync --content`, which updates the branch after transferring content. # SEE ALSO