From dev-return-21325-apmail-couchdb-dev-archive=couchdb.apache.org@couchdb.apache.org Tue Mar 6 15:28:35 2012 Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 821EE98FD for ; Tue, 6 Mar 2012 15:28:35 +0000 (UTC) Received: (qmail 25808 invoked by uid 500); 6 Mar 2012 15:28:35 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 25660 invoked by uid 500); 6 Mar 2012 15:28:34 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 25651 invoked by uid 99); 6 Mar 2012 15:28:34 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Mar 2012 15:28:34 +0000 Received: from localhost (HELO mail-gy0-f180.google.com) (127.0.0.1) (smtp-auth username rnewson, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Mar 2012 15:28:34 +0000 Received: by ghbz12 with SMTP id z12so2629646ghb.11 for ; Tue, 06 Mar 2012 07:28:33 -0800 (PST) Received-SPF: pass (google.com: domain of rnewson@apache.org designates 10.50.216.201 as permitted sender) client-ip=10.50.216.201; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rnewson@apache.org designates 10.50.216.201 as permitted sender) smtp.mail=rnewson@apache.org Received: from mr.google.com ([10.50.216.201]) by 10.50.216.201 with SMTP id os9mr10755483igc.22.1331047713212 (num_hops = 1); Tue, 06 Mar 2012 07:28:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.216.201 with SMTP id os9mr8971771igc.22.1331047713197; Tue, 06 Mar 2012 07:28:33 -0800 (PST) Received: by 10.42.196.195 with HTTP; Tue, 6 Mar 2012 07:28:32 -0800 (PST) In-Reply-To: <5293620AC1A91649BDD85E5380BC837A79A74A@uksrpblkexb02.detica.com> References: <5293620AC1A91649BDD85E5380BC837A79A74A@uksrpblkexb02.detica.com> Date: Tue, 6 Mar 2012 15:28:32 +0000 Message-ID: Subject: Re: -- Revision ID Calculation -- and -- Request for edit permissions on wiki -- From: Robert Newson To: dev@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Presumably you're reading this; new_revid(#doc{body=Body,revs={OldStart,OldRevs}, atts=Atts,deleted=Deleted}) -> case [{N, T, M} || #att{name=N,type=T,md5=M} <- Atts, M =/= <<>>] of Atts2 when length(Atts) =/= length(Atts2) -> % We must have old style non-md5 attachments ?l2b(integer_to_list(couch_util:rand32())); Atts2 -> OldRev = case OldRevs of [] -> 0; [OldRev0|_] -> OldRev0 end, couch_util:md5(term_to_binary([Deleted, OldStart, OldRev, Body, Atts2])) end. Which, basically, means we add in the md5's of the attachments if we have them (and a random value if we don't). In any case, you don't need to slavishly reimplement the current _rev algorithm to interoperate correctly. The previous revision calculation was just a random value, after all. If you include your wiki username I can grant you edit access. B. P.S Who in the world would think of printing an email? On 6 March 2012 14:58, Davies, Owain wrote: > Hi, > > I have just joined this list. I am using CouchDB to do an offline web > app. I am having to re-implement some of the logic for conflict > detection, win determination and replication. I have implemented a > dojo.store that represents that CouchDB API, and am working on the > offline versions using IndexDB and WebSQL as the persistence provider. > > First off, please could somebody let me have edit permissions to the > wiki. I am finding lots of undocumented features, or features documented > in one place but not another. A prime example is _changes?style=all_docs > which has taken me some time to discover. Of course, one I knew what it > was called I found it documented in the couchdb guide. Anyhow, I > digress, if I get edit permissions I will endeavour to record my > changes. > > Second, can somebody please tell me how the revision id for documents > with attachments are calculated. I have produced a JavaScript module > that consistently calculates the revision of documents without > attachments. I had to reverse engineer erlangs term_to_binary function, > which is actually quite tricky. But I do not know erlang and I do not > understand how the Atts2 term is calculated. Any help? > > Kind regards, > > Owain > > > Please consider the environment before printing this email. > > This message should be regarded as confidential. If you have received this email in error please notify the sender and destroy it immediately. > > Statements of intent shall only become binding when confirmed in hard copy by an authorised signatory. > > The contents of this email may relate to dealings with other companies under the control of BAE Systems plc details of which can be found at http://www.baesystems.com/Businesses/index.htm. > > Detica Limited is a BAE Systems company trading as BAE Systems Detica. > Detica Limited is registered in England and Wales under No: 1337451. > Registered office: Surrey Research Park, Guildford, Surrey, GU2 7YP, England. >