remove stateDir

This commit is contained in:
Joey Hess 2011-06-23 08:48:13 -04:00
parent af10b2854a
commit 9e37898e21
5 changed files with 13 additions and 20 deletions

View file

@ -22,7 +22,6 @@ import qualified Backend
import Messages import Messages
import qualified Annex import qualified Annex
import qualified GitRepo as Git import qualified GitRepo as Git
import Locations
import Utility import Utility
import Types.Key import Types.Key
@ -181,17 +180,15 @@ withNothing _ _ = error "This command takes no parameters."
backendPairs :: CommandSeekBackendFiles backendPairs :: CommandSeekBackendFiles
backendPairs a files = liftM (map a) $ Backend.chooseBackends files backendPairs a files = liftM (map a) $ Backend.chooseBackends files
{- Filter out files from the state directory, and those matching the {- Filter out files those matching the exclude glob pattern,
- exclude glob pattern, if it was specified. -} - if it was specified. -}
filterFiles :: [FilePath] -> Annex [FilePath] filterFiles :: [FilePath] -> Annex [FilePath]
filterFiles l = do filterFiles l = do
let l' = filter notState l
exclude <- Annex.getState Annex.exclude exclude <- Annex.getState Annex.exclude
if null exclude if null exclude
then return l' then return l
else return $ filter (notExcluded $ wildsRegex exclude) l' else return $ filter (notExcluded $ wildsRegex exclude) l
where where
notState f = not $ stateDir `isPrefixOf` f
notExcluded r f = isNothing $ match r f [] notExcluded r f = isNothing $ match r f []
wildsRegex :: [String] -> Regex wildsRegex :: [String] -> Regex

View file

@ -6,8 +6,6 @@
-} -}
module Locations ( module Locations (
gitStateDir,
stateDir,
keyFile, keyFile,
fileKey, fileKey,
gitAnnexLocation, gitAnnexLocation,
@ -52,13 +50,6 @@ import qualified GitRepo as Git
- Everything else should use relative paths. - Everything else should use relative paths.
-} -}
{- Long-term, cross-repo state is stored in files inside the .git-annex
- directory, in the git repository's working tree. -}
stateDir :: FilePath
stateDir = addTrailingPathSeparator $ ".git-annex"
gitStateDir :: Git.Repo -> FilePath
gitStateDir repo = addTrailingPathSeparator $ Git.workTree repo </> stateDir
{- The directory git annex uses for local state, relative to the .git {- The directory git annex uses for local state, relative to the .git
- directory -} - directory -}
annexDir :: FilePath annexDir :: FilePath

View file

@ -113,7 +113,7 @@ moveLocationLogs = do
where where
oldlocationlogs = do oldlocationlogs = do
g <- Annex.gitRepo g <- Annex.gitRepo
let dir = gitStateDir g let dir = Upgrade.V2.gitStateDir g
exists <- liftIO $ doesDirectoryExist dir exists <- liftIO $ doesDirectoryExist dir
if exists if exists
then do then do
@ -123,7 +123,7 @@ moveLocationLogs = do
move (l, k) = do move (l, k) = do
g <- Annex.gitRepo g <- Annex.gitRepo
let dest = logFile k let dest = logFile k
let dir = gitStateDir g let dir = Upgrade.V2.gitStateDir g
let f = dir </> l let f = dir </> l
liftIO $ createDirectoryIfMissing True (parentDir dest) liftIO $ createDirectoryIfMissing True (parentDir dest)
-- could just git mv, but this way deals with -- could just git mv, but this way deals with
@ -186,7 +186,7 @@ fileKey1 file = readKey1 $
replace "&a" "&" $ replace "&s" "%" $ replace "%" "/" file replace "&a" "&" $ replace "&s" "%" $ replace "%" "/" file
logFile1 :: Git.Repo -> Key -> String logFile1 :: Git.Repo -> Key -> String
logFile1 repo key = gitStateDir repo ++ keyFile1 key ++ ".log" logFile1 repo key = Upgrade.V2.gitStateDir repo ++ keyFile1 key ++ ".log"
lookupFile1 :: FilePath -> Annex (Maybe (Key, Backend Annex)) lookupFile1 :: FilePath -> Annex (Maybe (Key, Backend Annex))
lookupFile1 file = do lookupFile1 file = do

View file

@ -89,3 +89,9 @@ gitAttributesUnWrite repo = do
liftIO $ safeWriteFile attributes $ unlines $ liftIO $ safeWriteFile attributes $ unlines $
filter (\l -> not $ l `elem` attrLines) $ lines c filter (\l -> not $ l `elem` attrLines) $ lines c
Git.run repo "add" [File attributes] Git.run repo "add" [File attributes]
stateDir :: FilePath
stateDir = addTrailingPathSeparator $ ".git-annex"
gitStateDir :: Git.Repo -> FilePath
gitStateDir repo = addTrailingPathSeparator $ Git.workTree repo </> stateDir

View file

@ -69,7 +69,6 @@ Example upgrade process:
cd localrepo cd localrepo
git pull git pull
git annex upgrade git annex upgrade
(Upgrading object directory layout v1 to v2...)
git commit -m "upgrade v1 to v2" git commit -m "upgrade v1 to v2"
git push git push