How does CouchDB calculate the Revision number

I'm trying to understand how CouchDB calculates the revision id for a document. I notice from the source that it's calculated by this bit of code here:

couch_util:md5(term_to_binary([Deleted, OldStart, OldRev, Body, Atts2]))

And I know that if I create a new empty document with no attachments, CouchDB always gives it a revision of 1-967a00dff5e02add41819138abb3284d which, in decimal is <<150,122,0,223,245,224,42,221,65,129,145,56,171,179,40,77>>.

However, if I type the following into the erlang prompt (false for deleted, 0 for OldStart, 0 for OldRev, an empty body and no attachments):

erlang:md5(term_to_binary([false, 0, 0, [], []])).                   

I always get

<<26,196,244,40,211,149,193,185,214,6,230,61,54,138,62,132>>

back.

So what am I doing wrong here - how can I work out the actual revision that couch generates?

7
задан kybernetikos 10 May 2011 в 18:48
поделиться