sync --content now supports --hide-missing adjusted branches

This relies on git ls-files --with-tree, which I'm using in a way that
its man page does not document. Hm. I emailed the git list to try to get
the docs improved, but at least the git test suite does test the same
kind of use case I'm using here.

Performance impact when not in an adjusted branch is limited to some
additional MVar accesses, and a single git call to determine the name of
the current branch. So very minimal.

When in an adjusted branch, the performance impact is
in Annex.WorkTree.lookupFile, which starts doing an equal amount of work
for files that didn't exist as it already did for files that were
unlocked.

This commit was sponsored by Jochen Bartl on Patreon.
This commit is contained in:
Joey Hess 2018-10-19 17:51:25 -04:00
parent 8be5a7269a
commit 4a788fbb3b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
9 changed files with 89 additions and 31 deletions

View file

@ -556,26 +556,35 @@ seekSyncContent o rs currbranch = do
bloom <- case keyOptions o of
Just WantAllKeys -> Just <$> genBloomFilter (seekworktree mvar [])
_ -> case currbranch of
(origbranch, Just adj) | adjustmentHidesFiles adj -> do
seekbranch origbranch (contentOfOption o)
pure Nohing
_ = do
(Just origbranch, Just adj) | adjustmentHidesFiles adj -> do
l <- workTreeItems' (AllowHidden True) (contentOfOption o)
seekincludinghidden origbranch mvar l (const noop)
pure Nothing
_ -> do
l <- workTreeItems (contentOfOption o)
seekworktree mvar l (const noop)
pure Nothing
withKeyOptions' (keyOptions o) False
(return (seekkeys mvar bloom))
(return (gokey mvar bloom))
(const noop)
[]
finishCommandActions
liftIO $ not <$> isEmptyMVar mvar
where
seekworktree mvar l bloomfeeder = seekHelper LsFiles.inRepo l >>=
mapM_ (\f -> ifAnnexed f (go (Right bloomfeeder) mvar (AssociatedFile (Just f))) noop)
seekworktree mvar l bloomfeeder =
seekHelper LsFiles.inRepo l
>>= gofiles bloomfeeder mvar
seekbranch origbranch l =
seekincludinghidden origbranch mvar l bloomfeeder =
seekHelper (LsFiles.inRepoOrBranch origbranch) l
>>= gofiles bloomfeeder mvar
seekkeys mvar bloom (k, _) = go (Left bloom) mvar (AssociatedFile Nothing) k
gofiles bloomfeeder mvar = mapM_ $ \f ->
ifAnnexed f
(go (Right bloomfeeder) mvar (AssociatedFile (Just f)))
noop
gokey mvar bloom (k, _) = go (Left bloom) mvar (AssociatedFile Nothing) k
go ebloom mvar af k = commandAction $ do
whenM (syncFile ebloom rs af k) $