summaryrefslogtreecommitdiff
path: root/Upgrade/V2.hs
blob: df1f62b8c8266bccadbcdca14da53407685a7917 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{- git-annex v2 -> v2 upgrade support
 -
 - Copyright 2011 Joey Hess <joey@kitenet.net>
 -
 - Licensed under the GNU GPL version 3 or higher.
 -}

module Upgrade.V2 where

import System.Directory
import System.FilePath

import Types.Key
import Types
import qualified GitRepo as Git
import Messages
import Utility
import Locations

upgrade :: Annex Bool
upgrade = do
	showNote "v2 to v3"
	error "TODO"

{- Old .gitattributes contents, not needed anymore. -}
attrLines :: [String]
attrLines =
	[ stateDir </> "*.log merge=union"
	, stateDir </> "*/*/*.log merge=union"
	]

gitAttributesUnWrite :: Git.Repo -> IO ()
gitAttributesUnWrite repo = do
	let attributes = Git.attributes repo
	whenM (doesFileExist attributes) $ do
		c <- readFileStrict attributes
		safeWriteFile attributes $ unlines $
			filter (\l -> not $ l `elem` attrLines) $ lines c

oldlogFile :: Git.Repo -> Key -> String
oldlogFile = logFile' hashDirLower

oldlogFileOld :: Git.Repo -> Key -> String
oldlogFileOld = logFile' hashDirMixed

logFile' :: (Key -> FilePath) -> Git.Repo -> Key -> String
logFile' hasher repo key =
	gitStateDir repo ++ hasher key ++ keyFile key ++ ".log"