[darcs-devel] patch: add option --dry-run to command add

Tomasz Zielonka tomasz.zielonka at gmail.com
Thu Nov 11 01:03:43 PST 2004


Best regards,
Tomasz

-- 
.signature: Too many levels of symbolic links
-------------- next part --------------

New patches:

[add option --dry-run to command add
Tomasz Zielonka <tomasz.zielonka at gmail.com>**20041111084332
 Where appropriate messages printed during add --dry-run use ,,would be'' rather
 than present tense. I'm not sure I got the grammar right.
] {
hunk ./Add.lhs 25
-                       recursive, working_repo_dir,
+                       recursive, working_repo_dir, dry_run,
hunk ./Add.lhs 28
-                                  Verbose, Quiet, FancyMoveAdd),
+                                  Verbose, Quiet, FancyMoveAdd, DryRun),
hunk ./Add.lhs 80
-                     working_repo_dir]}
+                     working_repo_dir, dry_run]}
hunk ./Add.lhs 99
-    sequence_ $ map (putInfoLn . ("Skipping boring file "++)) $
+    sequence_ $ map (putInfoLn . ((msg_skipping msgs ++ " boring file ")++)) $
hunk ./Add.lhs 102
-    ps <- addp opts date cur $ nboring flist
-    pend <- read_pending
-    case pend of
-        Nothing -> write_pending $ join_patches $ filter (/= join_patches []) ps
-        Just op -> write_pending $ join_patches $
-                   flatten $ join_patches [op,join_patches ps]
+    ps <- addp msgs opts date cur $ nboring flist
+    when (not gotDryRun) $ do
+        pend <- read_pending
+        case pend of
+            Nothing -> write_pending $ join_patches $ filter (/= join_patches []) ps
+            Just op -> write_pending $ join_patches $
+                       flatten $ join_patches [op,join_patches ps]
+  where
+    gotDryRun = DryRun `elem` opts
+    msgs | gotDryRun = dryRunMessages
+         | otherwise = normalMessages
hunk ./Add.lhs 114
-addp :: [DarcsFlag] -> String -> Slurpy -> [FilePath] -> IO [Patch]
-addp opts date cur0 files = do
+addp :: AddMessages -> [DarcsFlag] -> String -> Slurpy -> [FilePath] -> IO [Patch]
+addp msgs opts date cur0 files = do
hunk ./Add.lhs 136
-               then return 
-                 "The following directory is already in the repository"
-               else return 
-                 "The following file is already in the repository"
+               then return $
+                 "The following directory "++msg_is msgs++" already in the repository"
+               else return $
+                 "The following file "++msg_is msgs++" already in the repository"
hunk ./Add.lhs 144
-               then return 
-                 "The following directories are already in the repository"
+               then return $
+                 "The following directories "++msg_are msgs++" already in the repository"
hunk ./Add.lhs 150
-                        "are already in the repository"
-                      else return
-                        "The following files are already in the repository")
+                        msg_are msgs ++ " already in the repository"
+                      else return $
+                        "The following files " ++ msg_are msgs ++ " already in the repository")
hunk ./Add.lhs 174
-                Nothing -> do putInfo $ "Skipping '" ++ f ++ "' ... "
+                Nothing -> do putInfo $ msg_skipping msgs ++ " '" ++ f ++ "' ... "
hunk ./Add.lhs 177
-                Just s' -> do putVerbose $ "Adding '"++f++"'\n"
+                Just s' -> do putVerbose $ msg_adding msgs++" '"++f++"'\n"
hunk ./Add.lhs 194
-  putVerbose = if Verbose `elem` opts then putStr else \_ -> return ()
+  putVerbose = if Verbose `elem` opts || DryRun `elem` opts then putStr else \_ -> return ()
hunk ./Add.lhs 199
+
+data AddMessages =
+    AddMessages
+    { msg_skipping  :: String
+    , msg_adding    :: String
+    , msg_is        :: String
+    , msg_are       :: String
+    }
+
+normalMessages, dryRunMessages :: AddMessages
+normalMessages =
+    AddMessages
+    { msg_skipping  = "Skipping"
+    , msg_adding    = "Adding"
+    , msg_is        = "is"
+    , msg_are       = "are"
+    }
+dryRunMessages =
+    AddMessages
+    { msg_skipping  = "Would skip"
+    , msg_adding    = "Would add"
+    , msg_is        = "would be"
+    , msg_are       = "would be"
+    }
}



Context:

[separate iteration from processing a single file in Add.addp
Tomasz Zielonka <tomasz.zielonka at gmail.com>**20041110224649
 Now addp' doesn't have to manage the lists of files, patches and duplicated
 files, it is only concerned with processing a single file.
 
 I hope you'll like the idea of building an accumulator passing function with
 foldr - this may be a little difficult to understand at first, but is very
 flexible.
 
 I also changed variable names cur and cur' to cur0 and cur because the first
 one is supposed to be used only once, and cur0 seems to be a better name in
 such case. Also, I explicitely memoised some checks for options.
] 
[link homepage to linux.html
Mark Stosberg <mark at summersault.com>**20041110131019] 
[Copy darcs_print.ps into darcs.ps instead of copying it
Samuel Tardieu <sam at rfc1149.net>**20041110125906] 
[Move getCurrentPop into Current.
Juliusz Chroboczek <jch at pps.jussieu.fr>**20040930201752
 Following a suggestion of David's, getPopFrom is moved into PopulationData,
 which avoids the circularity between modules.
 
 Unfortunately, this causes Current to import PatchInfo, which is wrong.
 Somebody or someone else should be made polymorphic.
] 
[stupid me resolved the same conflict twice, and now has to do it again. :(
David Roundy <droundy at abridgegame.org>**20040926114756] 
[resolve spelling fix conflict.
David Roundy <droundy at abridgegame.org>**20040926100211] 
[Get multiple files with a single wget call
schnetter at aei.mpg.de**20040922200621
 Get multiple files with a single wget call.  This is much faster from
 remote repositories because wget can reuse the existing http
 connection.
] 
[Change directory handling when calling sftp
schnetter at aei.mpg.de**20040922192756
 Change the local directory instead of using the "lcd" command when
 using ftp to copy from remote files.
] 
[Document DARCS_SFTP environment variable
Erik Schnetter <schnetter at aei.mpg.de>**20040919125737] 
[fix warnings and resolve conflict.
David Roundy <droundy at abridgegame.org>**20040919121852] 
[Use sftp instead of scp to copy patches
Erik Schnetter <schnetter at aei.mpg.de>**20040918174705
 Add a new routine External.CopyFilesAndUrls that copies several files
 at once, which is much faster for remote files.  For SSH connections,
 use sftp instead of scp to copy all files, which reuses the ssh
 connection and is much faster for small files.  For local files and
 http connections, fall back to looping over the old methods.
 
 Calling libcurl, wget, or curl should be similarly improved.
 
 Use this routine in Repository to copy the patches of a repository.
 There is no progress indicator any more.
] 
[generalize wording for --dry-run, so it makes sense for 'send'
Mark Stosberg <mark at summersault.com>**20041109230515
 
 The documentation for '--dry-run' referred to 'making changes', which
 doesn't apply to send. I generalized the wording so it fits better 
 for all cases.
] 
[make AntiMemo literate, working towards antimemoization paper.
David Roundy <droundy at abridgegame.org>**20041106141351] 
[added GHC_LIBDIR to autoconfigure
Craig M. Lennox <mirian at sandstorm.net>**20040927193821] 
[use := rather than = for static assignments as recommended in GNU Make manual
Craig M. Lennox <mirian at sandstorm.net>**20041004134942] 
[resolve conflicts between Current and SignalHandler changes.
David Roundy <droundy at abridgegame.org>**20041001115019] 
[Use David's fromJust.
Juliusz Chroboczek <jch at pps.jussieu.fr>**20040930201432] 
[Naming tweaks (writeCurrent, write_dirty_Current).
Juliusz Chroboczek <jch at pps.jussieu.fr>**20040930195800] 
[Rename mmap_slurp_Current to slurpCurrent.
Juliusz Chroboczek <jch at pps.jussieu.fr>**20040930195301] 
[Copied copyright header from RepoPrefs, updating the year.
Craig M. Lennox <mirian at sandstorm.net>**20040927134420] 
[Moved motd to its own module to keep External out of Core
Craig M. Lennox <mirian at cosmic.com>**20040926015204] 
[split ColourPrinter.lhs off from Printer.lhs
Craig M. Lennox <mirian at cosmic.com>**20040925212232
 This is to allow "core" darcs modules like Patch to import Printer
 without needing to link in all the curses stuff.
] 
[Make _darcs/current polymorphic.
Juliusz Chroboczek <jch at pps.jussieu.fr>**20040916065829
 This allows multiple formats for _darcs/current.  Currently, two
 formats are implemented:
 
   - PlainCurrent, the directory _darcs/current that we all know and love;
   - NoCurrent, just a placeholder file _darcs/current.none.
 
 A third format, HashedCurrent, is planned but not implemented yet
 (there are stubs in Current.lhs).
 
 You can convert to the NoCurrent format by doing
 
   $ rm -r _darcs/current
   $ touch _darcs/current.none
 
 and convert back to PlainCurrent by doing
 
   $ rm _darcs/current.none
   $ mkdir _darcs/current
   $ darcs repair
 
 There are two problems with this code that I was unable to solve.
 First, getCurrentPop in Population.lhs is a gross violation of
 modularity; it is actually the only reason why Current is not abstract
 (it has to export PlainCurrent).  Second, surely_slurp_Current in
 Repository.lhs leaves a temporary directory after darcs terminates;
 we're bitten by the laziness of slurp.  These problems should be
 solved before release.
 
 Converting Current to be a type class instead of an algebraic
 datatype is left as an exercice for the reader (hint: you need
 existential types).
] 
[darcs_cgi also needs Current.lhs.
Juliusz Chroboczek <jch at pps.jussieu.fr>**20040916090832] 
[Clean up remote access routines
Erik Schnetter <schnetter at aei.mpg.de>**20040918164628
 Use a common structure for the three file access methods "local",
 "remote", and "SSH".  Handle all temporary files in External instead
 of providing an equivalent routine in Curl.  Do not use temporary
 files for local access to gzipped files.
] 
[don't assume in add.pl that perl will produce utf8 when dealing with unicode chars.
David Roundy <droundy at abridgegame.org>**20041110115821] 
[fix conflict in add.pl.
David Roundy <droundy at abridgegame.org>**20041110114416] 
[Condense "file already in repo" output when adding. Add related tests.
Jim Marshall <jmarshall99 at qwest.net>**20041108075251
 This is meant to address issue #15 on bugs.darcs.net. Because I couldn't
 figure out a way to find already-added files "up front" (because they may only
 become duplicates after the add has started), and to avoid having to pass a []
 to addp to accumulate the list of duplicates, I moved the real work of addp
 into a where-scoped helper function. If you'd rather live with passing in the
 [], and are otherwise happy with the patch, let me know and I'll change it.
 
 This should also pass the add.pl test, and this patch extends that test a bit.
] 
[editorial suggestion
Mark Stosberg <mark at summersault.com>**20041110022033] 
[mention tools for migrating from CVS and Arch
Mark Stosberg <mark at summersault.com>**20041110022012] 
[Important fix for broken html manual
Mark Stosberg <mark at summersault.com>**20041110014511
 
 I think the online manual is broken. Scroll to where the 'record' docs
 should end, and you'll just see a text dump:
 
 http://www.darcs.net/manual/node7.html
 
 I apologize, because I think I submitted the patch that broke this.
 
 (I need some better latex tools to review my work, I think...)
 
     Mark
 
] 
[clean up and normalize help output
Will <will at glozer.net>**20041109223054] 
[make optimize --uncompress work with --partial repos.
David Roundy <droundy at abridgegame.org>**20041109131538] 
[TAG 1.0.0
David Roundy <droundy at abridgegame.org>**20041108111509] 

Patch bundle hash:
3d2b7b383f1f613fa12b129266289cbbfb9a3f8c


More information about the darcs-devel mailing list