diff options
author | Joey Hess <joey@kitenet.net> | 2011-10-31 12:47:13 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-10-31 12:56:07 -0400 |
commit | 380839299ea8ffa2c98ce6219e62b979ede0c93b (patch) | |
tree | 9740bd5a861b9b47b2ee6ed5564a3b221137e115 | |
parent | cc1ea8f84463c7e333bfa17a815f250d8d088841 (diff) |
The fromkey command now takes the key as its first parameter. The --key option is no longer used.
-rw-r--r-- | Annex.hs | 2 | ||||
-rw-r--r-- | Command/FromKey.hs | 22 | ||||
-rw-r--r-- | Command/SetContent.hs | 2 | ||||
-rw-r--r-- | Config.hs | 13 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/bugs/No_easy_way_to_re-inject_a_file_into_an_annex/comment_4_480a4f72445a636eab1b1c0f816d365c._comment | 3 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 6 | ||||
-rw-r--r-- | test.hs | 20 |
8 files changed, 27 insertions, 43 deletions
@@ -60,7 +60,6 @@ data AnnexState = AnnexState , catfilehandle :: Maybe CatFileHandle , forcebackend :: Maybe String , forcenumcopies :: Maybe Int - , defaultkey :: Maybe String , toremote :: Maybe String , fromremote :: Maybe String , limit :: Either [Utility.Matcher.Token (FilePath -> Annex Bool)] (Utility.Matcher.Matcher (FilePath -> Annex Bool)) @@ -85,7 +84,6 @@ newState gitrepo = AnnexState , catfilehandle = Nothing , forcebackend = Nothing , forcenumcopies = Nothing - , defaultkey = Nothing , toremote = Nothing , fromremote = Nothing , limit = Left [] diff --git a/Command/FromKey.hs b/Command/FromKey.hs index 4e4644708..b910dd1f0 100644 --- a/Command/FromKey.hs +++ b/Command/FromKey.hs @@ -12,26 +12,26 @@ import Command import qualified Annex.Queue import Annex.Content import Types.Key -import Config def :: [Command] -def = [command "fromkey" paramPath seek "adds a file using a specific key"] +def = [command "fromkey" (paramPair paramKey paramPath) seek + "adds a file using a specific key"] seek :: [CommandSeek] -seek = [withFilesMissing start] +seek = [withWords start] -start :: FilePath -> CommandStart -start file = notBareRepo $ do - key <- cmdlineKey +start :: [String] -> CommandStart +start (keyname:file:[]) = notBareRepo $ do + let key = maybe (error "bad key") id $ readKey keyname inbackend <- inAnnex key unless inbackend $ error $ - "key ("++keyName key++") is not present in backend" + "key ("++ keyname ++") is not present in backend" showStart "fromkey" file - next $ perform file + next $ perform key file +start _ = error "specify a key and a dest file" -perform :: FilePath -> CommandPerform -perform file = do - key <- cmdlineKey +perform :: Key -> FilePath -> CommandPerform +perform key file = do link <- calcGitLink file key liftIO $ createDirectoryIfMissing True (parentDir file) liftIO $ createSymbolicLink link file diff --git a/Command/SetContent.hs b/Command/SetContent.hs index d62faa445..0ecfa34bd 100644 --- a/Command/SetContent.hs +++ b/Command/SetContent.hs @@ -23,7 +23,7 @@ seek = [withWords start] start :: [FilePath] -> CommandStart start (src:dest:[]) = do - showStart "setkey" dest + showStart "setcontent" dest next $ perform src dest start _ = error "specify a src file and a dest file" @@ -10,7 +10,6 @@ module Config where import Common.Annex import qualified Git import qualified Annex -import Types.Key (readKey) type ConfigKey = String @@ -92,15 +91,3 @@ getNumCopies v = g <- gitRepo return $ read $ Git.configGet g config "1" config = "annex.numcopies" - -{- The Key specified by the --key parameter. -} -cmdlineKey :: Annex Key -cmdlineKey = do - k <- Annex.getState Annex.defaultkey - case k of - Nothing -> nokey - Just "" -> nokey - Just kstring -> maybe badkey return $ readKey kstring - where - nokey = error "please specify the key with --key" - badkey = error "bad key" diff --git a/debian/changelog b/debian/changelog index 91e4a18af..25f18f795 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,8 @@ git-annex (3.20111026) UNRELEASED; urgency=low * unused, dropunused: Now work in bare repositories. * Removed the setkey command, and added a setcontent command with a more useful interface. + * The fromkey command now takes the key as its first parameter. The --key + option is no longer used. -- Joey Hess <joeyh@debian.org> Thu, 27 Oct 2011 13:58:53 -0400 diff --git a/doc/bugs/No_easy_way_to_re-inject_a_file_into_an_annex/comment_4_480a4f72445a636eab1b1c0f816d365c._comment b/doc/bugs/No_easy_way_to_re-inject_a_file_into_an_annex/comment_4_480a4f72445a636eab1b1c0f816d365c._comment index 4a22d414b..787173b0a 100644 --- a/doc/bugs/No_easy_way_to_re-inject_a_file_into_an_annex/comment_4_480a4f72445a636eab1b1c0f816d365c._comment +++ b/doc/bugs/No_easy_way_to_re-inject_a_file_into_an_annex/comment_4_480a4f72445a636eab1b1c0f816d365c._comment @@ -4,5 +4,6 @@ subject="comment 4" date="2011-05-14T16:29:35Z" content=""" -Although, if you really do want to shoot yourself in the foot, or know you have the old content, you can use `git-annex setkey`. +Although, if you really do want to shoot yourself in the foot, or know you +have the old content, you can use `git-annex setcontent`. """]] diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index abddaa0de..42997e534 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -318,7 +318,7 @@ subdirectories). This is meant to be called from git's pre-commit hook. `git annex init` automatically creates a pre-commit hook using this. -* fromkey file +* fromkey key file This plumbing-level command can be used to manually set up a file in the git repository to link to a specified key. @@ -406,10 +406,6 @@ subdirectories). are in the annex, their backend is known and this option is not necessary. -* --key=name - - Specifies a key to operate on. - * -c name=value Used to override git configuration settings. May be specified multiple times. @@ -88,7 +88,7 @@ blackbox = TestLabel "blackbox" $ TestList -- test order matters, later tests may rely on state from earlier [ test_init , test_add - , test_setkey + , test_setcontent , test_unannex , test_drop , test_get @@ -118,15 +118,15 @@ test_add = "git-annex add" ~: TestList [basic, sha1dup, subdirs] writeFile annexedfile $ content annexedfile git_annex "add" ["-q", annexedfile] @? "add failed" annexed_present annexedfile + writeFile sha1annexedfile $ content sha1annexedfile + git_annex "add" ["-q", sha1annexedfile, "--backend=SHA1"] @? "add with SHA1 failed" + annexed_present sha1annexedfile writeFile ingitfile $ content ingitfile boolSystem "git" [Param "add", File ingitfile] @? "git add failed" boolSystem "git" [Params "commit -q -a -m commit"] @? "git commit failed" git_annex "add" ["-q", ingitfile] @? "add ingitfile should be no-op" unannexed ingitfile sha1dup = TestCase $ intmpclonerepo $ do - writeFile sha1annexedfile $ content sha1annexedfile - git_annex "add" ["-q", sha1annexedfile, "--backend=SHA1"] @? "add with SHA1 failed" - annexed_present sha1annexedfile writeFile sha1annexedfiledup $ content sha1annexedfiledup git_annex "add" ["-q", sha1annexedfiledup, "--backend=SHA1"] @? "add of second file with same SHA1 failed" annexed_present sha1annexedfiledup @@ -140,15 +140,15 @@ test_add = "git-annex add" ~: TestList [basic, sha1dup, subdirs] changeWorkingDirectory "dir" git_annex "add" ["-q", "../dir2"] @? "add of ../subdir failed" -test_setkey :: Test -test_setkey = "git-annex setkey/fromkey" ~: TestCase $ inmainrepo $ do +test_setcontent :: Test +test_setcontent = "git-annex setcontent/fromkey" ~: TestCase $ intmpclonerepo $ do + git_annex "drop" ["-q", "--force", sha1annexedfile] @? "drop failed" writeFile tmp $ content sha1annexedfile r <- annexeval $ Types.Backend.getKey backendSHA1 tmp let key = show $ fromJust r - git_annex "setkey" ["-q", "--key", key, tmp] @? "setkey failed" - git_annex "fromkey" ["-q", "--key", key, sha1annexedfile] @? "fromkey failed" - boolSystem "git" [Params "commit -q -a -m commit"] @? "git commit failed" - annexed_present sha1annexedfile + git_annex "setcontent" ["-q", tmp, sha1annexedfile] @? "setcontent failed" + git_annex "fromkey" ["-q", key, sha1annexedfiledup] @? "fromkey failed" + annexed_present sha1annexedfiledup where tmp = "tmpfile" |