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
|
@ -104,12 +104,12 @@ seek o@(LocalImportOptions {}) = allowConcurrentOutput $ do
|
|||
`withPathContents` importFiles o
|
||||
seek o@(RemoteImportOptions {}) = allowConcurrentOutput $ do
|
||||
r <- getParsed (importFromRemote o)
|
||||
unlessM (Remote.isImportSupported r) $
|
||||
giveup "That remote does not support imports."
|
||||
subdir <- maybe
|
||||
(pure Nothing)
|
||||
(Just <$$> inRepo . toTopFilePath)
|
||||
(importToSubDir o)
|
||||
unlessM (Remote.isImportSupported remote) $
|
||||
giveup "That remote does not support imports."
|
||||
seekRemote r (importToBranch o) subdir
|
||||
|
||||
startLocal :: GetFileMatcher -> DuplicateMode -> (FilePath, FilePath) -> CommandStart
|
||||
|
|
|
@ -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
|
||||
|
@ -189,9 +191,11 @@ seek o = allowConcurrentOutput $ do
|
|||
]
|
||||
|
||||
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),
|
||||
|
|
|
@ -10,6 +10,16 @@ this.
|
|||
|
||||
## implementation notes
|
||||
|
||||
* renameExport is disabled in a way that makes export tree
|
||||
complain unncessarily verbosely. Perhaps change renameExport
|
||||
to a Maybe so it can know when it's not available.
|
||||
|
||||
* Does export of master:subdir update the remote tracking branch right?
|
||||
|
||||
* Does sync --content with remote.name.annex-tracking-branch=master:subdir
|
||||
export the right tree and update the remote tracking branch right?
|
||||
Does it import correctly?
|
||||
|
||||
* Need to support annex-tracking-branch configuration, which documentation
|
||||
says makes git-annex sync and assistant do imports.
|
||||
|
||||
|
|
Loading…
Reference in a new issue