include info for sameas repos
It's not currently possible to exclude a sameas repo using its annex-config-uuid. (Remote.nameToUUID rejects them). Since there's no real documented way to learn those, this seems ok, at least for now. Also it avoids the problem of someone excluding the parent but including the sameas, which would probably make the sameas repo not usable when using the filtered branch.
This commit is contained in:
parent
984034f335
commit
2420910ab8
2 changed files with 25 additions and 9 deletions
|
@ -15,7 +15,10 @@ import qualified Annex.Branch
|
||||||
import Annex.Branch.Transitions (filterBranch, FileTransition(..))
|
import Annex.Branch.Transitions (filterBranch, FileTransition(..))
|
||||||
import Annex.HashObject
|
import Annex.HashObject
|
||||||
import Annex.Tmp
|
import Annex.Tmp
|
||||||
|
import Annex.SpecialRemote.Config
|
||||||
|
import Types.ProposedAccepted
|
||||||
import Logs
|
import Logs
|
||||||
|
import Logs.Remote
|
||||||
import Git.Types
|
import Git.Types
|
||||||
import Git.FilePath
|
import Git.FilePath
|
||||||
import Git.Index
|
import Git.Index
|
||||||
|
@ -25,6 +28,7 @@ import qualified Git.LsTree as LsTree
|
||||||
import qualified Git.Branch as Git
|
import qualified Git.Branch as Git
|
||||||
import Utility.RawFilePath
|
import Utility.RawFilePath
|
||||||
|
|
||||||
|
import qualified Data.Map as M
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import qualified Data.ByteString.Lazy as L
|
import qualified Data.ByteString.Lazy as L
|
||||||
import Data.ByteString.Builder
|
import Data.ByteString.Builder
|
||||||
|
@ -91,18 +95,27 @@ parseRepositoryOption s h = parseUUIDOption <$> strOption
|
||||||
)
|
)
|
||||||
|
|
||||||
mkUUIDMatcher :: [IncludeExclude (DeferredParse UUID)] -> Annex (UUID -> Bool)
|
mkUUIDMatcher :: [IncludeExclude (DeferredParse UUID)] -> Annex (UUID -> Bool)
|
||||||
mkUUIDMatcher l = mkUUIDMatcher' <$> mapM get l
|
mkUUIDMatcher l = do
|
||||||
|
sameasmap <- M.mapMaybe
|
||||||
|
(toUUID . fromProposedAccepted <$$> M.lookup sameasUUIDField)
|
||||||
|
<$> remoteConfigMap
|
||||||
|
mkUUIDMatcher' sameasmap <$> mapM get l
|
||||||
where
|
where
|
||||||
get (Include v) = Include <$> getParsed v
|
get (Include v) = Include <$> getParsed v
|
||||||
get (Exclude v) = Exclude <$> getParsed v
|
get (Exclude v) = Exclude <$> getParsed v
|
||||||
get IncludeAll = pure IncludeAll
|
get IncludeAll = pure IncludeAll
|
||||||
|
|
||||||
mkUUIDMatcher' :: [IncludeExclude UUID] -> (UUID -> Bool)
|
mkUUIDMatcher' :: M.Map UUID UUID -> [IncludeExclude UUID] -> (UUID -> Bool)
|
||||||
mkUUIDMatcher' l = \u ->
|
mkUUIDMatcher' sameasmap l = \u ->
|
||||||
(S.member (Include u) includes || S.member IncludeAll includes)
|
let sameas = M.lookup u sameasmap
|
||||||
|
in ( S.member (Include u) includes
|
||||||
|
|| S.member IncludeAll includes
|
||||||
|
|| maybe False (\u' -> S.member (Include u') includes) sameas
|
||||||
|
)
|
||||||
&& S.notMember (Exclude u) excludes
|
&& S.notMember (Exclude u) excludes
|
||||||
|
&& maybe True (\u' -> S.notMember (Exclude u') excludes) sameas
|
||||||
where
|
where
|
||||||
(includes, excludes) = S.partition isInclude (S.fromList l)
|
(includes, excludes) = (S.partition isInclude (S.fromList l))
|
||||||
|
|
||||||
seek :: FilterBranchOptions -> CommandSeek
|
seek :: FilterBranchOptions -> CommandSeek
|
||||||
seek o = withOtherTmp $ \tmpdir -> do
|
seek o = withOtherTmp $ \tmpdir -> do
|
||||||
|
@ -159,7 +172,6 @@ seek o = withOtherTmp $ \tmpdir -> do
|
||||||
|
|
||||||
-- Add repository configs for all repositories that are
|
-- Add repository configs for all repositories that are
|
||||||
-- being included.
|
-- being included.
|
||||||
-- TODO need to include configs for sameas remotes
|
|
||||||
forM_ topLevelUUIDBasedLogs $ \f ->
|
forM_ topLevelUUIDBasedLogs $ \f ->
|
||||||
filterbanch repoconfigmatcher f
|
filterbanch repoconfigmatcher f
|
||||||
=<< Annex.Branch.get f
|
=<< Annex.Branch.get f
|
||||||
|
|
|
@ -26,11 +26,15 @@ branch. Use options to specify what to include. All options can be specified
|
||||||
multiple times.
|
multiple times.
|
||||||
|
|
||||||
Note that, when the repository contains information about a private
|
Note that, when the repository contains information about a private
|
||||||
repository (due to `annex.private` being set, or `--private` being used
|
repository (due to `annex.private` being set, or `git-annex initremote
|
||||||
with [[git-annex-initremote](1)), that private information will be included
|
--private` being used), that private information will be included when
|
||||||
when allowed by the options, even though it is not recorded on the git-annex
|
allowed by the options, even though it is not recorded on the git-annex
|
||||||
branch.
|
branch.
|
||||||
|
|
||||||
|
When a repository was created with `git annex initremote --sameas=foo`,
|
||||||
|
its information will be included when the information for foo is,
|
||||||
|
and excluded when foo is excluded.
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
|
|
||||||
* `path`
|
* `path`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue