[darcs-users] Patch hash calculation

Tomasz Zielonka t.zielonka at students.mimuw.edu.pl
Thu Nov 4 07:00:11 UTC 2004


On Wed, Nov 03, 2004 at 02:44:29PM -0800, Kannan Goundan wrote:
> I tried renaming a patch by going into the _darcs directory and
> editing the "inventory" file and the patch file.  Now, "darcs repair"
> tells me that it couldn't read my patches.  I'm guessing that this is
> because the checksum doesn't match.
> 
> Looking at the sources it looks like SHA1 is being used.  I tried
> giving the "sha1sum" utility various subsets of the patch text but
> couldn't match it up with Darcs's checksum.  Does anybody know how to
> calculate the checksum for a patch text?

SHA1 is calculated only from the "patch info" part of the patch, but
looking at the code I think I will be difficult to prepare the input
for SHA1 by hand.

If you have GHC, you can save that patch info to a file. This will
look like this:

[added
Tomasz Zielonka <t.zielonka at students.mimuw.edu.pl>**20041103084531]

Then:

$ make ghci
...
Prelude Main> :m PatchInfo
Prelude PatchInfo> cs <- readFile "/tmp/patchinfo"
Prelude PatchInfo> let ps = FastPackedString.packString cs
Loading package haskell98 ... linking ... done.
Prelude PatchInfo> let Just (pi, _) = readPatchInfoPS ps
Prelude PatchInfo> make_filename pi
"20041103084531-4c5ba-8db887d56037b6d05a8ac19e0d3b2e6a40d3259e.gz"

Voila!

If you don't have GHC, send me the patch info and I will calculate it
for you.

> If there's another way to rename patches (without modifying the
> timestamp), then that would work too.

That's not supposed to work, so I guess no...

I guess it would be easier to change the name of patch in a patch
bundle, but you would have to recalculate the SHA1 of the bundle.
It would be quite easy to make a program that would read the patch
bundle ignoring the checksum and spit it out with a fixed SHA1.
I've even done that yesterday, but for different reason.

Best regards,
Tomasz

-- 
.signature: Too many levels of symbolic links




More information about the darcs-users mailing list