bug
This commit is contained in:
parent
d4ce072452
commit
aa2f4bd810
5 changed files with 46 additions and 46 deletions
15
Annex.hs
15
Annex.hs
|
@ -14,9 +14,18 @@ import qualified GitRepo as Git
|
||||||
import Types
|
import Types
|
||||||
import qualified BackendTypes as Backend
|
import qualified BackendTypes as Backend
|
||||||
|
|
||||||
-- constructor
|
{- Create and returns an Annex state object for the specified git repo.
|
||||||
new :: Git.Repo -> AnnexState
|
-}
|
||||||
new g = Backend.AnnexState { Backend.repo = g, Backend.backends = [] }
|
new :: Git.Repo -> IO AnnexState
|
||||||
|
new g = do
|
||||||
|
let s = Backend.AnnexState { Backend.repo = g, Backend.backends = [] }
|
||||||
|
(_,s') <- Annex.run s (prep g)
|
||||||
|
return s'
|
||||||
|
where
|
||||||
|
prep g = do
|
||||||
|
-- read git config and update state
|
||||||
|
g' <- liftIO $ Git.configRead g
|
||||||
|
Annex.gitRepoChange g'
|
||||||
|
|
||||||
-- performs an action in the Annex monad
|
-- performs an action in the Annex monad
|
||||||
run state action = runStateT (action) state
|
run state action = runStateT (action) state
|
||||||
|
|
|
@ -52,7 +52,7 @@ storeFileKey :: FilePath -> Annex (Maybe (Key, Backend))
|
||||||
storeFileKey file = do
|
storeFileKey file = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
let relfile = Git.relative g file
|
let relfile = Git.relative g file
|
||||||
b <- Annex.backends
|
b <- backendList
|
||||||
storeFileKey' b file relfile
|
storeFileKey' b file relfile
|
||||||
storeFileKey' [] _ _ = return Nothing
|
storeFileKey' [] _ _ = return Nothing
|
||||||
storeFileKey' (b:bs) file relfile = do
|
storeFileKey' (b:bs) file relfile = do
|
||||||
|
|
|
@ -14,6 +14,7 @@ import Locations
|
||||||
import qualified Remotes
|
import qualified Remotes
|
||||||
import qualified GitRepo as Git
|
import qualified GitRepo as Git
|
||||||
import Utility
|
import Utility
|
||||||
|
import Core
|
||||||
|
|
||||||
backend = Backend {
|
backend = Backend {
|
||||||
name = "file",
|
name = "file",
|
||||||
|
|
27
Core.hs
27
Core.hs
|
@ -6,33 +6,20 @@ import System.IO
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import Control.Monad.State (liftIO)
|
import Control.Monad.State (liftIO)
|
||||||
import Types
|
import Types
|
||||||
import BackendList
|
|
||||||
import Locations
|
import Locations
|
||||||
import UUID
|
import UUID
|
||||||
import qualified GitRepo as Git
|
import qualified GitRepo as Git
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
|
|
||||||
{- Create and returns an Annex state object.
|
|
||||||
- Examines and prepares the git repo.
|
|
||||||
-}
|
|
||||||
start :: IO AnnexState
|
|
||||||
start = do
|
|
||||||
g <- Git.repoFromCwd
|
|
||||||
let s = Annex.new g
|
|
||||||
(_,s') <- Annex.run s (prep g)
|
|
||||||
return s'
|
|
||||||
where
|
|
||||||
prep g = do
|
|
||||||
-- setup git and read its config; update state
|
|
||||||
g' <- liftIO $ Git.configRead g
|
|
||||||
Annex.gitRepoChange g'
|
|
||||||
liftIO $ gitSetup g'
|
|
||||||
prepUUID
|
|
||||||
|
|
||||||
{- Sets up a git repo for git-annex. May be called repeatedly. -}
|
{- Sets up a git repo for git-annex. May be called repeatedly. -}
|
||||||
gitSetup :: Git.Repo -> IO ()
|
gitSetup :: Annex ()
|
||||||
gitSetup repo = do
|
gitSetup = do
|
||||||
|
g <- Annex.gitRepo
|
||||||
|
liftIO $ setupattributes g
|
||||||
|
prepUUID
|
||||||
|
where
|
||||||
-- configure git to use union merge driver on state files
|
-- configure git to use union merge driver on state files
|
||||||
|
setupattributes repo = do
|
||||||
exists <- doesFileExist attributes
|
exists <- doesFileExist attributes
|
||||||
if (not exists)
|
if (not exists)
|
||||||
then do
|
then do
|
||||||
|
|
|
@ -7,12 +7,15 @@ import qualified Annex
|
||||||
import Types
|
import Types
|
||||||
import Core
|
import Core
|
||||||
import Commands
|
import Commands
|
||||||
|
import Annex
|
||||||
|
import qualified GitRepo as Git
|
||||||
|
|
||||||
main = do
|
main = do
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
actions <- argvToActions args
|
actions <- argvToActions args
|
||||||
state <- start
|
gitrepo <- Git.repoFromCwd
|
||||||
tryRun state actions
|
state <- new gitrepo
|
||||||
|
tryRun state (gitSetup:actions)
|
||||||
|
|
||||||
{- Runs a list of Annex actions. Catches exceptions, not stopping
|
{- Runs a list of Annex actions. Catches exceptions, not stopping
|
||||||
- if some error out, and propigates an overall error status at the end.
|
- if some error out, and propigates an overall error status at the end.
|
||||||
|
|
Loading…
Reference in a new issue