import Annex.Branch.Transitions (filterBranch, FileTransition(..))
import Annex.HashObject
import Annex.Tmp
+import Annex.SpecialRemote.Config
+import Types.ProposedAccepted
import Logs
+import Logs.Remote
import Git.Types
import Git.FilePath
import Git.Index
import qualified Git.Branch as Git
import Utility.RawFilePath
+import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.ByteString.Lazy as L
import Data.ByteString.Builder
)
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
get (Include v) = Include <$> getParsed v
get (Exclude v) = Exclude <$> getParsed v
get IncludeAll = pure IncludeAll
-mkUUIDMatcher' :: [IncludeExclude UUID] -> (UUID -> Bool)
-mkUUIDMatcher' l = \u ->
- (S.member (Include u) includes || S.member IncludeAll includes)
+mkUUIDMatcher' :: M.Map UUID UUID -> [IncludeExclude UUID] -> (UUID -> Bool)
+mkUUIDMatcher' sameasmap l = \u ->
+ 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
+ && maybe True (\u' -> S.notMember (Exclude u') excludes) sameas
where
- (includes, excludes) = S.partition isInclude (S.fromList l)
+ (includes, excludes) = (S.partition isInclude (S.fromList l))
seek :: FilterBranchOptions -> CommandSeek
seek o = withOtherTmp $ \tmpdir -> do
-- Add repository configs for all repositories that are
-- being included.
- -- TODO need to include configs for sameas remotes
forM_ topLevelUUIDBasedLogs $ \f ->
filterbanch repoconfigmatcher f
=<< Annex.Branch.get f
multiple times.
Note that, when the repository contains information about a private
-repository (due to `annex.private` being set, or `--private` being used
-with [[git-annex-initremote](1)), that private information will be included
-when allowed by the options, even though it is not recorded on the git-annex
+repository (due to `annex.private` being set, or `git-annex initremote
+--private` being used), that private information will be included when
+allowed by the options, even though it is not recorded on the git-annex
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
* `path`