handle Annex.Branch.files with read-only unmerged git-annex branches
It would be difficult to make Annex.Branch.files query the unmerged
git-annex branches. Might be possible, similar to what was discussed in
7f6b2ca49c
but again I decided to make it
not do anything in that situation to start with before adding such a
complicated thing.
git-annex info uses it when getting info about a repostory. The choices
were to make that fail with an error, or display the info it can, and
change the output slightly for the bits of info it cannot access. While
that is a behavior change, and I want to avoid any behavior changes due
to unmerged git-annex branches in a read-only repo, displaying a message
that is not a number seems unlikely to break anything that was consuming
a number, any worse than throwing an exception would. Probably.
Also git-annex unused --from origin is made to throw an error, but
it would fail later anyway when trying to write to the unused log files.
Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
parent
7f6b2ca49c
commit
23a485498f
5 changed files with 61 additions and 38 deletions
|
@ -137,15 +137,17 @@ finishCheck (Unchecked a) = a
|
|||
-
|
||||
- Keys that have been marked as dead are not included.
|
||||
-}
|
||||
loggedKeys :: Annex ([Unchecked Key], IO Bool)
|
||||
loggedKeys :: Annex (Maybe ([Unchecked Key], IO Bool))
|
||||
loggedKeys = loggedKeys' (not <$$> checkDead)
|
||||
|
||||
loggedKeys' :: (Key -> Annex Bool) -> Annex ([Unchecked Key], IO Bool)
|
||||
loggedKeys' :: (Key -> Annex Bool) -> Annex (Maybe ([Unchecked Key], IO Bool))
|
||||
loggedKeys' check = do
|
||||
config <- Annex.getGitConfig
|
||||
(bfs, cleanup) <- Annex.Branch.files
|
||||
let l = mapMaybe (defercheck <$$> locationLogFileKey config) bfs
|
||||
return (l, cleanup)
|
||||
Annex.Branch.files >>= \case
|
||||
Nothing -> return Nothing
|
||||
Just (bfs, cleanup) -> do
|
||||
let l = mapMaybe (defercheck <$$> locationLogFileKey config) bfs
|
||||
return (Just (l, cleanup))
|
||||
where
|
||||
defercheck k = Unchecked $ ifM (check k)
|
||||
( return (Just k)
|
||||
|
@ -157,14 +159,15 @@ loggedKeys' check = do
|
|||
-
|
||||
- This does not stream well; use loggedKeysFor' for lazy streaming.
|
||||
-}
|
||||
loggedKeysFor :: UUID -> Annex [Key]
|
||||
loggedKeysFor u = do
|
||||
(l, cleanup) <- loggedKeysFor' u
|
||||
l' <- catMaybes <$> mapM finishCheck l
|
||||
liftIO $ void cleanup
|
||||
return l'
|
||||
loggedKeysFor :: UUID -> Annex (Maybe [Key])
|
||||
loggedKeysFor u = loggedKeysFor' u >>= \case
|
||||
Nothing -> return Nothing
|
||||
Just (l, cleanup) -> do
|
||||
l' <- catMaybes <$> mapM finishCheck l
|
||||
liftIO $ void cleanup
|
||||
return (Just l')
|
||||
|
||||
loggedKeysFor' :: UUID -> Annex ([Unchecked Key], IO Bool)
|
||||
loggedKeysFor' :: UUID -> Annex (Maybe ([Unchecked Key], IO Bool))
|
||||
loggedKeysFor' u = loggedKeys' isthere
|
||||
where
|
||||
isthere k = do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue