This is my fix for the recently reported "--no-pristine-tree broken" bug
report (on the darcs-users mailing list).  The patches are sort of in the
wrong order... I really need to learn to create the test script first and
*then* fix the bug!

Both fixes look pretty safe to me, so I expect to move this bugfix into
stable pretty expeditiously (how's that for a nice word?) unless there are
any objections.

David

Sat Sep  3 09:07:22 EDT 2005  David Roundy <[EMAIL PROTECTED]>
  * don't create test directory if we don't want to actually run test.

Sat Sep  3 09:20:55 EDT 2005  David Roundy <[EMAIL PROTECTED]>
  * fix bug triggered by --no-pristine-tree and running test.
  The trouble was that the NoPristine version of createPristineDirectoryTree
  would fail if the directory already exists, which isn't the intended
  behavior.  I also took this opportunity to remove the "stubbornly" function
  and replace some stubborn directory creation with
  createDirectoryIfMissing.

Sat Sep  3 09:29:06 EDT 2005  David Roundy <[EMAIL PROTECTED]>
  * add test script that displays --no-pristine test-related bug.

New patches:

[don't create test directory if we don't want to actually run test.
David Roundy <[EMAIL PROTECTED]>**20050903130722] 
<
> {
hunk ./Test.lhs 81
 
 \begin{code}
 test_patch :: [DarcsFlag] -> Patch -> IO ExitCode
-test_patch opts p =
-   let putInfo str = when (not $ Quiet `elem` opts) $ putStr str
-   in do
-   testline <- get_prefval "test"
-   formerdir <- getCurrentDirectory
-   withRecorded (wd "testing") $ \td ->
-     case testline of
-     Nothing -> return ExitSuccess
-     Just _ -> do
-       apply p
-       setCurrentDirectory formerdir
-       ec <- run_test opts td
-       if ec == ExitSuccess
-          then putInfo "Looks like a good patch.\n"
-          else putInfo "Looks like you have a bad patch!\n"
-       return ec
+test_patch opts p = do
+  testline <- get_prefval "test"
+  case testline of
+    Nothing -> return ExitSuccess
+    Just _ -> do
+      formerdir <- getCurrentDirectory
+      withRecorded (wd "testingss") $ \td -> do
+        apply p
+        setCurrentDirectory formerdir
+        ec <- run_test opts td
+        if ec == ExitSuccess
+           then putInfo "Looks like a good patch.\n"
+           else putInfo "Looks like you have a bad patch!\n"
+        return ec
    where wd = if LeaveTestDir `elem` opts then withPermDir else withTempDir
hunk ./Test.lhs 96
+         putInfo str = when (not $ Quiet `elem` opts) $ putStr str
 \end{code}
 
 \begin{code}
}
[fix bug triggered by --no-pristine-tree and running test.
David Roundy <[EMAIL PROTECTED]>**20050903132055
 The trouble was that the NoPristine version of createPristineDirectoryTree
 would fail if the directory already exists, which isn't the intended
 behavior.  I also took this opportunity to remove the "stubbornly" function
 and replace some stubborn directory creation with
 createDirectoryIfMissing.
] 
<
> {
hunk ./DarcsRepo.lhs 69
                     simple_feedback
                   ) where
 
-import Directory ( createDirectory, setCurrentDirectory, doesFileExist,
+import Directory ( setCurrentDirectory, doesFileExist,
                    doesDirectoryExist )
hunk ./DarcsRepo.lhs 71
-import Workaround ( getCurrentDirectory, renameFile )
+import Workaround ( getCurrentDirectory, renameFile, createDirectoryIfMissing )
 import DarcsUtils ( withCurrentDirectory, bugDoc )
 import System.IO ( hPutStrLn, stderr, hFlush, stdout )
 import System.IO.Unsafe ( unsafeInterleaveIO )
hunk ./DarcsRepo.lhs 212
             sfp sofar (p:ps) = sfp (p:sofar) ps
 \end{code}
 \begin{code}
-stubbornly :: IO () -> IO ()
-stubbornly do_something = do_something `catchall` return ()
-
 write_patch :: [DarcsFlag] -> Patch -> IO FilePath
 write_patch opts p =
     case patch2patchinfo p of
hunk ./DarcsRepo.lhs 239
  = do done <- easyCreatePristineDirectoryTree pris fp
       unless done $ do
           patches <- get_whole_repo_patches
-          createDirectory fp
+          createDirectoryIfMissing True fp
           withCurrentDirectory fp $
               apply_patches noPut noPut patches
     where noPut _ = return ()
hunk ./DarcsRepo.lhs 330
 -- out the entire inventory, including the parts that you haven't
 -- changed...
 write_inventory dir ps = withSignalsBlocked $ do
-    stubbornly $ createDirectory (dir++"/_darcs/inventories")
+    createDirectoryIfMissing False (dir++"/_darcs/inventories")
     simply_write_inventory "inventory" dir $ slightly_optimize_patchset ps
 
 simply_write_inventory :: String -> FilePath -> PatchSet -> IO ()
hunk ./DarcsRepo.lhs 522
 write_checkpoint_patch p =
   case patch2patchinfo p of
   Just pinfo -> do
-    stubbornly $ createDirectory "_darcs/checkpoints"
+    createDirectoryIfMissing False "_darcs/checkpoints"
     gzWritePatch ("_darcs/checkpoints/"++make_filename pinfo) p
     cpi <- (map fst) `liftM` read_checkpoints "."
     writeDocBinFile "_darcs/checkpoints/inventory"
}
[add test script that displays --no-pristine test-related bug.
David Roundy <[EMAIL PROTECTED]>**20050903132906] 
<
> {
addfile ./tests/no_pristine.sh
hunk ./tests/no_pristine.sh 1
+#!/bin/sh
+
+# This test script, originally written by David Roundy and Ian Lynagh is in
+# the public domain.
+
+set -ev
+
+test $DARCS || DARCS=$PWD/../darcs
+ACTUAL_DARCS=`which $DARCS`
+DARCSPATH=`dirname $ACTUAL_DARCS`
+export PATH="$DARCSPATH:$PATH"
+
+rm -rf temp1
+
+mkdir temp1
+cd temp1
+
+$DARCS initialize --no-pristine-tree
+echo ALL --author Testing Person >> _darcs/prefs/defaults
+echo ALL --ignore-times
+
+echo foo > bar
+$DARCS add bar
+$DARCS record -a -m baz bar
+
+date > bar
+$DARCS record --no-test -a -m 'patch 2'
+
+$DARCS setpref test 'echo hello world'
+$DARCS record -a -m 'setpref'
+
+date >> bar
+$DARCS record -a -m 'record with test'
+
+cd ..
+
+rm -rf temp*
}

Context:

[Change an rm_rf to a cleanup in tests/disable.pl
Ian Lynagh <[EMAIL PROTECTED]>**20050902024711] 
[TAG 1.0.4pre4
David Roundy <[EMAIL PROTECTED]>**20050901110418] 
[add changelog entry for makefile fix.
David Roundy <[EMAIL PROTECTED]>**20050901110353] 
[bump version to 1.0.4pre4.
David Roundy <[EMAIL PROTECTED]>**20050901110210] 
[fix DESTDIR syntax errors in makefile
Andres Loeh <[EMAIL PROTECTED]>**20050831192410] 
[TAG 1.0.4pre3
David Roundy <[EMAIL PROTECTED]>**20050831115448] 
[add two changelog entries.
David Roundy <[EMAIL PROTECTED]>**20050831113335] 
[only create directories on install if they don't exist (bug #494)
David Roundy <[EMAIL PROTECTED]>**20050831113142] 
[fix bug in whatsnew -l -l (rt#501).
David Roundy <[EMAIL PROTECTED]>**20050831110552] 
[fix typo in docs.
David Roundy <[EMAIL PROTECTED]>**20050831002520] 
[fix --posthook code to pass tests.
David Roundy <[EMAIL PROTECTED]>**20050830132225] 
[add test for --disable.
David Roundy <[EMAIL PROTECTED]>**20050830132122] 
[add changelog entry for --posthook.
David Roundy <[EMAIL PROTECTED]>**20050830132110] 
[add skeleton posthook test.
David Roundy <[EMAIL PROTECTED]>**20050827123744] 
[posthook documentation
Jason Dagit <[EMAIL PROTECTED]>**20050825045706] 
[update building darcs section of manual.
David Roundy <[EMAIL PROTECTED]>**20050829120152] 
[add bench directory with a single script in it.
David Roundy <[EMAIL PROTECTED]>**20050828114118
 See bench/README for discussion of the idea behind this.
] 
[fix "No root path(s) specified at ..." testsuite problem.
David Roundy <[EMAIL PROTECTED]>**20050830121603] 
[Rewrite gcau, add explanatory comment from David and some TODO notes
Ian Lynagh <[EMAIL PROTECTED]>**20050830020943] 
[add test that triggers "too many open files" bug.
David Roundy <[EMAIL PROTECTED]>**20050827192215
 We just need to pull over 1024 patches at once to trigger this bug on my
 linux system.
] 
[changed from --posthook-command to posthook
Jason Dagit <[EMAIL PROTECTED]>**20050825043414] 
[now the posthook options appear for each command
Jason Dagit <[EMAIL PROTECTED]>**20050825043305] 
[posthook for apply
Jason Dagit <[EMAIL PROTECTED]>**20050803070343
 With this patch it is now possible to specify a command to run after every
 successful apply.
] 
[added run_posthook for actually running posthooks
Jason Dagit <[EMAIL PROTECTED]>**20050803070156
 This adds the function run_posthook which should be used to run posthooks.
 The code was added to Test.lhs, but there may be a better place for this code.
] 
[added posthook command line switches
Jason Dagit <[EMAIL PROTECTED]>**20050803065956
 Added generic posthook command line switches.  This patch does not add any
 posthooks to any command.
] 
[New implementation of comparePS, based on memcmp. 1/5 space usage, 96% faster
[EMAIL PROTECTED] 
[Use substrPS-less versions of initPS and tailPS
[EMAIL PROTECTED] 
[remove hideous malloc hack.
David Roundy <[EMAIL PROTECTED]>**20050818161411] 
[change my AUTHORS email to [EMAIL PROTECTED]
David Roundy <[EMAIL PROTECTED]>**20050808124703] 
[fix mkstemp implementation for win32
Peter Strand <[EMAIL PROTECTED]>**20050810211303] 
[Implement parts of System.Posix.(IO|Files) for win32
[EMAIL PROTECTED] 
[implement RawMode with library functions instead of ffi
[EMAIL PROTECTED] 
[call hsc2hs without output filename argument
[EMAIL PROTECTED] 
[Rename compat.c to c_compat.c to avoid object filename conflict with Compat.hs
[EMAIL PROTECTED] 
[Move atomic_create/sloppy_atomic_create to Compat
Ian Lynagh <[EMAIL PROTECTED]>**20050730141703] 
[Split the raw mode stuff out into its own .hsc file. Windows needs some TLC
Ian Lynagh <[EMAIL PROTECTED]>**20050730134030] 
[Move maybe_relink out of compat.c
Ian Lynagh <[EMAIL PROTECTED]>**20050730131205] 
[Remove is_symlink
Ian Lynagh <[EMAIL PROTECTED]>**20050730122255] 
[Move mkstemp to Compat.hs
Ian Lynagh <[EMAIL PROTECTED]>**20050730020918] 
[Remove unused function
Ian Lynagh <[EMAIL PROTECTED]>**20050730010118] 
[Start Compat.hs, and move stdout_is_a_pipe from compat.c
Ian Lynagh <[EMAIL PROTECTED]>**20050730004829] 
[fix compilation errors with ghc-6.2.2 on win32
Peter Strand <[EMAIL PROTECTED]>**20050809192759] 
[Retain both Git's author and committer.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20050810000820] 
[Move slurping into syncPristine.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20050809232101
 Avoids creating a useless pristine tree when there is none.  Thanks to
 Ian for pointing this out.
] 
[Split --relink into --relink and --relink-pristine.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20050809230951
 Relinking the pristine tree breaks handling of timestamps, which causes
 Darcs to compare file contents.  It should not be used unless you know
 what you are doing.
] 
[fix for bug Ian found in apply.
David Roundy <[EMAIL PROTECTED]>**20050811162558
 This is the bug manifested in the cabal repository.
] 
[Cleanup --verbose handling in repair command
Matt Lavin <[EMAIL PROTECTED]>**20050805020630] 
[clean up Printer.wrap_text.
David Roundy <[EMAIL PROTECTED]>**20050808114844] 
[add several changelog entries.
David Roundy <[EMAIL PROTECTED]>**20050808114800] 
[improve EOD message a tad.
David Roundy <[EMAIL PROTECTED]>**20050807112644
 This change also introduces a "wrapped_text" function in Printer, so we
 won't have to worry so often about manually wrapping lines.
] 
[changed ***DARCS*** to ***END OF DESCRIPTION***
Jason Dagit <[EMAIL PROTECTED]>**20050729032543] 
[remove unused opts argument from apply_patches and apply_patches_with_feedback
Matt Lavin <[EMAIL PROTECTED]>**20050807031038] 
[add code to read patch bundles with added CRs.
David Roundy <[EMAIL PROTECTED]>**20050806222631
 I think this'll address bug #291.
] 
[accept command-line flags in any order.
David Roundy <[EMAIL PROTECTED]>**20050806211828
 In particular, we no longer require that --flags precede filename and
 repository arguments.
] 
[add obliterate command as alias for unpull.
David Roundy <[EMAIL PROTECTED]>**20050804104929] 
[Do not ask confirmation for revert -a
[EMAIL PROTECTED]
 Giving -a as a parameter means the user expects all changes to be reverted.
 Just like for unrevert and record go ahead with it do not ask for confirmation.
] 
[clarify help text for 'd' in SelectPatches.
David Roundy <[EMAIL PROTECTED]>**20050806231117] 
[Add --with-static-libs configure flag for linking static versions of libraries.
[EMAIL PROTECTED] 
[add changelog entry for bug #477.
David Roundy <[EMAIL PROTECTED]>**20050806212148] 
[add description of how to add changelog entries to ChangeLog.README.
David Roundy <[EMAIL PROTECTED]>**20050806225901] 
[Explain the missing ChangeLog
Mark Stosberg <[EMAIL PROTECTED]>**20050526135421
 
 It should be easy for casual users and contributors to view and update the
 ChangeLog.
 
 Providing a README file in the place where people are most likely to look
 provides a very useful clue.
 
 However, it's still not clear to me exactly how the system works, so I have
 left a stub to complete that documentation.
 
     Mark
 
] 
[make repair work on partial repositories.
David Roundy <[EMAIL PROTECTED]>**20050805113001] 
[Use apply_patch_with_feedback from check and repair commands
Matt Lavin <[EMAIL PROTECTED]>**20050805020830] 
[show patch numbers instead of dots on get
Matt Lavin <[EMAIL PROTECTED]>**20050804013649] 
[fix obsolete error explanation in get_extra bug.
David Roundy <[EMAIL PROTECTED]>**20050804130610] 
[simplify fix for bug 463; reuse /// from FilePathUtils
Matt Lavin <[EMAIL PROTECTED]>**20050804021130] 
[Make curl exit with error on failed downloads
[EMAIL PROTECTED] 
[Bump up AC_PREREQ version to 2.59.
[EMAIL PROTECTED] 
[fix for bug 463 (with new test)
Matt Lavin <[EMAIL PROTECTED]>**20050802002116] 
[bump version number, since I just made a release.
David Roundy <[EMAIL PROTECTED]>**20050731190756] 
[Use simpler curl_version() function to get version string.
Kannan Goundan <[EMAIL PROTECTED]>**20050322221027] 
[fix documentation on --reorder-patches.
David Roundy <[EMAIL PROTECTED]>**20050731185406] 
[add changelog entry for bug #224.
David Roundy <[EMAIL PROTECTED]>**20050731133942] 
[fix bug when editing long comment leaves empty file.
David Roundy <[EMAIL PROTECTED]>**20050731133612] 
[changelog entry for bug #189.
David Roundy <[EMAIL PROTECTED]>**20050731132624] 
[TAG 1.0.4pre2
David Roundy <[EMAIL PROTECTED]>**20050731121029] 
Patch bundle hash:
b69704adbe1b45fca5bb01c2ce46d15b1d214cbd
_______________________________________________
darcs-devel mailing list
[email protected]
http://www.abridgegame.org/cgi-bin/mailman/listinfo/darcs-devel

Reply via email to