Tony,

Thanks for your patch.

I'm forwarding it tod darcs-devel, so the list can review it.

                                        Juliusz
New patches:

[Add "--[no-]check-patch" option and "checkpatch" pref for darcs record.
Tony Garnock-Jones <[EMAIL PROTECTED]>**20060509194639] {
hunk ./DarcsArguments.lhs 64
+                        checkpatch_cmd
hunk ./DarcsArguments.lhs 112
+get_content (CheckPatchCmd s) = Just s
hunk ./DarcsArguments.lhs 1107
+\begin{code}
+checkpatch_cmd :: DarcsOption
+checkpatch_cmd = DarcsMultipleChoiceOption
+                 [DarcsArgOption [] ["check-patch"] CheckPatchCmd
+                 "COMMAND" "specify command to run over the patch",
+                 DarcsNoArgOption [] ["no-check-patch"] NoCheckPatch
+                 "Do not run check-patch command."]
+\end{code}
hunk ./DarcsFlags.lhs 70
+               | CheckPatchCmd String | NoCheckPatch
hunk ./Record.lhs 28
-import IO ( hGetContents, stdin )
+import IO ( hGetContents, hFlush, stdin )
hunk ./Record.lhs 33
-import Maybe ( isJust )
+import Maybe ( isJust, listToMaybe )
hunk ./Record.lhs 36
-import Lock ( readBinFile, writeBinFile, world_readable_temp )
+import Lock ( readBinFile, writeBinFile, world_readable_temp, withOpenTemp )
hunk ./Record.lhs 62
-import Printer ( hPutDocLn, text, wrap_text, ($$), renderString )
+import Printer ( hPutDoc, hPutDocLn, text, wrap_text, ($$), renderString )
+import PatchShow ( showPatch )
+import RepoPrefs ( get_prefval )
hunk ./Record.lhs 106
-                                               umask_option]}
+                                               umask_option,
+                                               checkpatch_cmd]}
hunk ./Record.lhs 181
+get_checkpatch_cmd :: [DarcsFlag] -> IO (Maybe String)
+get_checkpatch_cmd opts = if NoCheckPatch `elem` opts
+                          then return Nothing
+                          else case listToMaybe [x | (CheckPatchCmd x) <- opts] of
+                                 Nothing -> get_prefval "checkpatch"
+                                 Just cmd -> return $ Just cmd
+
+do_check_patch :: String -> Patch -> IO ExitCode
+do_check_patch command mypatch =
+    withOpenTemp $ (\(h, f) -> do
+                      hPutDoc h $ showPatch mypatch
+                      hFlush h
+                      system (command ++ " " ++ f))
+
+check_patch :: [DarcsFlag] -> Patch -> IO ExitCode
+check_patch opts mypatch =
+    let (logMessage, _, _) = loggers opts in
+    do maybeCmd <- get_checkpatch_cmd opts
+       case maybeCmd of
+         Nothing -> return ExitSuccess
+         Just command -> do
+           when (Verbose `elem` opts) $
+                logMessage "Checking the patch..."
+           if (NoCheckPatch `elem` opts)
+             then return ExitSuccess
+             else do_check_patch command mypatch
+
+check_patch_or_die :: [DarcsFlag] -> Patch -> IO ()
+check_patch_or_die opts mypatch =
+    let (logMessage, logError, _) = loggers opts in
+    do ec <- check_patch opts mypatch
+       when (Verbose `elem` opts) $
+            logMessage $ "Patch checking returned " ++ show ec
+       when (ec /= ExitSuccess) $ do
+         logError "Patch checking failed. Patch not recorded."
+         exitWith $ ExitFailure 1
+
hunk ./Record.lhs 227
+                 check_patch_or_die opts mypatch
hunk ./Record.lhs 544
+\begin{options}
+--check-patch=COMMAND, --no-check-patch
+\end{options}
+
+To scrutinize each patch before recording it in the local repository,
+supply a command with \verb!--check-patch!. Immediately before
+\verb!darcs record! stores a patch in the repository, the command is
+invoked via the shell with a filename as its argument. The named file
+contains the patch that will be recorded. The command may examine the
+contents of the file, and once it has made a decision on whether to
+accept the patch or not, it should exit with zero exit status if the
+patch is to be accepted, or non-zero exit status to reject the patch.
+
+This is can be used, for instance, to ensure that log messages mention
+any appropriate bug numbers for the changes being recorded in the
+patch.
+
+Note there is a corresponding preference, ``\verb!checkpatch!'', which
+when set with \verb!darcs setpref! allows the master repository to
+supply a version-controlled default setting for this option for all
+checkouts.
+
hunk ./SetPref.lhs 58
-valid_pref_data = ["test", "predist", "boringfile", "binariesfile"]
+valid_pref_data = ["test", "predist", "boringfile", "binariesfile", "checkpatch"]
hunk ./SetPref.lhs 70
+\item ``checkpatch'' --- a command to run prior to recording a patch
+  with ``\verb!darcs record!''.
}

Context:

[fix error is is_pipe test in error reporting. (fixes Issue160)
David Roundy <[EMAIL PROTECTED]>**20060501142114
 The trouble was that Ian (quite naturally) assumed that my C function
 stdout_is_a_pipe returned nonzero for true, whereas for some very, very
 backwards reason it returned zero for true, and its result was properly
 interpreted.  So I caused this bug by my (unexplained) backwards
 programming, but it was introduced when Ian refactored the C code.  :(
] 
[Add forgotten file umask.h.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20060423174844] 
[Add --umask to all commands that write to the current repository.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20060407195655] 
[Add option --umask.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20060407194552] 
[Actually switch umasks in withRepoLock.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20060407194202] 
[Implement withUMask.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20060407193312] 
[Add umask.c.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20060407193255] 
[Propagate opts to withRepoLock.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20060325190622] 
[Test pull.pl, CREATE_DIR_ERROR: removed TODO now that directory name is printed in error message
Marnix Klooster <[EMAIL PROTECTED]>**20060304164033
 Also removes a superfluous (and erroneous) chdir statement, which tried to
 change to non-existing directory templ (last character was ell instead of one).
 
 Also improves the description of this test.
] 
[TAG 1.0.7pre1
Tommy Pettersson <[EMAIL PROTECTED]>**20060427095905] 
Patch bundle hash:
095a01de473ae57017dd6d9fd80abd2e335f2a0b
_______________________________________________
darcs-devel mailing list
[email protected]
http://www.abridgegame.org/cgi-bin/mailman/listinfo/darcs-devel

Reply via email to