rework git check-attr interface
Now gitattributes are looked up, efficiently, in only the places that
really need them, using the same approach used for cat-file.
The old CheckAttr code seemed very fragile, in the way it streamed files
through git check-attr.
I actually found that cad8824852
was still deadlocking with ghc 7.4, at the end of adding a lot of files.
This should fix that problem, and avoid future ones.
The best part is that this removes withAttrFilesInGit and withNumCopies,
which were complicated Seek methods, as well as simplfying the types
for several other Seek methods that had a Backend tupled in.
This commit is contained in:
parent
d35a8d85b5
commit
cbaebf538a
16 changed files with 143 additions and 99 deletions
21
Backend.hs
21
Backend.hs
|
@ -6,12 +6,11 @@
|
|||
-}
|
||||
|
||||
module Backend (
|
||||
BackendFile,
|
||||
list,
|
||||
orderedList,
|
||||
genKey,
|
||||
lookupFile,
|
||||
chooseBackends,
|
||||
chooseBackend,
|
||||
lookupBackendName,
|
||||
maybeLookupBackendName
|
||||
) where
|
||||
|
@ -22,6 +21,7 @@ import Common.Annex
|
|||
import qualified Git.Config
|
||||
import qualified Git.CheckAttr
|
||||
import qualified Annex
|
||||
import Annex.CheckAttr
|
||||
import Types.Key
|
||||
import qualified Types.Backend as B
|
||||
|
||||
|
@ -93,20 +93,15 @@ lookupFile file = do
|
|||
bname ++ ")"
|
||||
return Nothing
|
||||
|
||||
type BackendFile = (Maybe Backend, FilePath)
|
||||
|
||||
{- Looks up the backends that should be used for each file in a list.
|
||||
{- Looks up the backend that should be used for a file.
|
||||
- That can be configured on a per-file basis in the gitattributes file.
|
||||
-}
|
||||
chooseBackends :: [FilePath] -> Annex [BackendFile]
|
||||
chooseBackends fs = Annex.getState Annex.forcebackend >>= go
|
||||
chooseBackend :: FilePath -> Annex (Maybe Backend)
|
||||
chooseBackend f = Annex.getState Annex.forcebackend >>= go
|
||||
where
|
||||
go Nothing = do
|
||||
pairs <- inRepo $ Git.CheckAttr.lookup "annex.backend" fs
|
||||
return $ map (\(f,b) -> (maybeLookupBackendName b, f)) pairs
|
||||
go (Just _) = do
|
||||
l <- orderedList
|
||||
return $ map (\f -> (Just $ Prelude.head l, f)) fs
|
||||
go Nothing = maybeLookupBackendName <$>
|
||||
checkAttr "annex.backend" f
|
||||
go (Just _) = Just . Prelude.head <$> orderedList
|
||||
|
||||
{- Looks up a backend by name. May fail if unknown. -}
|
||||
lookupBackendName :: String -> Backend
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue