From 5db7d435e7e9915ddbe7126f719820099fa8fe41 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 5 Nov 2015 18:24:15 -0400 Subject: [PATCH] -J for add/addurl/import --- Command/Add.hs | 4 ++-- Command/AddUrl.hs | 13 +++++++------ Command/Import.hs | 4 ++-- debian/changelog | 3 ++- doc/git-annex-add.mdwn | 5 +++++ doc/git-annex-addurl.mdwn | 5 +++++ doc/git-annex-import.mdwn | 5 +++++ 7 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Command/Add.hs b/Command/Add.hs index 11682207e0..94a19fba5c 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -35,7 +35,7 @@ import Utility.Tmp import Control.Exception (IOException) cmd :: Command -cmd = notBareRepo $ withGlobalOptions fileMatchingOptions $ +cmd = notBareRepo $ withGlobalOptions (jobsOption : fileMatchingOptions) $ command "add" SectionCommon "add files to annex" paramPaths (seek <$$> optParser) @@ -56,7 +56,7 @@ optParser desc = AddOptions - - In direct mode, it acts on any files that have changed. -} seek :: AddOptions -> CommandSeek -seek o = do +seek o = allowConcurrentOutput $ do matcher <- largeFilesMatcher let go a = flip a (addThese o) $ \file -> ifM (checkFileMatcher matcher file <||> Annex.getState Annex.force) ( start file diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index 4b34051e9c..6ed4fb2e2d 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -38,7 +38,7 @@ import qualified Utility.Quvi as Quvi #endif cmd :: Command -cmd = notBareRepo $ +cmd = notBareRepo $ withGlobalOptions [jobsOption] $ command "addurl" SectionCommon "add urls to annex" (paramRepeating paramUrl) (seek <$$> optParser) @@ -87,11 +87,12 @@ parseRawOption = switch ) seek :: AddUrlOptions -> CommandSeek -seek o = forM_ (addUrls o) $ \u -> do - r <- Remote.claimingUrl u - if Remote.uuid r == webUUID || rawOption o - then void $ commandAction $ startWeb o u - else checkUrl r o u +seek o = allowConcurrentOutput $ + forM_ (addUrls o) $ \u -> do + r <- Remote.claimingUrl u + if Remote.uuid r == webUUID || rawOption o + then void $ commandAction $ startWeb o u + else checkUrl r o u checkUrl :: Remote -> AddUrlOptions -> URLString -> Annex () checkUrl r o u = do diff --git a/Command/Import.hs b/Command/Import.hs index a96c080556..3ace2d2b05 100644 --- a/Command/Import.hs +++ b/Command/Import.hs @@ -21,7 +21,7 @@ import Annex.CheckIgnore import Annex.NumCopies cmd :: Command -cmd = withGlobalOptions fileMatchingOptions $ notBareRepo $ +cmd = withGlobalOptions (jobsOption : fileMatchingOptions) $ notBareRepo $ command "import" SectionCommon "move and add files from outside git working copy" paramPaths (seek <$$> optParser) @@ -59,7 +59,7 @@ duplicateModeParser = ) seek :: ImportOptions -> CommandSeek -seek o = do +seek o = allowConcurrentOutput $ do repopath <- liftIO . absPath =<< fromRepo Git.repoPath inrepops <- liftIO $ filter (dirContains repopath) <$> mapM absPath (importFiles o) unless (null inrepops) $ do diff --git a/debian/changelog b/debian/changelog index 44ed24a604..da322b50ea 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,7 +2,8 @@ git-annex (5.20151102.2) UNRELEASED; urgency=medium * Use concurrent-output library when configured with -fConcurrentOutput. This allows nicely displayed messages when using the -J flag. - * Additional commands now suppport the -J flag: fsck, drop + * Additional commands now suppport the -J flag: + fsck, drop, add, addurl, import -- Joey Hess Wed, 04 Nov 2015 12:50:20 -0400 diff --git a/doc/git-annex-add.mdwn b/doc/git-annex-add.mdwn index ee5f499d9c..cfeb8a98e5 100644 --- a/doc/git-annex-add.mdwn +++ b/doc/git-annex-add.mdwn @@ -43,6 +43,11 @@ annexed content, and other symlinks. For example: `--largerthan=1GB` +* `--jobs=N` `-JN` + + Adds multiple files in parallel. This may be faster. + For example: `-J4` + # SEE ALSO [[git-annex]](1) diff --git a/doc/git-annex-addurl.mdwn b/doc/git-annex-addurl.mdwn index 1503a284ea..0f5a763bc1 100644 --- a/doc/git-annex-addurl.mdwn +++ b/doc/git-annex-addurl.mdwn @@ -65,6 +65,11 @@ be used to get better filenames. Use to adjust the filenames that are created by addurl. For example, `--suffix=.mp3` can be used to add an extension to the file. +* `--jobs=N` `-JN` + + Enables parallel downloads when multiple urls are being added. + For example: `-J4` + # SEE ALSO [[git-annex]](1) diff --git a/doc/git-annex-import.mdwn b/doc/git-annex-import.mdwn index 48c087aec2..ca37b81ebb 100644 --- a/doc/git-annex-import.mdwn +++ b/doc/git-annex-import.mdwn @@ -66,6 +66,11 @@ Several options can be used to adjust handling of duplicate files. git annex import /dir --include='*.png' +* `--jobs=N` `-JN` + + Imports multiple files in parallel. This may be faster. + For example: `-J4` + # CAVEATS Note that using `--deduplicate` or `--clean-duplicates` with the WORM