summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-12 13:10:07 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-12 13:10:07 -0400
commitdc1d5e68317b85043c8c30a82f53f78b0a9a9f51 (patch)
treef276c940a74ea8888e746e61ddb891cf280a2d29
parentea5d7fe07a5c40349e66848fc9cd06a9f748b724 (diff)
update
-rw-r--r--Annex.hs16
-rw-r--r--TODO34
-rw-r--r--UUID.hs36
3 files changed, 39 insertions, 47 deletions
diff --git a/Annex.hs b/Annex.hs
index 5adc73996..31897479d 100644
--- a/Annex.hs
+++ b/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
diff --git a/TODO b/TODO
index b08784ec2..c951eb3f1 100644
--- a/TODO
+++ b/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
diff --git a/UUID.hs b/UUID.hs
new file mode 100644
index 000000000..a0e078482
--- /dev/null
+++ b/UUID.hs
@@ -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 ()