Add annex.version, which will be used to automate upgrades.
This commit is contained in:
parent
f03adec793
commit
ab4de45491
5 changed files with 32 additions and 12 deletions
12
Annex.hs
12
Annex.hs
|
@ -19,7 +19,8 @@ module Annex (
|
|||
flagGet,
|
||||
Flag(..),
|
||||
queue,
|
||||
queueGet
|
||||
queueGet,
|
||||
setConfig
|
||||
) where
|
||||
|
||||
import Control.Monad.State
|
||||
|
@ -118,3 +119,12 @@ queueGet :: Annex GitQueue.Queue
|
|||
queueGet = do
|
||||
state <- get
|
||||
return (Internals.repoqueue state)
|
||||
|
||||
{- Changes a git config setting in both internal state and .git/config -}
|
||||
setConfig :: String -> String -> Annex ()
|
||||
setConfig key value = do
|
||||
g <- Annex.gitRepo
|
||||
liftIO $ Git.run g ["config", key, value]
|
||||
-- re-read git config and update the repo's state
|
||||
g' <- liftIO $ Git.configRead g Nothing
|
||||
Annex.gitRepoChange g'
|
||||
|
|
16
Core.hs
16
Core.hs
|
@ -46,6 +46,7 @@ tryRun' _ errnum [] =
|
|||
startup :: Annex Bool
|
||||
startup = do
|
||||
prepUUID
|
||||
autoUpgrade
|
||||
return True
|
||||
|
||||
{- When git-annex is done, it runs this. -}
|
||||
|
@ -151,6 +152,21 @@ getViaTmp key action = do
|
|||
-- to resume its transfer
|
||||
return False
|
||||
|
||||
{- Uses the annex.version git config setting to automate upgrades. -}
|
||||
autoUpgrade :: Annex ()
|
||||
autoUpgrade = do
|
||||
g <- Annex.gitRepo
|
||||
|
||||
case Git.configGet g field "0" of
|
||||
"0" -> do -- before there was repo versioning
|
||||
setVersion
|
||||
v | v == currentVersion -> return ()
|
||||
_ -> error "this version of git-annex is too old for this git repository!"
|
||||
where
|
||||
currentVersion = "1"
|
||||
setVersion = Annex.setConfig field currentVersion
|
||||
field = "annex.version"
|
||||
|
||||
{- Output logging -}
|
||||
verbose :: Annex () -> Annex ()
|
||||
verbose a = do
|
||||
|
|
13
UUID.hs
13
UUID.hs
|
@ -65,7 +65,7 @@ getUUID r = do
|
|||
where
|
||||
uncached = Git.configGet r "annex.uuid" ""
|
||||
cached g = Git.configGet g cachekey ""
|
||||
updatecache g u = when (g /= r) $ setConfig cachekey u
|
||||
updatecache g u = when (g /= r) $ Annex.setConfig cachekey u
|
||||
cachekey = "remote." ++ (Git.repoRemoteName r) ++ ".annex-uuid"
|
||||
|
||||
{- Make sure that the repo has an annex.uuid setting. -}
|
||||
|
@ -75,16 +75,7 @@ prepUUID = do
|
|||
u <- getUUID g
|
||||
when ("" == u) $ do
|
||||
uuid <- liftIO $ genUUID
|
||||
setConfig configkey uuid
|
||||
|
||||
{- Changes a git config setting in both internal state and .git/config -}
|
||||
setConfig :: String -> String -> Annex ()
|
||||
setConfig key value = do
|
||||
g <- Annex.gitRepo
|
||||
liftIO $ Git.run g ["config", key, value]
|
||||
-- re-read git config and update the repo's state
|
||||
g' <- liftIO $ Git.configRead g Nothing
|
||||
Annex.gitRepoChange g'
|
||||
Annex.setConfig configkey uuid
|
||||
|
||||
{- Filters a list of repos to ones that have listed UUIDs. -}
|
||||
reposByUUID :: [Git.Repo] -> [UUID] -> Annex [Git.Repo]
|
||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -1,6 +1,7 @@
|
|||
git-annex (0.04) UNRELEASED; urgency=low
|
||||
|
||||
* Add build dep on libghc6-testpack-dev.
|
||||
* Add annex.version, which will be used to automate upgrades.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Mon, 08 Nov 2010 12:36:39 -0400
|
||||
|
||||
|
|
|
@ -207,6 +207,8 @@ Here are all the supported configuration settings.
|
|||
to talk to this repository.
|
||||
* `annex.scp-options` and `annex.ssh-options` -- Default scp and ssh
|
||||
options to use if a remote does not have specific options.
|
||||
* `annex.version` -- Automatically maintained, and used to automate upgrades
|
||||
between versions.
|
||||
|
||||
The backend used when adding a new file to the annex can be configured
|
||||
on a per-file-type basis via the `.gitattributes` file. In the file,
|
||||
|
|
Loading…
Reference in a new issue