2018-10-19 19:17:48 +00:00
|
|
|
{- adjusted branch types
|
|
|
|
-
|
2020-11-13 17:27:03 +00:00
|
|
|
- Copyright 2016-2020 Joey Hess <id@joeyh.name>
|
2018-10-19 19:17:48 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Types.AdjustedBranch where
|
|
|
|
|
|
|
|
data Adjustment
|
|
|
|
= LinkAdjustment LinkAdjustment
|
|
|
|
| PresenceAdjustment PresenceAdjustment (Maybe LinkAdjustment)
|
2020-11-13 18:32:06 +00:00
|
|
|
| LinkPresentAdjustment LinkPresentAdjustment
|
2018-10-19 19:17:48 +00:00
|
|
|
deriving (Show, Eq)
|
|
|
|
|
|
|
|
data LinkAdjustment
|
|
|
|
= UnlockAdjustment
|
|
|
|
| LockAdjustment
|
|
|
|
| FixAdjustment
|
|
|
|
| UnFixAdjustment
|
|
|
|
deriving (Show, Eq)
|
|
|
|
|
|
|
|
data PresenceAdjustment
|
|
|
|
= HideMissingAdjustment
|
|
|
|
| ShowMissingAdjustment
|
|
|
|
deriving (Show, Eq)
|
|
|
|
|
2020-11-13 18:32:06 +00:00
|
|
|
data LinkPresentAdjustment
|
|
|
|
= UnlockPresentAdjustment
|
|
|
|
| LockPresentAdjustment
|
2020-11-13 17:27:03 +00:00
|
|
|
deriving (Show, Eq)
|
|
|
|
|
2018-10-19 19:17:48 +00:00
|
|
|
-- Adjustments have to be able to be reversed, so that commits made to the
|
|
|
|
-- adjusted branch can be reversed to the commit that would have been made
|
|
|
|
-- without the adjustment and applied to the original branch.
|
|
|
|
class ReversableAdjustment t where
|
|
|
|
reverseAdjustment :: t -> t
|
|
|
|
|
|
|
|
instance ReversableAdjustment Adjustment where
|
|
|
|
reverseAdjustment (LinkAdjustment l) =
|
|
|
|
LinkAdjustment (reverseAdjustment l)
|
|
|
|
reverseAdjustment (PresenceAdjustment p ml) =
|
|
|
|
PresenceAdjustment (reverseAdjustment p) (fmap reverseAdjustment ml)
|
2020-11-13 18:32:06 +00:00
|
|
|
reverseAdjustment (LinkPresentAdjustment l) =
|
|
|
|
LinkPresentAdjustment (reverseAdjustment l)
|
2018-10-19 19:17:48 +00:00
|
|
|
|
|
|
|
instance ReversableAdjustment LinkAdjustment where
|
|
|
|
reverseAdjustment UnlockAdjustment = LockAdjustment
|
2019-09-27 18:23:25 +00:00
|
|
|
-- Keep the file locked intentionally when reversing LockAdjustment.
|
|
|
|
reverseAdjustment LockAdjustment = LockAdjustment
|
2018-10-19 19:17:48 +00:00
|
|
|
reverseAdjustment FixAdjustment = UnFixAdjustment
|
|
|
|
reverseAdjustment UnFixAdjustment = FixAdjustment
|
|
|
|
|
|
|
|
instance ReversableAdjustment PresenceAdjustment where
|
|
|
|
reverseAdjustment HideMissingAdjustment = ShowMissingAdjustment
|
|
|
|
reverseAdjustment ShowMissingAdjustment = HideMissingAdjustment
|
|
|
|
|
2020-11-13 18:32:06 +00:00
|
|
|
instance ReversableAdjustment LinkPresentAdjustment where
|
|
|
|
reverseAdjustment UnlockPresentAdjustment = LockPresentAdjustment
|
|
|
|
reverseAdjustment LockPresentAdjustment = UnlockPresentAdjustment
|
2020-11-13 17:27:03 +00:00
|
|
|
|
2018-10-19 19:17:48 +00:00
|
|
|
adjustmentHidesFiles :: Adjustment -> Bool
|
|
|
|
adjustmentHidesFiles (PresenceAdjustment HideMissingAdjustment _) = True
|
|
|
|
adjustmentHidesFiles _ = False
|