replace (Key, Backend) with Key
Only fsck and reinject and the test suite used the Backend, and they can look it up as needed from the Key. This simplifies the code and also speeds it up. There is a small behavior change here. Before, all commands would warn when acting on an annexed file with an unknown backend. Now, only fsck and reinject show that warning.
This commit is contained in:
parent
41c7aaa65c
commit
e880d0d22c
33 changed files with 112 additions and 94 deletions
24
Backend.hs
24
Backend.hs
|
@ -1,6 +1,6 @@
|
|||
{- git-annex key/value backends
|
||||
-
|
||||
- Copyright 2010,2013 Joey Hess <joey@kitenet.net>
|
||||
- Copyright 2010-2014 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
@ -10,6 +10,7 @@ module Backend (
|
|||
orderedList,
|
||||
genKey,
|
||||
lookupFile,
|
||||
getBackend,
|
||||
isAnnexLink,
|
||||
chooseBackend,
|
||||
lookupBackendName,
|
||||
|
@ -74,7 +75,7 @@ genKey' (b:bs) source = do
|
|||
| c == '\n' = '_'
|
||||
| otherwise = c
|
||||
|
||||
{- Looks up the key and backend corresponding to an annexed file,
|
||||
{- Looks up the key corresponding to an annexed file,
|
||||
- by examining what the file links to.
|
||||
-
|
||||
- In direct mode, there is often no link on disk, in which case
|
||||
|
@ -82,7 +83,7 @@ genKey' (b:bs) source = do
|
|||
- on disk still takes precedence over what was committed to git in direct
|
||||
- mode.
|
||||
-}
|
||||
lookupFile :: FilePath -> Annex (Maybe (Key, Backend))
|
||||
lookupFile :: FilePath -> Annex (Maybe Key)
|
||||
lookupFile file = do
|
||||
mkey <- isAnnexLink file
|
||||
case mkey of
|
||||
|
@ -92,14 +93,15 @@ lookupFile file = do
|
|||
, return Nothing
|
||||
)
|
||||
where
|
||||
makeret k = let bname = keyBackendName k in
|
||||
case maybeLookupBackendName bname of
|
||||
Just backend -> return $ Just (k, backend)
|
||||
Nothing -> do
|
||||
warning $
|
||||
"skipping " ++ file ++
|
||||
" (unknown backend " ++ bname ++ ")"
|
||||
return Nothing
|
||||
makeret k = return $ Just k
|
||||
|
||||
getBackend :: FilePath -> Key -> Annex (Maybe Backend)
|
||||
getBackend file k = let bname = keyBackendName k in
|
||||
case maybeLookupBackendName bname of
|
||||
Just backend -> return $ Just backend
|
||||
Nothing -> do
|
||||
warning $ "skipping " ++ file ++ " (unknown backend " ++ bname ++ ")"
|
||||
return Nothing
|
||||
|
||||
{- Looks up the backend that should be used for a file.
|
||||
- That can be configured on a per-file basis in the gitattributes file. -}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue