update
This commit is contained in:
parent
ea5d7fe07a
commit
dc1d5e6831
3 changed files with 39 additions and 47 deletions
16
Annex.hs
16
Annex.hs
|
@ -10,13 +10,12 @@ module Annex (
|
|||
|
||||
import System.Posix.Files
|
||||
import System.Directory
|
||||
import System.Cmd.Utils
|
||||
import System.IO
|
||||
import GitRepo
|
||||
import Utility
|
||||
import Locations
|
||||
import Backend
|
||||
import BackendList
|
||||
import UUID
|
||||
import LocationLog
|
||||
|
||||
-- git-annex's runtime state
|
||||
|
@ -86,12 +85,7 @@ unannexFile state file = do
|
|||
{- Sets up a git repo for git-annex. May be called repeatedly. -}
|
||||
gitPrep :: GitRepo -> IO ()
|
||||
gitPrep repo = do
|
||||
-- Make sure that the repo has an annex.uuid setting.
|
||||
if ("" == gitConfig repo "annex.uuid" "")
|
||||
then do
|
||||
uuid <- genUUID
|
||||
gitRun repo ["config", "annex.uuid", uuid]
|
||||
else return ()
|
||||
prepUUID repo
|
||||
|
||||
-- configure git to use union merge driver on state files
|
||||
let attrLine = stateLoc ++ "/*.log merge=union"
|
||||
|
@ -108,9 +102,3 @@ gitPrep repo = do
|
|||
appendFile attributes $ attrLine ++ "\n"
|
||||
gitAdd repo attributes
|
||||
else return ()
|
||||
|
||||
{- Generates a UUID. There is a library for this, but it's not packaged,
|
||||
- so use the command line tool. -}
|
||||
genUUID :: IO String
|
||||
genUUID = do
|
||||
pOpen ReadFromPipe "uuid" ["-m"] $ \h -> hGetLine h
|
||||
|
|
34
TODO
34
TODO
|
@ -1,39 +1,7 @@
|
|||
* bug when annexing files in a subdir of a git repo
|
||||
* how to handle git mv file?
|
||||
|
||||
* query remotes for their annex.name settings, or figure out a different
|
||||
solution to nameing problem?
|
||||
|
||||
- querying network remotes all the time will be slow. local caching in
|
||||
.git/config?
|
||||
- having a git annex name and a git remote name that are distinct
|
||||
will be confusing
|
||||
- but git remote names are repo-local, I want a global name
|
||||
- really, I don't want a name at all, I want a per-repo UUID
|
||||
|
||||
So, each repo has a UUID, stored in annex.uuid.
|
||||
|
||||
And also, the last seen UUID for each remote is listed:
|
||||
|
||||
remote.origin.annex-uuid=d3d2474c-d5c3-11df-80a9-002170d25c55
|
||||
|
||||
Then when it need to find a repo by UUID, it can see if a known remote
|
||||
has it -- and then query the remote to confirm the repo there still has
|
||||
that UUID (a different repo may have been mounted there).
|
||||
|
||||
Failing that, it can force a refresh of all uuids, updating .git/config,
|
||||
and check again.
|
||||
|
||||
- Only downside for this is that if I put a repo on a usb disk,
|
||||
and it is disconnected and I have no remote for it,
|
||||
git-annex will have to say:
|
||||
|
||||
"You asked for a file that is only present on a git repo with
|
||||
UUID d3d2474c-d5c3-11df-80a9-002170d25c55 -- and I don't know
|
||||
where it is."
|
||||
|
||||
To solve that, let .git-annex/uuid.map map between uuids and descriptions,
|
||||
like "d3d2474c-d5c3-11df-80a9-002170d25c55 SATA drive labeled '* arch-2'"
|
||||
* query remotes for their annex.uuid settings
|
||||
|
||||
* hook up LocationLog
|
||||
* --push/--pull/--get/--want/--drop
|
||||
|
|
36
UUID.hs
Normal file
36
UUID.hs
Normal file
|
@ -0,0 +1,36 @@
|
|||
{- git-annex uuids
|
||||
-
|
||||
- Each git repository used by git-annex has an annex.uuid setting that
|
||||
- uniquely identifies that repository.
|
||||
-
|
||||
-}
|
||||
|
||||
module UUID (
|
||||
getUUID,
|
||||
prepUUID,
|
||||
genUUID
|
||||
) where
|
||||
|
||||
import System.Cmd.Utils
|
||||
import System.IO
|
||||
import GitRepo
|
||||
|
||||
configkey="annex.uuid"
|
||||
|
||||
{- Generates a UUID. There is a library for this, but it's not packaged,
|
||||
- so use the command line tool. -}
|
||||
genUUID :: IO String
|
||||
genUUID = do
|
||||
pOpen ReadFromPipe "uuid" ["-m"] $ \h -> hGetLine h
|
||||
|
||||
getUUID :: GitRepo -> String
|
||||
getUUID repo = gitConfig repo "annex.uuid" ""
|
||||
|
||||
{- Make sure that the repo has an annex.uuid setting. -}
|
||||
prepUUID :: GitRepo -> IO ()
|
||||
prepUUID repo =
|
||||
if ("" == getUUID repo)
|
||||
then do
|
||||
uuid <- genUUID
|
||||
gitRun repo ["config", configkey, uuid]
|
||||
else return ()
|
Loading…
Reference in a new issue