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.
This commit is contained in:
parent
3899e216af
commit
e66b7d2e1b
6 changed files with 42 additions and 37 deletions
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue