get --from is the same as copy --from

get not honoring --from has surprised me a few times, so least surprise
suggests it should just behave like copy --from. This leaves the difference
between get and copy being that copy always requires the remote to copy
from, while get will decide whether to get a file from a key/value store or
a remote.
This commit is contained in:
Joey Hess 2011-06-09 18:54:49 -04:00
parent 2136534be1
commit 90dd245522
8 changed files with 17 additions and 9 deletions

View file

@ -81,7 +81,7 @@ copyKeyFile key file = do
Left _ -> return False Left _ -> return False
else return True else return True
docopy r continue = do docopy r continue = do
showNote $ "copying from " ++ Remote.name r ++ "..." showNote $ "from " ++ Remote.name r ++ "..."
copied <- Remote.retrieveKeyFile r key file copied <- Remote.retrieveKeyFile r key file
if copied if copied
then return True then return True

View file

@ -9,9 +9,12 @@ module Command.Get where
import Command import Command
import qualified Backend import qualified Backend
import qualified Annex
import qualified Remote
import Types import Types
import Content import Content
import Messages import Messages
import qualified Command.Move
command :: [Command] command :: [Command]
command = [repoCommand "get" paramPath seek command = [repoCommand "get" paramPath seek
@ -20,7 +23,6 @@ command = [repoCommand "get" paramPath seek
seek :: [CommandSeek] seek :: [CommandSeek]
seek = [withFilesInGit start] seek = [withFilesInGit start]
{- Gets an annexed file from one of the backends. -}
start :: CommandStartString start :: CommandStartString
start file = isAnnexed file $ \(key, backend) -> do start file = isAnnexed file $ \(key, backend) -> do
inannex <- inAnnex key inannex <- inAnnex key
@ -28,7 +30,12 @@ start file = isAnnexed file $ \(key, backend) -> do
then stop then stop
else do else do
showStart "get" file showStart "get" file
next $ perform key backend from <- Annex.getState Annex.fromremote
case from of
Nothing -> next $ perform key backend
Just name -> do
src <- Remote.byName name
next $ Command.Move.fromPerform src False key
perform :: Key -> Backend Annex -> CommandPerform perform :: Key -> Backend Annex -> CommandPerform
perform key backend = do perform key backend = do

1
debian/changelog vendored
View file

@ -2,6 +2,7 @@ git-annex (0.20110602) UNRELEASED; urgency=low
* Add --numcopies option. * Add --numcopies option.
* Add --trust, --untrust, and --semitrust options. * Add --trust, --untrust, and --semitrust options.
* get --from is the same as copy --from
-- Joey Hess <joeyh@debian.org> Wed, 01 Jun 2011 16:26:48 -0400 -- Joey Hess <joeyh@debian.org> Wed, 01 Jun 2011 16:26:48 -0400

View file

@ -30,7 +30,7 @@ The newline is in the wrong place and confuses the user. It should be printed _a
> A related problem occurs if an error message is unexpetedly printed. > A related problem occurs if an error message is unexpetedly printed.
> Dummying up an example: > Dummying up an example:
> >
> O get test1 (copying from foo...) E git-annex: failed to run ssh > O get test1 (from foo...) E git-annex: failed to run ssh
> failed > failed
> >
> --[[Joey]] > --[[Joey]]

View file

@ -41,7 +41,7 @@ content from the key-value store.
# sudo mount /media/usb # sudo mount /media/usb
# git remote add usbdrive /media/usb # git remote add usbdrive /media/usb
# git annex get video/hackity_hack_and_kaxxt.mov # git annex get video/hackity_hack_and_kaxxt.mov
get video/hackity_hack_and_kaxxt.mov (copying from usbdrive...) ok get video/hackity_hack_and_kaxxt.mov (from usbdrive...) ok
# git commit -a -m "got a video I want to rewatch on the plane" # git commit -a -m "got a video I want to rewatch on the plane"
# git annex add iso # git annex add iso

View file

@ -8,8 +8,8 @@ USB drive.
# cd /media/usb/annex # cd /media/usb/annex
# git pull laptop master # git pull laptop master
# git annex get . # git annex get .
get my_cool_big_file (copying from laptop...) ok get my_cool_big_file (from laptop...) ok
get iso/debian.iso (copying from laptop...) ok get iso/debian.iso (from laptop...) ok
Notice that you had to git pull from laptop first, this lets git-annex know Notice that you had to git pull from laptop first, this lets git-annex know
what has changed in laptop, and so it knows about the files present there and what has changed in laptop, and so it knows about the files present there and

View file

@ -14,5 +14,5 @@ it:
failed failed
# sudo mount /media/usb # sudo mount /media/usb
# git annex get video/hackity_hack_and_kaxxt.mov # git annex get video/hackity_hack_and_kaxxt.mov
get video/hackity_hack_and_kaxxt.mov (copying from usbdrive...) ok get video/hackity_hack_and_kaxxt.mov (from usbdrive...) ok
# git commit -a -m "got a video I want to rewatch on the plane" # git commit -a -m "got a video I want to rewatch on the plane"

View file

@ -12,7 +12,7 @@ to clone the laptop's annex to it:
Now you can get files and they will be transferred (using `rsync` via `ssh`): Now you can get files and they will be transferred (using `rsync` via `ssh`):
# git annex get my_cool_big_file # git annex get my_cool_big_file
get my_cool_big_file (getting UUID for origin...) (copying from origin...) get my_cool_big_file (getting UUID for origin...) (from origin...)
WORM-s2159-m1285650548--my_cool_big_file 100% 2159 2.1KB/s 00:00 WORM-s2159-m1285650548--my_cool_big_file 100% 2159 2.1KB/s 00:00
ok ok