[darcs-users] [patch407] hook env vars: add some haddocks (and 3 more)

Simon Michael simon at joyful.com
Wed Oct 13 15:25:43 UTC 2010


Thanks for the review Ganesh. Hm, you may be right, I'll check. I  
moved it because the code read as if setEnvCautiously was used only  
within its #ifdef block, which tripped me up when refactoring. And  
secondly because it seems like a utility that's not windows-specific  
and advisable to use elsewhere. I could add an annotation to silence  
this warning ? Otherwise redo the two patches I guess.

On Oct 9, 2010, at 8:18 AM, Ganesh Sittampalam wrote:
> I don't understand the point of this - you've moved some code that's
> only used under #ifndef WIN32 outside the scope of that guard. Won't
> that just make warnings on WIN32?


On Oct 1, 2010, at 5:11 PM, Simon Michael wrote:
> [hook env vars: clarify some conditional code
> Simon Michael <simon at joyful.com>**20101001220149
> Ignore-this: 950ea31d46c94c3cb9df8905c3e86503
> ] hunk ./src/Darcs/Arguments.lhs 1580
>                       finishedOneIO k "DARCS_FILES"
>                       setEnvCautiously "DARCS_FILES" (unlines$  
> listTouchedFiles ps)
>                       endTedious k
> -
> --- | Set some environment variable to the given value, unless said  
> value
> --- is longer than 10K in which case do nothing.
> -setEnvCautiously :: String -> String -> IO ()
> -setEnvCautiously e v | toobig (10*1024) v = return ()
> -                     | otherwise = setEnv e v True
> -    where toobig :: Int -> [a] -> Bool
> -          toobig 0 _ = True
> -          toobig _ [] = False
> -          toobig n (_:xs) = toobig (n-1) xs
> #else
> definePatches _ = return ()
> #endif
> hunk ./src/Darcs/Arguments.lhs 1593
> defineChanges _ = return ()
> #endif
>
> +-- | Set some environment variable to the given value, unless said  
> value
> +-- is longer than 10K characters, in which case do nothing.
> +setEnvCautiously :: String -> String -> IO ()
> +setEnvCautiously e v | toobig (10*1024) v = return ()
> +                     | otherwise = setEnv e v True
> +    where toobig :: Int -> [a] -> Bool
> +          toobig 0 _ = True
> +          toobig _ [] = False
> +          toobig n (_:xs) = toobig (n-1) xs
> +
> posthookCmd :: DarcsOption
> posthookCmd = DarcsMultipleChoiceOption
>                [DarcsArgOption [] ["posthook"] PosthookCmd




More information about the darcs-users mailing list