summaryrefslogtreecommitdiff
path: root/Command/Sync.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Command/Sync.hs')
-rw-r--r--Command/Sync.hs53
1 files changed, 38 insertions, 15 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index f7410112e..7a034bfa4 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -15,6 +15,8 @@ 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
import qualified Git.LsFiles as LsFiles
@@ -28,7 +30,6 @@ import qualified Remote.Git
import Types.Key
import Config
-import qualified Data.ByteString.Lazy as L
import Data.Hash.MD5
def :: [Command]
@@ -78,14 +79,20 @@ syncRemotes rs = ifM (Annex.getState Annex.fast) ( nub <$> pickfast , wanted )
fastest = fromMaybe [] . headMaybe . Remote.byCost
commit :: CommandStart
-commit = do
- showStart "commit" ""
- next $ next $ do
+commit = next $ next $ do
+ ifM isDirect
+ ( ifM stageDirect
+ ( runcommit [] , return True )
+ , runcommit [Param "-a"]
+ )
+ where
+ runcommit ps = do
+ showStart "commit" ""
showOutput
Annex.Branch.commit "update"
-- Commit will fail when the tree is clean, so ignore failure.
- _ <- inRepo $ Git.Command.runBool "commit"
- [Param "-a", Param "-m", Param "git-annex automatic sync"]
+ _ <- inRepo $ Git.Command.runBool "commit" $ ps ++
+ [Param "-m", Param "git-annex automatic sync"]
return True
mergeLocal :: Git.Ref -> CommandStart
@@ -172,13 +179,31 @@ 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. -}
mergeFrom :: Git.Ref -> Annex Bool
-mergeFrom branch = do
- showOutput
- ok <- inRepo $ Git.Merge.mergeNonInteractive branch
- if ok
- then return ok
- else resolveMerge
+mergeFrom branch = 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
+ godirect currbranch = do
+ old <- inRepo $ Git.Ref.sha currbranch
+ r <- go
+ new <- inRepo $ Git.Ref.sha currbranch
+ case (old, new) of
+ (Just oldsha, Just newsha) -> do
+ updateAssociatedFiles oldsha newsha
+ _ -> noop
+ return r
{- Resolves a conflicted merge. It's important that any conflicts be
- resolved in a way that itself avoids later merge conflicts, since
@@ -240,9 +265,7 @@ resolveMerge' u
case msha of
Nothing -> a Nothing
Just sha -> do
- key <- fileKey . takeFileName
- . encodeW8 . L.unpack
- <$> catObject sha
+ key <- catKey sha
maybe (return False) (a . Just) key
{- The filename to use when resolving a conflicted merge of a file,