diff options
-rw-r--r-- | Command/Init.hs | 17 | ||||
-rw-r--r-- | Command/Uninit.hs | 2 | ||||
-rw-r--r-- | LocationLog.hs | 2 | ||||
-rw-r--r-- | Upgrade/V1.hs | 18 | ||||
-rw-r--r-- | debian/changelog | 5 |
5 files changed, 30 insertions, 14 deletions
diff --git a/Command/Init.hs b/Command/Init.hs index 661835169..d9ea394a3 100644 --- a/Command/Init.hs +++ b/Command/Init.hs @@ -8,7 +8,7 @@ module Command.Init where import Control.Monad.State (liftIO) -import Control.Monad (when) +import Control.Monad (when, unless) import System.Directory import System.FilePath @@ -74,12 +74,14 @@ gitAttributesWrite repo = do exists <- doesFileExist attributes if not exists then do - safeWriteFile attributes $ attrLine ++ "\n" + safeWriteFile attributes $ unlines attrLines commit else do content <- readFile attributes - when (all (/= attrLine) (lines content)) $ do - appendFile attributes $ attrLine ++ "\n" + let present = lines content + let missing = filter (\l -> not $ l `elem` present) attrLines + unless (null missing) $ do + appendFile attributes $ unlines missing commit where attributes = Git.attributes repo @@ -91,8 +93,11 @@ gitAttributesWrite repo = do , Param attributes ] -attrLine :: String -attrLine = stateDir </> "*.log merge=union" +attrLines :: [String] +attrLines = + [ stateDir </> "*.log merge=union" + , stateDir </> "*/*/*.log merge=union" + ] {- set up a git pre-commit hook, if one is not already present -} gitPreCommitHookWrite :: Git.Repo -> Annex () diff --git a/Command/Uninit.hs b/Command/Uninit.hs index e9406ce3a..e8ac1bbd5 100644 --- a/Command/Uninit.hs +++ b/Command/Uninit.hs @@ -60,4 +60,4 @@ gitAttributesUnWrite repo = do when attrexists $ do c <- readFileStrict attributes safeWriteFile attributes $ unlines $ - filter (/= Command.Init.attrLine) $ lines c + filter (\l -> not $ l `elem` Command.Init.attrLines) $ lines c diff --git a/LocationLog.hs b/LocationLog.hs index a939af825..f1e54432c 100644 --- a/LocationLog.hs +++ b/LocationLog.hs @@ -24,6 +24,8 @@ module LocationLog ( LogStatus(..), logChange, logFile, + readLog, + writeLog, keyLocations ) where diff --git a/Upgrade/V1.hs b/Upgrade/V1.hs index 602ba41c5..797bdee0d 100644 --- a/Upgrade/V1.hs +++ b/Upgrade/V1.hs @@ -21,13 +21,15 @@ import Key import Content import Types import Locations +import LocationLog import qualified Annex import qualified GitRepo as Git import Backend import Messages import Version import Utility - +import qualified Command.Init + -- v2 adds hashing of filenames of content and location log files. -- Key information is encoded in filenames differently, so -- both content and location log files move around, and symlinks @@ -61,6 +63,12 @@ upgrade = do Annex.queueRun setVersion + + -- add new line to auto-merge hashed location logs + -- this commits, so has to come after the upgrade + g <- Annex.gitRepo + liftIO $ Command.Init.gitAttributesWrite g + return True moveContent :: Annex () @@ -110,8 +118,12 @@ moveLocationLogs = do let f = dir </> l liftIO $ createDirectoryIfMissing True (parentDir dest) -- could just git mv, but this way deals with - -- log files that are not checked into git - liftIO $ copyFile f dest + -- log files that are not checked into git, + -- as well as merging with already upgraded + -- logs that have been pulled from elsewhere + old <- liftIO $ readLog f + new <- liftIO $ readLog dest + liftIO $ writeLog dest (old++new) Annex.queue "add" [Param "--"] dest Annex.queue "add" [Param "--"] f Annex.queue "rm" [Param "--quiet", Param "-f", Param "--"] f diff --git a/debian/changelog b/debian/changelog index c40385beb..68afb1293 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,12 +1,9 @@ git-annex (0.20110316) UNRELEASED; urgency=low - * Reorganized .git/annex/objects and .git-annex/; annex.version=2 + * New repository format, annex.version=2. * The first time git-annex is run in an old format repository, it will automatically upgrade it to the new format, staging all necessary changes to git. - * Note that remotes must be running this version of git-annex, - and must also have been upgraded, in order for git-annex to - communicate with them. * Colons are now avoided in filenames, so bare clones of git repos can be put on USB thumb drives formatted with vFAT or similar filesystems. |