improved git-annex branch changing

All changes to files in the branch are now made via pure functions that
transform the old file into the new. This will allow adding locking
to prevent read/write races. It also makes the code nicer, and purer.

I noticed a behavior change, really a sort of bug fix. Before,
'git annex untrust foo --trust bar' would change both trust levels
permanantly, now the --trust doesn't get stored.
This commit is contained in:
Joey Hess 2011-10-03 15:41:25 -04:00
parent 6dfb94b2d7
commit f77979b8b5
7 changed files with 34 additions and 30 deletions

View file

@ -87,8 +87,8 @@ inject :: FilePath -> FilePath -> Annex ()
inject source dest = do
g <- Annex.gitRepo
new <- liftIO (readFile $ olddir g </> source)
prev <- Branch.get dest
Branch.change dest $ unlines $ nub $ lines prev ++ lines new
Branch.change dest $ \prev ->
unlines $ nub $ lines prev ++ lines new
showProgress
logFiles :: FilePath -> Annex [FilePath]