implemented cloneSimRepo
Started on updateSimRepoState
This commit is contained in:
parent
8d707c4821
commit
4e11cb19ef
3 changed files with 82 additions and 15 deletions
|
@ -1,6 +1,6 @@
|
|||
{- git-annex repository differences
|
||||
-
|
||||
- Copyright 2015 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2015-2024 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -51,6 +51,7 @@ data Difference
|
|||
= ObjectHashLower
|
||||
| OneLevelObjectHash
|
||||
| OneLevelBranchHash
|
||||
| Simulation
|
||||
deriving (Show, Read, Eq, Ord, Enum, Bounded)
|
||||
|
||||
-- This type is used internally for efficient checking for differences,
|
||||
|
@ -60,6 +61,7 @@ data Differences
|
|||
{ objectHashLower :: Bool
|
||||
, oneLevelObjectHash :: Bool
|
||||
, oneLevelBranchHash :: Bool
|
||||
, simulation :: Bool
|
||||
}
|
||||
| UnknownDifferences
|
||||
|
||||
|
@ -71,6 +73,7 @@ instance Eq Differences where
|
|||
[ objectHashLower
|
||||
, oneLevelObjectHash
|
||||
, oneLevelBranchHash
|
||||
, simulation
|
||||
]
|
||||
|
||||
appendDifferences :: Differences -> Differences -> Differences
|
||||
|
@ -78,6 +81,7 @@ appendDifferences a@(Differences {}) b@(Differences {}) = a
|
|||
{ objectHashLower = objectHashLower a || objectHashLower b
|
||||
, oneLevelObjectHash = oneLevelObjectHash a || oneLevelObjectHash b
|
||||
, oneLevelBranchHash = oneLevelBranchHash a || oneLevelBranchHash b
|
||||
, simulation = simulation a || simulation b
|
||||
}
|
||||
appendDifferences _ _ = UnknownDifferences
|
||||
|
||||
|
@ -85,7 +89,7 @@ instance Sem.Semigroup Differences where
|
|||
(<>) = appendDifferences
|
||||
|
||||
instance Monoid Differences where
|
||||
mempty = Differences False False False
|
||||
mempty = Differences False False False False
|
||||
|
||||
readDifferences :: String -> Differences
|
||||
readDifferences = maybe UnknownDifferences mkDifferences . readish
|
||||
|
@ -97,26 +101,28 @@ getDifferences :: Git.Repo -> Differences
|
|||
getDifferences r = mkDifferences $ S.fromList $
|
||||
mapMaybe getmaybe [minBound .. maxBound]
|
||||
where
|
||||
getmaybe d = case Git.Config.isTrueFalse' =<< Git.Config.getMaybe (differenceConfigKey d) r of
|
||||
getmaybe d = case Git.Config.isTrueFalse' =<< flip Git.Config.getMaybe r =<< differenceConfigKey d of
|
||||
Just True -> Just d
|
||||
_ -> Nothing
|
||||
|
||||
differenceConfigKey :: Difference -> ConfigKey
|
||||
differenceConfigKey :: Difference -> Maybe ConfigKey
|
||||
differenceConfigKey ObjectHashLower = tunable "objecthashlower"
|
||||
differenceConfigKey OneLevelObjectHash = tunable "objecthash1"
|
||||
differenceConfigKey OneLevelBranchHash = tunable "branchhash1"
|
||||
differenceConfigKey Simulation = Nothing
|
||||
|
||||
differenceConfigVal :: Difference -> String
|
||||
differenceConfigVal _ = Git.Config.boolConfig True
|
||||
|
||||
tunable :: B.ByteString -> ConfigKey
|
||||
tunable k = ConfigKey ("annex.tune." <> k)
|
||||
tunable :: B.ByteString -> Maybe ConfigKey
|
||||
tunable k = Just $ ConfigKey ("annex.tune." <> k)
|
||||
|
||||
hasDifference :: Difference -> Differences -> Bool
|
||||
hasDifference _ UnknownDifferences = False
|
||||
hasDifference ObjectHashLower ds = objectHashLower ds
|
||||
hasDifference OneLevelObjectHash ds = oneLevelObjectHash ds
|
||||
hasDifference OneLevelBranchHash ds = oneLevelBranchHash ds
|
||||
hasDifference Simulation ds = simulation ds
|
||||
|
||||
listDifferences :: Differences -> [Difference]
|
||||
listDifferences d@(Differences {}) = map snd $
|
||||
|
@ -124,6 +130,7 @@ listDifferences d@(Differences {}) = map snd $
|
|||
[ (objectHashLower, ObjectHashLower)
|
||||
, (oneLevelObjectHash, OneLevelObjectHash)
|
||||
, (oneLevelBranchHash, OneLevelBranchHash)
|
||||
, (simulation, Simulation)
|
||||
]
|
||||
listDifferences UnknownDifferences = []
|
||||
|
||||
|
@ -132,6 +139,7 @@ mkDifferences s = Differences
|
|||
{ objectHashLower = check ObjectHashLower
|
||||
, oneLevelObjectHash = check OneLevelObjectHash
|
||||
, oneLevelBranchHash = check OneLevelBranchHash
|
||||
, simulation = check Simulation
|
||||
}
|
||||
where
|
||||
check f = f `S.member` s
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue