add inRepoDetails
planned to use for an optimisation most things using stagedDetails were not expecting to get dup files in a conflicted merge and deal with them, so converted them to use inRepoDetails.
This commit is contained in:
parent
7347e50123
commit
9f6bd6cc05
5 changed files with 27 additions and 17 deletions
|
@ -345,11 +345,11 @@ narrowView = applyView' viewedFileReuse getViewedFileMetaData
|
||||||
applyView' :: MkViewedFile -> (FilePath -> MetaData) -> View -> Annex Git.Branch
|
applyView' :: MkViewedFile -> (FilePath -> MetaData) -> View -> Annex Git.Branch
|
||||||
applyView' mkviewedfile getfilemetadata view = do
|
applyView' mkviewedfile getfilemetadata view = do
|
||||||
top <- fromRepo Git.repoPath
|
top <- fromRepo Git.repoPath
|
||||||
(l, clean) <- inRepo $ Git.LsFiles.stagedDetails [top]
|
(l, clean) <- inRepo $ Git.LsFiles.inRepoDetails [] [top]
|
||||||
liftIO . nukeFile =<< fromRepo gitAnnexViewIndex
|
liftIO . nukeFile =<< fromRepo gitAnnexViewIndex
|
||||||
viewg <- withViewIndex gitRepo
|
viewg <- withViewIndex gitRepo
|
||||||
withUpdateIndex viewg $ \uh -> do
|
withUpdateIndex viewg $ \uh -> do
|
||||||
forM_ l $ \(f, sha, mode, _) -> do
|
forM_ l $ \(f, sha, mode) -> do
|
||||||
topf <- inRepo (toTopFilePath f)
|
topf <- inRepo (toTopFilePath f)
|
||||||
go uh topf sha (toTreeItemType mode) =<< lookupFile f
|
go uh topf sha (toTreeItemType mode) =<< lookupFile f
|
||||||
liftIO $ void clean
|
liftIO $ void clean
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
module Git.LsFiles (
|
module Git.LsFiles (
|
||||||
Options(..),
|
Options(..),
|
||||||
inRepo,
|
inRepo,
|
||||||
|
inRepoDetails,
|
||||||
inRepoOrBranch,
|
inRepoOrBranch,
|
||||||
notInRepo,
|
notInRepo,
|
||||||
notInRepoIncludingEmptyDirectories,
|
notInRepoIncludingEmptyDirectories,
|
||||||
|
@ -67,6 +68,9 @@ guardSafeForLsFiles r a
|
||||||
|
|
||||||
data Options = ErrorUnmatch
|
data Options = ErrorUnmatch
|
||||||
|
|
||||||
|
opParam :: Options -> CommandParam
|
||||||
|
opParam ErrorUnmatch = Param "--error-unmatch"
|
||||||
|
|
||||||
{- Lists files that are checked into git's index at the specified paths.
|
{- Lists files that are checked into git's index at the specified paths.
|
||||||
- With no paths, all files are listed.
|
- With no paths, all files are listed.
|
||||||
-}
|
-}
|
||||||
|
@ -79,9 +83,18 @@ inRepo' ps os l repo = guardSafeForLsFiles repo $ pipeNullSplit' params repo
|
||||||
params =
|
params =
|
||||||
Param "ls-files" :
|
Param "ls-files" :
|
||||||
Param "-z" :
|
Param "-z" :
|
||||||
map op os ++ ps ++
|
map opParam os ++ ps ++
|
||||||
(Param "--" : map (File . fromRawFilePath) l)
|
(Param "--" : map (File . fromRawFilePath) l)
|
||||||
op ErrorUnmatch = Param "--error-unmatch"
|
|
||||||
|
{- Lists the same files inRepo does, but with sha and mode. -}
|
||||||
|
inRepoDetails :: [Options] -> [RawFilePath] -> Repo -> IO ([(RawFilePath, Sha, FileMode)], IO Bool)
|
||||||
|
inRepoDetails = stagedDetails' parser . map opParam
|
||||||
|
where
|
||||||
|
parser s = case parseStagedDetails s of
|
||||||
|
Just (file, sha, mode, stagenum)
|
||||||
|
| stagenum == usualStageNum || stagenum == mergeConflictHeadStageNum ->
|
||||||
|
Just (file, sha, mode)
|
||||||
|
_ -> Nothing
|
||||||
|
|
||||||
{- Files that are checked into the index or have been committed to a
|
{- Files that are checked into the index or have been committed to a
|
||||||
- branch. -}
|
- branch. -}
|
||||||
|
@ -158,12 +171,12 @@ mergeConflictHeadStageNum = 2
|
||||||
- more than once with different stage numbers.
|
- more than once with different stage numbers.
|
||||||
-}
|
-}
|
||||||
stagedDetails :: [RawFilePath] -> Repo -> IO ([StagedDetails], IO Bool)
|
stagedDetails :: [RawFilePath] -> Repo -> IO ([StagedDetails], IO Bool)
|
||||||
stagedDetails = stagedDetails' []
|
stagedDetails = stagedDetails' parseStagedDetails []
|
||||||
|
|
||||||
stagedDetails' :: [CommandParam] -> [RawFilePath] -> Repo -> IO ([StagedDetails], IO Bool)
|
stagedDetails' :: (S.ByteString -> Maybe t) -> [CommandParam] -> [RawFilePath] -> Repo -> IO ([t], IO Bool)
|
||||||
stagedDetails' ps l repo = guardSafeForLsFiles repo $ do
|
stagedDetails' parser ps l repo = guardSafeForLsFiles repo $ do
|
||||||
(ls, cleanup) <- pipeNullSplit' params repo
|
(ls, cleanup) <- pipeNullSplit' params repo
|
||||||
return (mapMaybe parseStagedDetails ls, cleanup)
|
return (mapMaybe parser ls, cleanup)
|
||||||
where
|
where
|
||||||
params = Param "ls-files" : Param "--stage" : Param "-z" : ps ++
|
params = Param "ls-files" : Param "--stage" : Param "-z" : ps ++
|
||||||
Param "--" : map (File . fromRawFilePath) l
|
Param "--" : map (File . fromRawFilePath) l
|
||||||
|
|
|
@ -94,12 +94,12 @@ knownUrls = do
|
||||||
Annex.Branch.commit =<< Annex.Branch.commitMessage
|
Annex.Branch.commit =<< Annex.Branch.commitMessage
|
||||||
Annex.Branch.withIndex $ do
|
Annex.Branch.withIndex $ do
|
||||||
top <- fromRepo Git.repoPath
|
top <- fromRepo Git.repoPath
|
||||||
(l, cleanup) <- inRepo $ Git.LsFiles.stagedDetails [top]
|
(l, cleanup) <- inRepo $ Git.LsFiles.inRepoDetails [] [top]
|
||||||
r <- mapM getkeyurls l
|
r <- mapM getkeyurls l
|
||||||
void $ liftIO cleanup
|
void $ liftIO cleanup
|
||||||
return $ concat r
|
return $ concat r
|
||||||
where
|
where
|
||||||
getkeyurls (f, s, _, _) = case urlLogFileKey f of
|
getkeyurls (f, s, _) = case urlLogFileKey f of
|
||||||
Just k -> zip (repeat k) <$> geturls s
|
Just k -> zip (repeat k) <$> geturls s
|
||||||
Nothing -> return []
|
Nothing -> return []
|
||||||
geturls logsha =
|
geturls logsha =
|
||||||
|
|
|
@ -110,11 +110,11 @@ convertDirect = do
|
||||||
upgradeDirectWorkTree :: Annex ()
|
upgradeDirectWorkTree :: Annex ()
|
||||||
upgradeDirectWorkTree = do
|
upgradeDirectWorkTree = do
|
||||||
top <- fromRepo Git.repoPath
|
top <- fromRepo Git.repoPath
|
||||||
(l, clean) <- inRepo $ Git.LsFiles.stagedDetails [top]
|
(l, clean) <- inRepo $ Git.LsFiles.inRepoDetails [] [top]
|
||||||
forM_ l go
|
forM_ l go
|
||||||
void $ liftIO clean
|
void $ liftIO clean
|
||||||
where
|
where
|
||||||
go (f, _sha, mode, _stagenum) | isSymLink mode = do
|
go (f, _sha, mode) | isSymLink mode = do
|
||||||
-- Cannot use lookupFile here, as we're in between direct
|
-- Cannot use lookupFile here, as we're in between direct
|
||||||
-- mode and v6.
|
-- mode and v6.
|
||||||
mk <- catKeyFile f
|
mk <- catKeyFile f
|
||||||
|
|
|
@ -13,10 +13,7 @@ Probably that extra round trip means the performance improvement will not
|
||||||
be as good as --all's was, but it could still be significant.
|
be as good as --all's was, but it could still be significant.
|
||||||
|
|
||||||
> Actually, the key lookup could use the same --buffer trick!
|
> Actually, the key lookup could use the same --buffer trick!
|
||||||
> Although this would need a way to use git ls-files to get the sha of each
|
> Use inRepoDetails to list files and shas, pass through cat-file to get keys,
|
||||||
> file, and the only way I can find is --stage, which lists the file
|
> and then pass the location log for each key through cat-file to precache logs.
|
||||||
> repeatedly when there's a merge conflict. If that can be finessed somehow,
|
|
||||||
> pass the file sha through cat-file to get key, and then pass the location
|
|
||||||
> log for the key through cat-file to precache logs.
|
|
||||||
|
|
||||||
--[[Joey]]
|
--[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue