diff options
author | Joey Hess <joey@kitenet.net> | 2012-02-13 23:42:44 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-02-13 23:52:21 -0400 |
commit | cbaebf538a8659193fb3dbb4f32e0f918a385af3 (patch) | |
tree | 63a86b6f3ffe8e08f8610a267c2c19bb2389bfc8 /Seek.hs | |
parent | d35a8d85b5ee9ce3d6057300e21729183cce802b (diff) |
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 cad8824852aa0623dc41eac02a9e2bae47d88ec4
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.
Diffstat (limited to 'Seek.hs')
-rw-r--r-- | Seek.hs | 33 |
1 files changed, 7 insertions, 26 deletions
@@ -14,11 +14,9 @@ module Seek where import Common.Annex import Types.Command import Types.Key -import Backend import qualified Annex import qualified Git import qualified Git.LsFiles as LsFiles -import qualified Git.CheckAttr import qualified Limit import qualified Option @@ -28,26 +26,12 @@ seekHelper a params = inRepo $ \g -> runPreserveOrder (`a` g) params withFilesInGit :: (FilePath -> CommandStart) -> CommandSeek withFilesInGit a params = prepFiltered a $ seekHelper LsFiles.inRepo params -withAttrFilesInGit :: String -> ((FilePath, String) -> CommandStart) -> CommandSeek -withAttrFilesInGit attr a params = do - files <- seekHelper LsFiles.inRepo params - prepFilteredGen a fst $ inRepo $ Git.CheckAttr.lookup attr files - -withNumCopies :: (Maybe Int -> FilePath -> CommandStart) -> CommandSeek -withNumCopies a params = withAttrFilesInGit "annex.numcopies" go params - where - go (file, v) = a (readish v) file - -withBackendFilesInGit :: (BackendFile -> CommandStart) -> CommandSeek -withBackendFilesInGit a params = - prepBackendPairs a =<< seekHelper LsFiles.inRepo params - -withFilesNotInGit :: (BackendFile -> CommandStart) -> CommandSeek +withFilesNotInGit :: (FilePath -> CommandStart) -> CommandSeek withFilesNotInGit a params = do {- dotfiles are not acted on unless explicitly listed -} files <- filter (not . dotfile) <$> seek ps dotfiles <- if null dotps then return [] else seek dotps - prepBackendPairs a $ preserveOrder params (files++dotfiles) + prepFiltered a $ return $ preserveOrder params (files++dotfiles) where (dotps, ps) = partition dotfile params seek l = do @@ -65,20 +49,20 @@ withFilesToBeCommitted :: (String -> CommandStart) -> CommandSeek withFilesToBeCommitted a params = prepFiltered a $ seekHelper LsFiles.stagedNotDeleted params -withFilesUnlocked :: (BackendFile -> CommandStart) -> CommandSeek +withFilesUnlocked :: (FilePath -> CommandStart) -> CommandSeek withFilesUnlocked = withFilesUnlocked' LsFiles.typeChanged -withFilesUnlockedToBeCommitted :: (BackendFile -> CommandStart) -> CommandSeek +withFilesUnlockedToBeCommitted :: (FilePath -> CommandStart) -> CommandSeek withFilesUnlockedToBeCommitted = withFilesUnlocked' LsFiles.typeChangedStaged -withFilesUnlocked' :: ([FilePath] -> Git.Repo -> IO [FilePath]) -> (BackendFile -> CommandStart) -> CommandSeek +withFilesUnlocked' :: ([FilePath] -> Git.Repo -> IO [FilePath]) -> (FilePath -> CommandStart) -> CommandSeek withFilesUnlocked' typechanged a params = do -- unlocked files have changed type from a symlink to a regular file top <- fromRepo Git.workTree typechangedfiles <- seekHelper typechanged params - unlockedfiles <- liftIO $ filterM notSymlink $ + let unlockedfiles = liftIO $ filterM notSymlink $ map (\f -> top ++ "/" ++ f) typechangedfiles - prepBackendPairs a unlockedfiles + prepFiltered a unlockedfiles withKeys :: (Key -> CommandStart) -> CommandSeek withKeys a params = return $ map (a . parse) params @@ -109,9 +93,6 @@ withNothing _ _ = error "This command takes no parameters." prepFiltered :: (FilePath -> CommandStart) -> Annex [FilePath] -> Annex [CommandStart] prepFiltered a = prepFilteredGen a id -prepBackendPairs :: (BackendFile -> CommandStart) -> CommandSeek -prepBackendPairs a fs = prepFilteredGen a snd (chooseBackends fs) - prepFilteredGen :: (b -> CommandStart) -> (b -> FilePath) -> Annex [b] -> Annex [CommandStart] prepFilteredGen a d fs = do matcher <- Limit.getMatcher |