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
|
`withPathContents` importFiles o
|
||||||
seek o@(RemoteImportOptions {}) = allowConcurrentOutput $ do
|
seek o@(RemoteImportOptions {}) = allowConcurrentOutput $ do
|
||||||
r <- getParsed (importFromRemote o)
|
r <- getParsed (importFromRemote o)
|
||||||
|
unlessM (Remote.isImportSupported r) $
|
||||||
|
giveup "That remote does not support imports."
|
||||||
subdir <- maybe
|
subdir <- maybe
|
||||||
(pure Nothing)
|
(pure Nothing)
|
||||||
(Just <$$> inRepo . toTopFilePath)
|
(Just <$$> inRepo . toTopFilePath)
|
||||||
(importToSubDir o)
|
(importToSubDir o)
|
||||||
unlessM (Remote.isImportSupported remote) $
|
|
||||||
giveup "That remote does not support imports."
|
|
||||||
seekRemote r (importToBranch o) subdir
|
seekRemote r (importToBranch o) subdir
|
||||||
|
|
||||||
startLocal :: GetFileMatcher -> DuplicateMode -> (FilePath, FilePath) -> CommandStart
|
startLocal :: GetFileMatcher -> DuplicateMode -> (FilePath, FilePath) -> CommandStart
|
||||||
|
|
|
@ -39,6 +39,7 @@ import qualified Git.Merge
|
||||||
import qualified Git.Types as Git
|
import qualified Git.Types as Git
|
||||||
import qualified Git.Ref
|
import qualified Git.Ref
|
||||||
import qualified Git
|
import qualified Git
|
||||||
|
import Git.FilePath
|
||||||
import qualified Remote.Git
|
import qualified Remote.Git
|
||||||
import Config
|
import Config
|
||||||
import Config.GitConfig
|
import Config.GitConfig
|
||||||
|
@ -171,6 +172,7 @@ seek o = allowConcurrentOutput $ do
|
||||||
dataremotes <- filter (\r -> Remote.uuid r /= NoUUID)
|
dataremotes <- filter (\r -> Remote.uuid r /= NoUUID)
|
||||||
<$> filterM (not <$$> liftIO . getDynamicConfig . remoteAnnexIgnore . Remote.gitconfig) remotes
|
<$> filterM (not <$$> liftIO . getDynamicConfig . remoteAnnexIgnore . Remote.gitconfig) remotes
|
||||||
let exportremotes = filter (exportTree . Remote.config) dataremotes
|
let exportremotes = filter (exportTree . Remote.config) dataremotes
|
||||||
|
let importremotes = filter (importTree . Remote.config) dataremotes
|
||||||
|
|
||||||
if cleanupOption o
|
if cleanupOption o
|
||||||
then do
|
then do
|
||||||
|
@ -187,11 +189,13 @@ seek o = allowConcurrentOutput $ do
|
||||||
, map (withbranch . pullRemote o mergeConfig) gitremotes
|
, map (withbranch . pullRemote o mergeConfig) gitremotes
|
||||||
, [ mergeAnnex ]
|
, [ mergeAnnex ]
|
||||||
]
|
]
|
||||||
|
|
||||||
whenM shouldsynccontent $ do
|
whenM shouldsynccontent $ do
|
||||||
-- Send content to any exports first, in
|
mapM_ (withbranch . importRemote o mergeConfig) importremotes
|
||||||
-- case that lets content be dropped from
|
|
||||||
-- other repositories.
|
-- Send content to any exports before other
|
||||||
|
-- repositories, in case that lets content
|
||||||
|
-- be dropped from other repositories.
|
||||||
exportedcontent <- withbranch $
|
exportedcontent <- withbranch $
|
||||||
seekExportContent (Just o) exportremotes
|
seekExportContent (Just o) exportremotes
|
||||||
syncedcontent <- withbranch $
|
syncedcontent <- withbranch $
|
||||||
|
@ -225,10 +229,11 @@ mergeConfig :: [Git.Merge.MergeConfig]
|
||||||
mergeConfig =
|
mergeConfig =
|
||||||
[ Git.Merge.MergeNonInteractive
|
[ Git.Merge.MergeNonInteractive
|
||||||
-- In several situations, unrelated histories should be merged
|
-- In several situations, unrelated histories should be merged
|
||||||
-- together. This includes pairing in the assistant, and merging
|
-- together. This includes pairing in the assistant, merging
|
||||||
-- from a remote into a newly created direct mode repo.
|
-- 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
|
-- (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
|
, Git.Merge.MergeUnrelatedHistories
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -404,6 +409,23 @@ pullRemote o mergeconfig remote branch = stopUnless (pure $ pullOption o && want
|
||||||
[Param "fetch", Param $ Remote.name remote]
|
[Param "fetch", Param $ Remote.name remote]
|
||||||
wantpull = remoteAnnexPull (Remote.gitconfig 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.
|
{- The remote probably has both a master and a synced/master branch.
|
||||||
- Which to merge from? Well, the master has whatever latest changes
|
- Which to merge from? Well, the master has whatever latest changes
|
||||||
- were committed (or pushed changes, if this is a bare remote),
|
- were committed (or pushed changes, if this is a bare remote),
|
||||||
|
|
|
@ -10,6 +10,16 @@ this.
|
||||||
|
|
||||||
## implementation notes
|
## 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
|
* Need to support annex-tracking-branch configuration, which documentation
|
||||||
says makes git-annex sync and assistant do imports.
|
says makes git-annex sync and assistant do imports.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue