commit logs at end; faster

This commit is contained in:
Joey Hess 2010-10-17 18:52:09 -04:00
parent bb6707020d
commit 335c06171a
3 changed files with 14 additions and 16 deletions

View file

@ -116,6 +116,8 @@ checkRemoveKey key = do
then retNotEnoughCopiesKnown remotes numcopies then retNotEnoughCopiesKnown remotes numcopies
else findcopies numcopies remotes [] else findcopies numcopies remotes []
where where
config = "annex.numcopies"
findcopies 0 _ _ = return True -- success, enough copies found findcopies 0 _ _ = return True -- success, enough copies found
findcopies _ [] bad = notEnoughCopiesSeen bad findcopies _ [] bad = notEnoughCopiesSeen bad
findcopies n (r:rs) bad = do findcopies n (r:rs) bad = do
@ -151,5 +153,3 @@ checkRemoveKey key = do
showLongNote $ "According to the " ++ config ++ showLongNote $ "According to the " ++ config ++
" setting, it is not safe to remove it!" " setting, it is not safe to remove it!"
showLongNote "(Use --force to override.)" showLongNote "(Use --force to override.)"
config = "annex.numcopies"

View file

@ -123,7 +123,7 @@ addCmd file = inBackend file $ 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
gitAdd file $ Just $ "git-annex annexed " ++ file gitAdd file $ "git-annex annexed " ++ file
showEndOk showEndOk
{- Undo addCmd. -} {- Undo addCmd. -}
@ -212,7 +212,7 @@ fixCmd file = notinBackend file $ \(key, backend) -> 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
gitAdd file $ Just $ "git-annex fix " ++ file gitAdd file $ "git-annex fix " ++ file
showEndOk showEndOk
{- Stores description for the repository. -} {- Stores description for the repository. -}
@ -227,7 +227,7 @@ initCmd description = do
u <- getUUID g u <- getUUID g
describeUUID u description describeUUID u description
log <- uuidLog log <- uuidLog
gitAdd log $ Just $ "description for UUID " ++ (show u) gitAdd log $ "description for UUID " ++ (show u)
liftIO $ putStrLn "description set" liftIO $ putStrLn "description set"
-- helpers -- helpers

20
Core.hs
View file

@ -34,8 +34,10 @@ shutdown = do
nocommit <- Annex.flagIsSet NoCommit nocommit <- Annex.flagIsSet NoCommit
needcommit <- Annex.flagIsSet NeedCommit needcommit <- Annex.flagIsSet NeedCommit
if (needcommit && not nocommit) if (needcommit && not nocommit)
then liftIO $ Git.run g ["commit", "-q", "-m", then do
"git-annex log update", gitStateDir g] liftIO $ Git.run g ["add", gitStateDir g]
liftIO $ Git.run g ["commit", "-q", "-m",
"git-annex log update", gitStateDir g]
else return () else return ()
-- clean up any files left in the temp directory -- clean up any files left in the temp directory
@ -75,14 +77,12 @@ inAnnex key = do
g <- Annex.gitRepo g <- Annex.gitRepo
liftIO $ doesFileExist $ annexLocation g key liftIO $ doesFileExist $ annexLocation g key
{- Adds, optionally also commits a file to git. {- Adds and commits a file to git.
-
- All changes to the git repository should go through this function.
- -
- This is careful to not rely on the index. It may have staged changes, - This is careful to not rely on the index. It may have staged changes,
- so only use operations that avoid committing such changes. - so only use operations that avoid committing such changes.
-} -}
gitAdd :: FilePath -> Maybe String -> Annex () gitAdd :: FilePath -> String -> Annex ()
gitAdd file commitmessage = do gitAdd file commitmessage = do
nocommit <- Annex.flagIsSet NoCommit nocommit <- Annex.flagIsSet NoCommit
if (nocommit) if (nocommit)
@ -90,10 +90,8 @@ gitAdd file commitmessage = do
else do else do
g <- Annex.gitRepo g <- Annex.gitRepo
liftIO $ Git.run g ["add", file] liftIO $ Git.run g ["add", file]
if (isJust commitmessage) liftIO $ Git.run g ["commit", "--quiet",
then liftIO $ Git.run g ["commit", "--quiet", "-m", commitmessage, file]
"-m", (fromJust commitmessage), file]
else Annex.flagChange NeedCommit True
{- Calculates the relative path to use to link a file to a key. -} {- Calculates the relative path to use to link a file to a key. -}
calcGitLink :: FilePath -> Key -> Annex FilePath calcGitLink :: FilePath -> Key -> Annex FilePath
@ -112,7 +110,7 @@ logStatus key status = do
g <- Annex.gitRepo g <- Annex.gitRepo
u <- getUUID g u <- getUUID g
f <- liftIO $ logChange g key u status f <- liftIO $ logChange g key u status
gitAdd f Nothing -- all logs are committed at end Annex.flagChange NeedCommit True -- commit all logs at end
{- Output logging -} {- Output logging -}
showStart :: String -> String -> Annex () showStart :: String -> String -> Annex ()