record only subtree in export db and log after importing a subtree

This commit is contained in:
Joey Hess 2019-03-11 13:44:23 -04:00
parent e46e40bf05
commit e1fdc8b374
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 13 additions and 11 deletions

View file

@ -107,9 +107,7 @@ buildImportCommit remote importtreeconfig importcommitconfig importable =
mkcommits origtree basecommit imported >>= \case mkcommits origtree basecommit imported >>= \case
Nothing -> return Nothing Nothing -> return Nothing
Just finalcommit -> do Just finalcommit -> do
updateexportdb finaltree updatestate finaltree
oldexport <- updateexportlog finaltree
updatelocationlog oldexport finaltree
return (Just finalcommit) return (Just finalcommit)
mkcommits origtree basecommit (History importedtree hs) = do mkcommits origtree basecommit (History importedtree hs) = do
@ -127,6 +125,18 @@ buildImportCommit remote importtreeconfig importcommitconfig importable =
importedtree importedtree
return (Just commit) return (Just commit)
updatestate committedtree = do
importedtree <- case subdir of
Nothing -> pure committedtree
Just dir ->
let subtreeref = Ref $
fromRef committedtree ++ ":" ++ getTopFilePath dir
in fromMaybe emptyTree
<$> inRepo (Git.Ref.tree subtreeref)
updateexportdb importedtree
oldexport <- updateexportlog importedtree
updatelocationlog oldexport importedtree
updateexportdb importedtree = do updateexportdb importedtree = do
db <- Export.openDb (Remote.uuid remote) db <- Export.openDb (Remote.uuid remote)
Export.writeLockDbWhile db $ do Export.writeLockDbWhile db $ do

View file

@ -10,14 +10,6 @@ this.
## implementation notes ## implementation notes
* When doing `git annex export master:subdir` followed by
`git annex import master:subdir` which imports a new file,
followed by merging the import and re-export, it does unncessary
work deleting stuff not in the subdir from the remote.
Why? Seems that the import recorded the exported tree wrong, using the
whole tree and not the sub-tree.
* Does sync --content with remote.name.annex-tracking-branch=master:subdir * Does sync --content with remote.name.annex-tracking-branch=master:subdir
export the right tree and update the remote tracking branch right? export the right tree and update the remote tracking branch right?
Does it import correctly? Does it import correctly?