2010-11-27 21:09:22 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Copy where
|
|
|
|
|
2011-11-11 03:35:08 +00:00
|
|
|
import Common.Annex
|
2010-11-27 21:09:22 +00:00
|
|
|
import Command
|
|
|
|
import qualified Command.Move
|
2012-01-06 08:02:35 +00:00
|
|
|
import qualified Remote
|
2010-11-27 21:09:22 +00:00
|
|
|
|
2011-10-29 19:19:05 +00:00
|
|
|
def :: [Command]
|
more command-specific options
Made --from and --to command-specific options.
Added generic storage for values of command-specific options,
which allows removing some of the special case fields in AnnexState.
(Also added generic storage for command-specific flags, although there are
not yet any.)
Note that this storage uses a Map, so repeatedly looking up the same value
is slightly more expensive than looking up an AnnexState field. But, the
value can be looked up once in the seek stage, transformed as necessary,
and passed in a closure to the start stage, and this avoids that overhead.
Still, I'm hesitant to use this for things like force or fast flags.
It's probably best to reserve it for flags that are only used by a few
commands, or options like --from and --to that it's important only be
allowed to be used with commands that implement them, to avoid user
confusion.
2012-01-06 07:06:25 +00:00
|
|
|
def = [withOptions Command.Move.options $ command "copy" paramPaths seek
|
2010-12-30 19:06:26 +00:00
|
|
|
"copy content of files to/from another repository"]
|
|
|
|
|
2010-12-30 18:19:16 +00:00
|
|
|
seek :: [CommandSeek]
|
2012-01-06 14:14:37 +00:00
|
|
|
seek = [withField Command.Move.toOption Remote.byName $ \to ->
|
|
|
|
withField Command.Move.fromOption Remote.byName $ \from ->
|
2012-02-14 03:42:44 +00:00
|
|
|
withFilesInGit $ whenAnnexed $ start to from]
|
2011-09-15 19:27:45 +00:00
|
|
|
|
|
|
|
-- A copy is just a move that does not delete the source file.
|
|
|
|
-- However, --auto mode avoids unnecessary copies.
|
2012-02-14 03:42:44 +00:00
|
|
|
start :: Maybe Remote -> Maybe Remote -> FilePath -> (Key, Backend) -> CommandStart
|
|
|
|
start to from file (key, backend) = autoCopies file key (<) $ \_numcopies ->
|
more command-specific options
Made --from and --to command-specific options.
Added generic storage for values of command-specific options,
which allows removing some of the special case fields in AnnexState.
(Also added generic storage for command-specific flags, although there are
not yet any.)
Note that this storage uses a Map, so repeatedly looking up the same value
is slightly more expensive than looking up an AnnexState field. But, the
value can be looked up once in the seek stage, transformed as necessary,
and passed in a closure to the start stage, and this avoids that overhead.
Still, I'm hesitant to use this for things like force or fast flags.
It's probably best to reserve it for flags that are only used by a few
commands, or options like --from and --to that it's important only be
allowed to be used with commands that implement them, to avoid user
confusion.
2012-01-06 07:06:25 +00:00
|
|
|
Command.Move.start to from False file (key, backend)
|