remove withIndexUpdate helper

This commit is contained in:
Joey Hess 2012-09-15 15:40:13 -04:00
parent b453ea8b48
commit 87fb9c690e

View file

@ -85,7 +85,7 @@ getBranch = maybe (hasOrigin >>= go >>= use) return =<< branchsha
return sha return sha
branchsha = inRepo $ Git.Ref.sha fullname branchsha = inRepo $ Git.Ref.sha fullname
{- Ensures that the branch and index are is up-to-date; should be {- Ensures that the branch and index are up-to-date; should be
- called before data is read from it. Runs only once per git-annex run. - called before data is read from it. Runs only once per git-annex run.
-} -}
update :: Annex () update :: Annex ()
@ -145,7 +145,8 @@ updateTo pairs = do
isnewer (r, _) = inRepo $ Git.Branch.changed fullname r isnewer (r, _) = inRepo $ Git.Branch.changed fullname r
{- Gets the content of a file on the branch, or content from the journal, or {- Gets the content of a file on the branch, or content from the journal, or
- staged in the index. - staged in the index. Merges remote versions of the branch if necessary,
- to ensure the most up-to-date available content is available.
- -
- Returns an empty string if the file doesn't exist yet. -} - Returns an empty string if the file doesn't exist yet. -}
get :: FilePath -> Annex String get :: FilePath -> Annex String
@ -165,7 +166,9 @@ get' staleok file = fromcache =<< getCache file
fromjournal (Just content) = cache content fromjournal (Just content) = cache content
fromjournal Nothing fromjournal Nothing
| staleok = withIndex frombranch | staleok = withIndex frombranch
| otherwise = withIndexUpdate $ frombranch >>= cache | otherwise = do
update
withIndex $ frombranch >>= cache
frombranch = L.unpack <$> catFile fullname file frombranch = L.unpack <$> catFile fullname file
cache content = do cache content = do
setCache file content setCache file content
@ -249,12 +252,13 @@ commitBranch branchref message parents = do
{- Lists all files on the branch. There may be duplicates in the list. -} {- Lists all files on the branch. There may be duplicates in the list. -}
files :: Annex [FilePath] files :: Annex [FilePath]
files = withIndexUpdate $ do files = do
bfiles <- inRepo $ Git.Command.pipeNullSplit update
[Params "ls-tree --name-only -r -z", Param $ show fullname] withIndex $ do
jfiles <- getJournalledFiles bfiles <- inRepo $ Git.Command.pipeNullSplit
return $ jfiles ++ bfiles [Params "ls-tree --name-only -r -z", Param $ show fullname]
jfiles <- getJournalledFiles
return $ jfiles ++ bfiles
{- Populates the branch's index file with the current branch contents. {- Populates the branch's index file with the current branch contents.
- -
@ -292,11 +296,6 @@ withIndex' bootstrapping a = do
return r return r
{- Runs an action using the branch's index file, first making sure that
- the branch and index are up-to-date. -}
withIndexUpdate :: Annex a -> Annex a
withIndexUpdate a = update >> withIndex a
{- Updates the branch's index to reflect the current contents of the branch. {- Updates the branch's index to reflect the current contents of the branch.
- Any changes staged in the index will be preserved. - Any changes staged in the index will be preserved.
- -