summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-09-15 15:27:45 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-09-15 15:28:58 -0400
commita0d3a343b52fba63df523d49849b43217ce744ab (patch)
tree3bd2e0cef5a91a5fdf6183ba3869c77ac6b68eaa
parent7b90cb72fc7d86a8f99d839378fba1ef1c86ff4a (diff)
copy --auto
Only does copy when numcopies is not yet satisfied.
-rw-r--r--Command/Copy.hs13
-rw-r--r--debian/changelog4
-rw-r--r--doc/walkthrough/automatically_managing_content.mdwn3
3 files changed, 16 insertions, 4 deletions
diff --git a/Command/Copy.hs b/Command/Copy.hs
index 7d40f438d..125e0bb9f 100644
--- a/Command/Copy.hs
+++ b/Command/Copy.hs
@@ -9,11 +9,20 @@ module Command.Copy where
import Command
import qualified Command.Move
+import Utility
command :: [Command]
command = [repoCommand "copy" paramPaths seek
"copy content of files to/from another repository"]
--- A copy is just a move that does not delete the source file.
seek :: [CommandSeek]
-seek = [withFilesInGit $ Command.Move.start False]
+seek = [withNumCopies start]
+
+-- A copy is just a move that does not delete the source file.
+-- However, --auto mode avoids unnecessary copies.
+start :: CommandStartAttrFile
+start (file, attr) = isAnnexed file $ \(key, _) ->
+ autoCopies key (<) numcopies $
+ Command.Move.start False file
+ where
+ numcopies = readMaybe attr
diff --git a/debian/changelog b/debian/changelog
index a3ae839ab..d9e606f82 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,8 +5,8 @@ git-annex (3.20110907) UNRELEASED; urgency=low
* Fix build without S3.
* addurl: Always use whole url as destination filename, rather than
only its file component.
- * get, drop: Added --auto option, which decides whether to get/drop
- content as needed to work toward the configured numcopies.
+ * get, drop, copy: Added --auto option, which decides whether
+ to get/drop content as needed to work toward the configured numcopies.
-- Joey Hess <joeyh@debian.org> Tue, 06 Sep 2011 16:59:15 -0400
diff --git a/doc/walkthrough/automatically_managing_content.mdwn b/doc/walkthrough/automatically_managing_content.mdwn
index 74a4c1b5b..5107d2f6f 100644
--- a/doc/walkthrough/automatically_managing_content.mdwn
+++ b/doc/walkthrough/automatically_managing_content.mdwn
@@ -36,3 +36,6 @@ work toward having two copies of your files.
whereis other_file (2 copies)
0c443de8-e644-11df-acbf-f7cd7ca6210d -- laptop
7570b02e-15e9-11e0-adf0-9f3f94cb2eaa -- backup drive
+
+The --auto option can also be used with the copy command,
+again this lets git-annex decide whether to actually copy content.