use git command queue

This commit is contained in:
Joey Hess 2010-10-26 16:15:29 -04:00
parent ef26076a5a
commit 24ee4439d4
3 changed files with 16 additions and 15 deletions

View file

@ -216,7 +216,7 @@ addCleanup file key = do
liftIO $ renameFile file dest liftIO $ renameFile file dest
link <- calcGitLink file key link <- calcGitLink file key
liftIO $ createSymbolicLink link file liftIO $ createSymbolicLink link file
liftIO $ Git.run g ["add", file] Annex.queue "add" [] file
return True return True
{- The unannex subcommand undoes an add. -} {- The unannex subcommand undoes an add. -}
@ -340,11 +340,10 @@ fixPerform file link = do
liftIO $ createDirectoryIfMissing True (parentDir file) liftIO $ createDirectoryIfMissing True (parentDir file)
liftIO $ removeFile file liftIO $ removeFile file
liftIO $ createSymbolicLink link file liftIO $ createSymbolicLink link file
g <- Annex.gitRepo return $ Just $ fixCleanup file
liftIO $ Git.run g ["add", file] fixCleanup :: FilePath -> Annex Bool
return $ Just $ fixCleanup fixCleanup file = do
fixCleanup :: Annex Bool Annex.queue "add" [] file
fixCleanup = do
return True return True
{- Stores description for the repository. -} {- Stores description for the repository. -}
@ -391,8 +390,7 @@ fromKeyPerform file key = do
return $ Just $ fromKeyCleanup file return $ Just $ fromKeyCleanup file
fromKeyCleanup :: FilePath -> Annex Bool fromKeyCleanup :: FilePath -> Annex Bool
fromKeyCleanup file = do fromKeyCleanup file = do
g <- Annex.gitRepo Annex.queue "add" [] file
liftIO $ Git.run g ["add", file]
return True return True
{- Move a file either --to or --from a repository. {- Move a file either --to or --from a repository.
@ -453,7 +451,8 @@ moveToCleanup remote key tmpfile = do
-- Record that the key is present on the remote. -- Record that the key is present on the remote.
g <- Annex.gitRepo g <- Annex.gitRepo
remoteuuid <- getUUID remote remoteuuid <- getUUID remote
liftIO $ logChange g key remoteuuid ValuePresent log <- liftIO $ logChange g key remoteuuid ValuePresent
Annex.queue "add" [] log
-- Cleanup on the local side is the same as done for the -- Cleanup on the local side is the same as done for the
-- drop subcommand. -- drop subcommand.
dropCleanup key dropCleanup key
@ -492,7 +491,8 @@ moveFromCleanup remote key = do
-- Record locally that the key is not on the remote. -- Record locally that the key is not on the remote.
remoteuuid <- getUUID remote remoteuuid <- getUUID remote
g <- Annex.gitRepo g <- Annex.gitRepo
liftIO $ logChange g key remoteuuid ValueMissing log <- liftIO $ logChange g key remoteuuid ValueMissing
Annex.queue "add" [] log
return True return True
-- helpers -- helpers

View file

@ -39,8 +39,6 @@ shutdown = do
liftIO $ putStrLn "Recording state in git..." liftIO $ putStrLn "Recording state in git..."
liftIO $ GitQueue.run g q liftIO $ GitQueue.run g q
liftIO $ Git.run g ["add", gitStateDir g]
-- clean up any files left in the temp directory, but leave -- clean up any files left in the temp directory, but leave
-- the tmp directory itself -- the tmp directory itself
let tmp = annexTmpLocation g let tmp = annexTmpLocation g
@ -106,7 +104,8 @@ logStatus :: Key -> LogStatus -> Annex ()
logStatus key status = do logStatus key status = do
g <- Annex.gitRepo g <- Annex.gitRepo
u <- getUUID g u <- getUUID g
liftIO $ logChange g key u status log <- liftIO $ logChange g key u status
Annex.queue "add" [] log
{- Runs an action, passing it a temporary filename to download, {- Runs an action, passing it a temporary filename to download,
- and if the action succeeds, moves the temp file into - and if the action succeeds, moves the temp file into

View file

@ -82,12 +82,14 @@ instance Read LogLine where
undefined = ret $ LogLine (0) Undefined "" undefined = ret $ LogLine (0) Undefined ""
ret v = [(v, "")] ret v = [(v, "")]
{- Log a change in the presence of a key's value in a repository. -} {- Log a change in the presence of a key's value in a repository,
logChange :: Git.Repo -> Key -> UUID -> LogStatus -> IO () - and returns the filename of the logfile. -}
logChange :: Git.Repo -> Key -> UUID -> LogStatus -> IO (FilePath)
logChange repo key uuid status = do logChange repo key uuid status = do
log <- logNow status uuid log <- logNow status uuid
ls <- readLog logfile ls <- readLog logfile
writeLog logfile (compactLog $ log:ls) writeLog logfile (compactLog $ log:ls)
return logfile
where where
logfile = logFile repo key logfile = logFile repo key