make views work with v6 unlocked files
Have to only use the view index in one place; lookupFile was failing for unlocked files because it was run using the view index, which was empty.
This commit is contained in:
parent
49fca49991
commit
60c36ef6ba
1 changed files with 22 additions and 24 deletions
|
@ -336,8 +336,7 @@ applyView' mkviewedfile getfilemetadata view = do
|
||||||
top <- fromRepo Git.repoPath
|
top <- fromRepo Git.repoPath
|
||||||
(l, clean) <- inRepo $ Git.LsFiles.inRepo [top]
|
(l, clean) <- inRepo $ Git.LsFiles.inRepo [top]
|
||||||
liftIO . nukeFile =<< fromRepo gitAnnexViewIndex
|
liftIO . nukeFile =<< fromRepo gitAnnexViewIndex
|
||||||
genViewBranch view $ do
|
uh <- withViewIndex $ inRepo Git.UpdateIndex.startUpdateIndex
|
||||||
uh <- inRepo Git.UpdateIndex.startUpdateIndex
|
|
||||||
hasher <- inRepo hashObjectStart
|
hasher <- inRepo hashObjectStart
|
||||||
forM_ l $ \f -> do
|
forM_ l $ \f -> do
|
||||||
relf <- getTopFilePath <$> inRepo (toTopFilePath f)
|
relf <- getTopFilePath <$> inRepo (toTopFilePath f)
|
||||||
|
@ -346,6 +345,7 @@ applyView' mkviewedfile getfilemetadata view = do
|
||||||
hashObjectStop hasher
|
hashObjectStop hasher
|
||||||
void $ stopUpdateIndex uh
|
void $ stopUpdateIndex uh
|
||||||
void clean
|
void clean
|
||||||
|
genViewBranch view
|
||||||
where
|
where
|
||||||
genviewedfiles = viewedFiles view mkviewedfile -- enables memoization
|
genviewedfiles = viewedFiles view mkviewedfile -- enables memoization
|
||||||
go uh hasher f (Just k) = do
|
go uh hasher f (Just k) = do
|
||||||
|
@ -408,24 +408,22 @@ withViewChanges addmeta removemeta = do
|
||||||
handlechange item a = maybe noop
|
handlechange item a = maybe noop
|
||||||
(void . commandAction . a (getTopFilePath $ DiffTree.file item))
|
(void . commandAction . a (getTopFilePath $ DiffTree.file item))
|
||||||
|
|
||||||
{- Generates a branch for a view. This is done using a different index
|
{- Runs an action using the view index file.
|
||||||
- file. An action is run to stage the files that will be in the branch.
|
- Note that the file does not necessarily exist, or can contain
|
||||||
- Then a commit is made, to the view branch. The view branch is not
|
- info staged for an old view. -}
|
||||||
|
withViewIndex :: Annex a -> Annex a
|
||||||
|
withViewIndex a = do
|
||||||
|
f <- fromRepo gitAnnexViewIndex
|
||||||
|
withIndexFile f a
|
||||||
|
|
||||||
|
{- Generates a branch for a view, using the view index file
|
||||||
|
- to make a commit to the view branch. The view branch is not
|
||||||
- checked out, but entering it will display the view. -}
|
- checked out, but entering it will display the view. -}
|
||||||
genViewBranch :: View -> Annex () -> Annex Git.Branch
|
genViewBranch :: View -> Annex Git.Branch
|
||||||
genViewBranch view a = withIndex $ do
|
genViewBranch view = withViewIndex $ do
|
||||||
a
|
|
||||||
let branch = branchView view
|
let branch = branchView view
|
||||||
void $ inRepo $ Git.Branch.commit Git.Branch.AutomaticCommit True (fromRef branch) branch []
|
void $ inRepo $ Git.Branch.commit Git.Branch.AutomaticCommit True (fromRef branch) branch []
|
||||||
return branch
|
return branch
|
||||||
|
|
||||||
{- Runs an action using the view index file.
|
|
||||||
- Note that the file does not necessarily exist, or can contain
|
|
||||||
- info staged for an old view. -}
|
|
||||||
withIndex :: Annex a -> Annex a
|
|
||||||
withIndex a = do
|
|
||||||
f <- fromRepo gitAnnexViewIndex
|
|
||||||
withIndexFile f a
|
|
||||||
|
|
||||||
withCurrentView :: (View -> Annex a) -> Annex a
|
withCurrentView :: (View -> Annex a) -> Annex a
|
||||||
withCurrentView a = maybe (error "Not in a view.") a =<< currentView
|
withCurrentView a = maybe (error "Not in a view.") a =<< currentView
|
||||||
|
|
Loading…
Add table
Reference in a new issue