diff options
author | Joey Hess <joey@kitenet.net> | 2012-12-18 15:04:44 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-12-18 15:04:44 -0400 |
commit | 10d77d95f454a2fb2806c031a14344dd7cdea006 (patch) | |
tree | b9ba63e2f844031d4fd1d8248e5b01e7b5be7902 /Command | |
parent | 19e46a374225bc37131454774f20da4c6a7779d9 (diff) |
direct mode merging works!
Automatic merge resoltion code needs to be fixed to preserve objects from
direct mode files.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Direct.hs | 25 | ||||
-rw-r--r-- | Command/Sync.hs | 34 |
2 files changed, 22 insertions, 37 deletions
diff --git a/Command/Direct.hs b/Command/Direct.hs index 598a7b4b3..991930c38 100644 --- a/Command/Direct.hs +++ b/Command/Direct.hs @@ -13,8 +13,7 @@ import qualified Git import qualified Git.Command import qualified Git.LsFiles import Config -import Annex.Content -import Annex.Content.Direct +import Annex.Direct def :: [Command] def = [command "direct" paramNothing seek "switch repository to direct mode"] @@ -41,25 +40,13 @@ perform = do void $ liftIO clean next cleanup where - {- Walk tree from top and move all present objects to the - - files that link to them, while updating direct mode mappings. -} go = whenAnnexed $ \f (k, _) -> do - loc <- inRepo $ gitAnnexLocation k - createContentDir loc -- thaws directory too - locs <- filter (/= f) <$> addAssociatedFile k f - case locs of - [] -> whenM (liftIO $ doesFileExist loc) $ do - {- Move content from annex to direct file. -} + r <- toDirect k f + case r of + Nothing -> noop + Just a -> do showStart "direct" f - updateCache k loc - thawContent loc - liftIO $ replaceFile f $ moveFile loc - showEndOk - (loc':_) -> do - {- Another direct file has the content, so - - hard link to it. -} - showStart "direct" f - liftIO $ replaceFile f $ createLink loc' + a showEndOk return Nothing diff --git a/Command/Sync.hs b/Command/Sync.hs index 7a034bfa4..2d1b2fb9c 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -15,7 +15,6 @@ import qualified Annex import qualified Annex.Branch import qualified Annex.Queue import Annex.Content -import Annex.Content.Direct import Annex.Direct import Annex.CatFile import qualified Git.Command @@ -179,31 +178,30 @@ mergeAnnex = do void $ Annex.Branch.forceUpdate stop -{- Merges from a branch into the current branch. - - - - In direct mode, updates associated files mappings for the files that - - were changed by the merge. -} +{- Merges from a branch into the current branch. -} mergeFrom :: Git.Ref -> Annex Bool -mergeFrom branch = ifM isDirect - ( maybe go godirect =<< inRepo Git.Branch.current - , go - ) +mergeFrom branch = do + showOutput + ifM isDirect + ( maybe go godirect =<< inRepo Git.Branch.current + , go + ) where - go = do - showOutput - ok <- inRepo $ Git.Merge.mergeNonInteractive branch - if ok - then return ok - else resolveMerge + go = runmerge $ inRepo $ Git.Merge.mergeNonInteractive branch godirect currbranch = do old <- inRepo $ Git.Ref.sha currbranch - r <- go + d <- fromRepo gitAnnexMergeDir + r <- runmerge $ inRepo $ mergeDirect d branch new <- inRepo $ Git.Ref.sha currbranch case (old, new) of - (Just oldsha, Just newsha) -> do - updateAssociatedFiles oldsha newsha + (Just oldsha, Just newsha) -> + mergeDirectCleanup d oldsha newsha _ -> noop return r + runmerge a = ifM (a) + ( return True + , resolveMerge + ) {- Resolves a conflicted merge. It's important that any conflicts be - resolved in a way that itself avoids later merge conflicts, since |