[darcs-devel] Idea: a new type of patch

Ian Lynagh igloo at earth.li
Sat Apr 30 17:19:01 PDT 2005


On Sat, Apr 30, 2005 at 08:44:07AM -0400, David Roundy wrote:
> 
> If we store the filename in the inventory, it isn't hard to make the
> filename be the hash of its contents--except I guess that this would ruin
> our lazy patch writing.  :( Ian, how hard is it to compute a sha1 "as you
> go"? In particular, could you implement a
> 
> writeSha1File :: Doc -> IO PackedString
> 
> which writes (consuming the Doc as it goes) to a temporary file, computing
> the sha1 of the file as it is written, and then renames the temporary file
> based on the computed sha1, and returns that sha1 as its return value? You
> could of course choose a different return type, such as String or FilePath
> or even FileName.

One way would be to pass sha1 a function [Word8] -> IO () to apply to
each block of however many Word8s it is it uses at once. It's a bit ugly
due to padding and endianess, though. Also, it currently works on PS,
not Doc.

It would be simpler to write to a temporary file, then (lazily) read it
in again to compute the PS. I wouldn't even be surprised if this was
faster.


Thanks
Ian





More information about the darcs-devel mailing list