sync: import when annex-tracking-branch is configured
This works, and tested syncing both gets changes from a special remote and sends changes to it, keeping it fully in sync nicely! But have not tried it with a subdir configured.
This commit is contained in:
parent
ca1a3caaa8
commit
c755788256
3 changed files with 41 additions and 9 deletions
|
@ -39,6 +39,7 @@ import qualified Git.Merge
|
|||
import qualified Git.Types as Git
|
||||
import qualified Git.Ref
|
||||
import qualified Git
|
||||
import Git.FilePath
|
||||
import qualified Remote.Git
|
||||
import Config
|
||||
import Config.GitConfig
|
||||
|
@ -171,6 +172,7 @@ seek o = allowConcurrentOutput $ do
|
|||
dataremotes <- filter (\r -> Remote.uuid r /= NoUUID)
|
||||
<$> filterM (not <$$> liftIO . getDynamicConfig . remoteAnnexIgnore . Remote.gitconfig) remotes
|
||||
let exportremotes = filter (exportTree . Remote.config) dataremotes
|
||||
let importremotes = filter (importTree . Remote.config) dataremotes
|
||||
|
||||
if cleanupOption o
|
||||
then do
|
||||
|
@ -187,11 +189,13 @@ seek o = allowConcurrentOutput $ do
|
|||
, map (withbranch . pullRemote o mergeConfig) gitremotes
|
||||
, [ mergeAnnex ]
|
||||
]
|
||||
|
||||
|
||||
whenM shouldsynccontent $ do
|
||||
-- Send content to any exports first, in
|
||||
-- case that lets content be dropped from
|
||||
-- other repositories.
|
||||
mapM_ (withbranch . importRemote o mergeConfig) importremotes
|
||||
|
||||
-- Send content to any exports before other
|
||||
-- repositories, in case that lets content
|
||||
-- be dropped from other repositories.
|
||||
exportedcontent <- withbranch $
|
||||
seekExportContent (Just o) exportremotes
|
||||
syncedcontent <- withbranch $
|
||||
|
@ -225,10 +229,11 @@ mergeConfig :: [Git.Merge.MergeConfig]
|
|||
mergeConfig =
|
||||
[ Git.Merge.MergeNonInteractive
|
||||
-- In several situations, unrelated histories should be merged
|
||||
-- together. This includes pairing in the assistant, and merging
|
||||
-- from a remote into a newly created direct mode repo.
|
||||
-- together. This includes pairing in the assistant, merging
|
||||
-- from a remote into a newly created direct mode repo,
|
||||
-- and an initial merge from an import from a special remote.
|
||||
-- (Once direct mode is removed, this could be changed, so only
|
||||
-- the assistant uses it.)
|
||||
-- the assistant and import from special remotes use it.)
|
||||
, Git.Merge.MergeUnrelatedHistories
|
||||
]
|
||||
|
||||
|
@ -404,6 +409,23 @@ pullRemote o mergeconfig remote branch = stopUnless (pure $ pullOption o && want
|
|||
[Param "fetch", Param $ Remote.name remote]
|
||||
wantpull = remoteAnnexPull (Remote.gitconfig remote)
|
||||
|
||||
importRemote :: SyncOptions -> [Git.Merge.MergeConfig] -> Remote -> CurrBranch -> CommandSeek
|
||||
importRemote o mergeconfig remote currbranch
|
||||
| not (pullOption o) || not wantpull = noop
|
||||
| otherwise = case remoteAnnexTrackingBranch (Remote.gitconfig remote) of
|
||||
Nothing -> noop
|
||||
Just tb -> do
|
||||
let (b, s) = separate (== ':') (Git.fromRef tb)
|
||||
let branch = Git.Ref b
|
||||
let subdir = if null s
|
||||
then Nothing
|
||||
else Just (asTopFilePath s)
|
||||
Command.Import.seekRemote remote branch subdir
|
||||
void $ mergeRemote remote currbranch mergeconfig
|
||||
(resolveMergeOverride o)
|
||||
where
|
||||
wantpull = remoteAnnexPull (Remote.gitconfig remote)
|
||||
|
||||
{- The remote probably has both a master and a synced/master branch.
|
||||
- Which to merge from? Well, the master has whatever latest changes
|
||||
- were committed (or pushed changes, if this is a bare remote),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue