[darcs-devel] darcs patch: Add some rudimentary amend-record + meta... (and 19 more)

David Roundy droundy at darcs.net
Thu Aug 2 14:03:24 PDT 2007


On Thu, Aug 02, 2007 at 10:23:01PM +0200, Eric Kow wrote:
> +\begin{code}
> +show_contents_cmd :: [DarcsFlag] -> [String] -> IO ()
> +show_contents_cmd opts args = do
> +  formerdir <- getCurrentDirectory
> +  repository <- identifyRepository opts "."
> +  thename <- return $ just_dir formerdir
> +  withTempDir thename $ \dir -> do
> +     if have_nonrange_match opts
> +        then withCurrentDirectory dir $
> +               apply_patches_to_some_files repository path_list $ get_nonrange_match_s opts
> +        else withCurrentDirectory formerdir $
> +               do pris <- identifyPristine
> +                  createPartialsPristineDirectoryTree opts path_list pris dir
> +     filterM doesFileExist path_list >>= mapM_ (\f -> readFile f >>= putStr)
> +  where
> +    path_list = if null args then [""] else map (fix_filepath "" opts) args
> +\end{code}

I wonder if it might be better in terms of efficiency to apply patches to
Slurpies.  Maybe not, as that could lead to holding more patches in
memory... still it seems a little silly to write the file contents to disk
and then re-read it.

Also, I noticed that the documentation said show contents accepted [FILE or
DIRECTORY] arguments, but only files actually work (as far as I can see).
I think it's reasonable to give directory arguments and expect a listing of
files in that directory... but maybe better to keep this simple.
-- 
David Roundy
Department of Physics
Oregon State University


More information about the darcs-devel mailing list