File Annotation
Not logged in
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Copyright (c) 2007 D. Richard Hipp
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** This program is free software; you can redistribute it and/or
dbda8d6ce9 2007-07-21       drh: ** modify it under the terms of the GNU General Public
dbda8d6ce9 2007-07-21       drh: ** License version 2 as published by the Free Software Foundation.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** This program is distributed in the hope that it will be useful,
dbda8d6ce9 2007-07-21       drh: ** but WITHOUT ANY WARRANTY; without even the implied warranty of
dbda8d6ce9 2007-07-21       drh: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dbda8d6ce9 2007-07-21       drh: ** General Public License for more details.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** You should have received a copy of the GNU General Public
dbda8d6ce9 2007-07-21       drh: ** License along with this library; if not, write to the
dbda8d6ce9 2007-07-21       drh: ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
dbda8d6ce9 2007-07-21       drh: ** Boston, MA  02111-1307, USA.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** Author contact information:
dbda8d6ce9 2007-07-21       drh: **   drh@hwaci.com
dbda8d6ce9 2007-07-21       drh: **   http://www.hwaci.com/drh/
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: *******************************************************************************
dbda8d6ce9 2007-07-21       drh: **
3b5514ed82 2007-09-22       drh: ** This file contains code used to cross link control files and
09c4adeb6f 2007-09-22       drh: ** manifests.  The file is named "manifest.c" because it was
09c4adeb6f 2007-09-22       drh: ** original only used to parse manifests.  Then later clusters
09c4adeb6f 2007-09-22       drh: ** and control files were added.
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: #include "config.h"
dbda8d6ce9 2007-07-21       drh: #include "manifest.h"
dbda8d6ce9 2007-07-21       drh: #include <assert.h>
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: #if INTERFACE
dbda8d6ce9 2007-07-21       drh: /*
3b5514ed82 2007-09-22       drh: ** Types of control files
3b5514ed82 2007-09-22       drh: */
3b5514ed82 2007-09-22       drh: #define CFTYPE_MANIFEST   1
3b5514ed82 2007-09-22       drh: #define CFTYPE_CLUSTER    2
3b5514ed82 2007-09-22       drh: #define CFTYPE_CONTROL    3
3b5514ed82 2007-09-22       drh: 
3b5514ed82 2007-09-22       drh: /*
ba486fec5a 2007-09-03       drh: ** A parsed manifest or cluster.
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: struct Manifest {
dbda8d6ce9 2007-07-21       drh:   Blob content;         /* The original content blob */
3b5514ed82 2007-09-22       drh:   int type;             /* Type of file */
dbda8d6ce9 2007-07-21       drh:   char *zComment;       /* Decoded comment */
09c4adeb6f 2007-09-22       drh:   char zUuid[UUID_SIZE+1];  /* Self UUID */
dbda8d6ce9 2007-07-21       drh:   double rDate;         /* Time in the "D" line */
dbda8d6ce9 2007-07-21       drh:   char *zUser;          /* Name of the user */
dbda8d6ce9 2007-07-21       drh:   char *zRepoCksum;     /* MD5 checksum of the baseline content */
dbda8d6ce9 2007-07-21       drh:   int nFile;            /* Number of F lines */
dbda8d6ce9 2007-07-21       drh:   int nFileAlloc;       /* Slots allocated in aFile[] */
dbda8d6ce9 2007-07-21       drh:   struct {
dbda8d6ce9 2007-07-21       drh:     char *zName;           /* Name of a file */
dbda8d6ce9 2007-07-21       drh:     char *zUuid;           /* UUID of the file */
dbda8d6ce9 2007-07-21       drh:   } *aFile;
dbda8d6ce9 2007-07-21       drh:   int nParent;          /* Number of parents */
dbda8d6ce9 2007-07-21       drh:   int nParentAlloc;     /* Slots allocated in azParent[] */
dbda8d6ce9 2007-07-21       drh:   char **azParent;      /* UUIDs of parents */
ba486fec5a 2007-09-03       drh:   int nCChild;          /* Number of cluster children */
ba486fec5a 2007-09-03       drh:   int nCChildAlloc;     /* Number of closts allocated in azCChild[] */
ba486fec5a 2007-09-03       drh:   char **azCChild;      /* UUIDs of referenced objects in a cluster */
3dc92fdb7f 2007-09-21       drh:   int nTag;             /* Number of T lines */
3dc92fdb7f 2007-09-21       drh:   int nTagAlloc;        /* Slots allocated in aTag[] */
3dc92fdb7f 2007-09-21       drh:   struct {
3dc92fdb7f 2007-09-21       drh:     char *zName;           /* Name of the tag */
3dc92fdb7f 2007-09-21       drh:     char *zUuid;           /* UUID that the tag is applied to */
f73c0e792b 2007-09-22       drh:     char *zValue;          /* Value if the tag is really a property */
3dc92fdb7f 2007-09-21       drh:   } *aTag;
dbda8d6ce9 2007-07-21       drh: };
dbda8d6ce9 2007-07-21       drh: #endif
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Clear the memory allocated in a manifest object
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: void manifest_clear(Manifest *p){
dbda8d6ce9 2007-07-21       drh:   blob_reset(&p->content);
dbda8d6ce9 2007-07-21       drh:   free(p->aFile);
dbda8d6ce9 2007-07-21       drh:   free(p->azParent);
ba486fec5a 2007-09-03       drh:   free(p->azCChild);
dbda8d6ce9 2007-07-21       drh:   memset(p, 0, sizeof(*p));
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Parse a manifest blob into a Manifest object.  The Manifest
dbda8d6ce9 2007-07-21       drh: ** object takes over the input blob and will free it when the
dbda8d6ce9 2007-07-21       drh: ** Manifest object is freed.  Zeros are inserted into the blob
dbda8d6ce9 2007-07-21       drh: ** as string terminators so that blob should not be used again.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** Return TRUE if the content really is a manifest.  Return FALSE
dbda8d6ce9 2007-07-21       drh: ** if there are syntax errors.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** The pContent is reset.  If TRUE is returned, then pContent will
dbda8d6ce9 2007-07-21       drh: ** be reset when the Manifest object is cleared.  If FALSE is
dbda8d6ce9 2007-07-21       drh: ** returned then the Manifest object is cleared automatically
dbda8d6ce9 2007-07-21       drh: ** and pContent is reset before the return.
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: int manifest_parse(Manifest *p, Blob *pContent){
dbda8d6ce9 2007-07-21       drh:   int seenHeader = 0;
2ad378d065 2007-09-23       jnc:   int i, lineNo=0;
dbda8d6ce9 2007-07-21       drh:   Blob line, token, a1, a2, a3;
09c4adeb6f 2007-09-22       drh:   Blob selfuuid;
dea1ae50d3 2007-09-23       drh:   char cPrevType = 0;
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   memset(p, 0, sizeof(*p));
dbda8d6ce9 2007-07-21       drh:   memcpy(&p->content, pContent, sizeof(p->content));
09c4adeb6f 2007-09-22       drh:   sha1sum_blob(&p->content, &selfuuid);
09c4adeb6f 2007-09-22       drh:   memcpy(p->zUuid, blob_buffer(&selfuuid), UUID_SIZE);
09c4adeb6f 2007-09-22       drh:   p->zUuid[UUID_SIZE] = 0;
dbda8d6ce9 2007-07-21       drh:   blob_zero(pContent);
dbda8d6ce9 2007-07-21       drh:   pContent = &p->content;
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   blob_zero(&a1);
dbda8d6ce9 2007-07-21       drh:   blob_zero(&a2);
dbda8d6ce9 2007-07-21       drh:   md5sum_init();
dbda8d6ce9 2007-07-21       drh:   while( blob_line(pContent, &line) ){
dbda8d6ce9 2007-07-21       drh:     char *z = blob_buffer(&line);
2ad378d065 2007-09-23       jnc:     lineNo++;
dbda8d6ce9 2007-07-21       drh:     if( z[0]=='-' ){
dbda8d6ce9 2007-07-21       drh:       if( strncmp(z, "-----BEGIN PGP ", 15)!=0 ){
dbda8d6ce9 2007-07-21       drh:         goto manifest_syntax_error;
dbda8d6ce9 2007-07-21       drh:       }
dbda8d6ce9 2007-07-21       drh:       if( seenHeader ){
dbda8d6ce9 2007-07-21       drh:         break;
dbda8d6ce9 2007-07-21       drh:       }
f030c0aea7 2007-08-30       drh:       while( blob_line(pContent, &line)>2 ){}
dbda8d6ce9 2007-07-21       drh:       if( blob_line(pContent, &line)==0 ) break;
e37451d9c2 2007-08-01       drh:       z = blob_buffer(&line);
e37451d9c2 2007-08-01       drh:     }
dea1ae50d3 2007-09-23       drh:     if( z[0]<cPrevType ){
3dc92fdb7f 2007-09-21       drh:       /* Lines of a manifest must occur in lexicographical order */
3dc92fdb7f 2007-09-21       drh:       goto manifest_syntax_error;
dbda8d6ce9 2007-07-21       drh:     }
dea1ae50d3 2007-09-23       drh:     cPrevType = z[0];
dbda8d6ce9 2007-07-21       drh:     seenHeader = 1;
dbda8d6ce9 2007-07-21       drh:     if( blob_token(&line, &token)!=1 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:     switch( z[0] ){
3dc92fdb7f 2007-09-21       drh:       /*
3dc92fdb7f 2007-09-21       drh:       **     C <comment>
3dc92fdb7f 2007-09-21       drh:       **
3dc92fdb7f 2007-09-21       drh:       ** Comment text is fossil-encoded.  There may be no more than
3dc92fdb7f 2007-09-21       drh:       ** one C line.  C lines are required for manifests and are
3dc92fdb7f 2007-09-21       drh:       ** disallowed on all other control files.
3dc92fdb7f 2007-09-21       drh:       */
3dc92fdb7f 2007-09-21       drh:       case 'C': {
3dc92fdb7f 2007-09-21       drh:         md5sum_step_text(blob_buffer(&line), blob_size(&line));
3dc92fdb7f 2007-09-21       drh:         if( p->zComment!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         p->zComment = blob_terminate(&a1);
3dc92fdb7f 2007-09-21       drh:         defossilize(p->zComment);
3dc92fdb7f 2007-09-21       drh:         break;
3dc92fdb7f 2007-09-21       drh:       }
3dc92fdb7f 2007-09-21       drh: 
3dc92fdb7f 2007-09-21       drh:       /*
3dc92fdb7f 2007-09-21       drh:       **     D <timestamp>
3dc92fdb7f 2007-09-21       drh:       **
3dc92fdb7f 2007-09-21       drh:       ** The timestamp should be ISO 8601.   YYYY-MM-DDtHH:MM:SS
3dc92fdb7f 2007-09-21       drh:       ** There can be no more than 1 D line.  D lines are required
3dc92fdb7f 2007-09-21       drh:       ** for all control files except for clusters.
3dc92fdb7f 2007-09-21       drh:       */
3dc92fdb7f 2007-09-21       drh:       case 'D': {
3dc92fdb7f 2007-09-21       drh:         char *zDate;
3dc92fdb7f 2007-09-21       drh:         md5sum_step_text(blob_buffer(&line), blob_size(&line));
3dc92fdb7f 2007-09-21       drh:         if( p->rDate!=0.0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         zDate = blob_terminate(&a1);
3dc92fdb7f 2007-09-21       drh:         p->rDate = db_double(0.0, "SELECT julianday(%Q)", zDate);
3dc92fdb7f 2007-09-21       drh:         break;
3dc92fdb7f 2007-09-21       drh:       }
3dc92fdb7f 2007-09-21       drh: 
3dc92fdb7f 2007-09-21       drh:       /*
3dc92fdb7f 2007-09-21       drh:       **     F <filename> <uuid>
3dc92fdb7f 2007-09-21       drh:       **
3dc92fdb7f 2007-09-21       drh:       ** Identifies a file in a manifest.  Multiple F lines are
3dc92fdb7f 2007-09-21       drh:       ** allowed in a manifest.  F lines are not allowed in any
3dc92fdb7f 2007-09-21       drh:       ** other control file.  The filename is fossil-encoded.
3dc92fdb7f 2007-09-21       drh:       */
3dc92fdb7f 2007-09-21       drh:       case 'F': {
3dc92fdb7f 2007-09-21       drh:         char *zName, *zUuid;
3dc92fdb7f 2007-09-21       drh:         md5sum_step_text(blob_buffer(&line), blob_size(&line));
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a2)==0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a3)!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         zName = blob_terminate(&a1);
3dc92fdb7f 2007-09-21       drh:         zUuid = blob_terminate(&a2);
3dc92fdb7f 2007-09-21       drh:         if( blob_size(&a2)!=UUID_SIZE ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         defossilize(zName);
3dc92fdb7f 2007-09-21       drh:         if( !file_is_simple_pathname(zName) ){
3dc92fdb7f 2007-09-21       drh:           goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         }
3dc92fdb7f 2007-09-21       drh:         if( p->nFile>=p->nFileAlloc ){
3dc92fdb7f 2007-09-21       drh:           p->nFileAlloc = p->nFileAlloc*2 + 10;
3dc92fdb7f 2007-09-21       drh:           p->aFile = realloc(p->aFile, p->nFileAlloc*sizeof(p->aFile[0]) );
3dc92fdb7f 2007-09-21       drh:           if( p->aFile==0 ) fossil_panic("out of memory");
3dc92fdb7f 2007-09-21       drh:         }
3dc92fdb7f 2007-09-21       drh:         i = p->nFile++;
3dc92fdb7f 2007-09-21       drh:         p->aFile[i].zName = zName;
3dc92fdb7f 2007-09-21       drh:         p->aFile[i].zUuid = zUuid;
3dc92fdb7f 2007-09-21       drh:         if( i>0 && strcmp(p->aFile[i-1].zName, zName)>=0 ){
3dc92fdb7f 2007-09-21       drh:           goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         }
3dc92fdb7f 2007-09-21       drh:         break;
3dc92fdb7f 2007-09-21       drh:       }
3dc92fdb7f 2007-09-21       drh: 
3dc92fdb7f 2007-09-21       drh:       /*
3dc92fdb7f 2007-09-21       drh:       **    M <uuid>
3dc92fdb7f 2007-09-21       drh:       **
3dc92fdb7f 2007-09-21       drh:       ** An M-line identifies another artifact by its UUID.  M-lines
3dc92fdb7f 2007-09-21       drh:       ** occur in clusters only.
3dc92fdb7f 2007-09-21       drh:       */
3dc92fdb7f 2007-09-21       drh:       case 'M': {
dbda8d6ce9 2007-07-21       drh:         char *zUuid;
3dc92fdb7f 2007-09-21       drh:         md5sum_step_text(blob_buffer(&line), blob_size(&line));
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
dbda8d6ce9 2007-07-21       drh:         zUuid = blob_terminate(&a1);
3dc92fdb7f 2007-09-21       drh:         if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error;
dbda8d6ce9 2007-07-21       drh:         if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( p->nCChild>=p->nCChildAlloc ){
3dc92fdb7f 2007-09-21       drh:           p->nCChildAlloc = p->nCChildAlloc*2 + 10;
3dc92fdb7f 2007-09-21       drh:           p->azCChild =
3dc92fdb7f 2007-09-21       drh:              realloc(p->azCChild, p->nCChildAlloc*sizeof(p->azCChild[0]) );
3dc92fdb7f 2007-09-21       drh:           if( p->azCChild==0 ) fossil_panic("out of memory");
3dc92fdb7f 2007-09-21       drh:         }
3dc92fdb7f 2007-09-21       drh:         i = p->nCChild++;
3dc92fdb7f 2007-09-21       drh:         p->azCChild[i] = zUuid;
3dc92fdb7f 2007-09-21       drh:         if( i>0 && strcmp(p->azCChild[i-1], zUuid)>=0 ){
3dc92fdb7f 2007-09-21       drh:           goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         }
3dc92fdb7f 2007-09-21       drh:         break;
3dc92fdb7f 2007-09-21       drh:       }
3dc92fdb7f 2007-09-21       drh: 
3dc92fdb7f 2007-09-21       drh:       /*
09c4adeb6f 2007-09-22       drh:       **    T (+|*|-)<tagname> <uuid> ?<value>?
f73c0e792b 2007-09-22       drh:       **
f73c0e792b 2007-09-22       drh:       ** Create or cancel a tag or property.  The tagname is fossil-encoded.
09c4adeb6f 2007-09-22       drh:       ** The first character of the name must be either "+" to create a
09c4adeb6f 2007-09-22       drh:       ** singleton tag, "*" to create a propagating tag, or "-" to create
09c4adeb6f 2007-09-22       drh:       ** anti-tag that undoes a prior "+" or blocks propagation of of
09c4adeb6f 2007-09-22       drh:       ** a "*".
3dc92fdb7f 2007-09-21       drh:       **
09c4adeb6f 2007-09-22       drh:       ** The tag is applied to <uuid>.  If <uuid> is "*" then the tag is
09c4adeb6f 2007-09-22       drh:       ** applied to the current manifest.  If <value> is provided then
09c4adeb6f 2007-09-22       drh:       ** the tag is really a property with the given value.
09c4adeb6f 2007-09-22       drh:       **
3dc92fdb7f 2007-09-21       drh:       ** Tags are not allowed in clusters.  Multiple T lines are allowed.
3dc92fdb7f 2007-09-21       drh:       */
3dc92fdb7f 2007-09-21       drh:       case 'T': {
f73c0e792b 2007-09-22       drh:         char *zName, *zUuid, *zValue;
3dc92fdb7f 2007-09-21       drh:         md5sum_step_text(blob_buffer(&line), blob_size(&line));
2ad378d065 2007-09-23       jnc:         if( blob_token(&line, &a1)==0 ){
2ad378d065 2007-09-23       jnc:           goto manifest_syntax_error;
2ad378d065 2007-09-23       jnc:         }
2ad378d065 2007-09-23       jnc:         if( blob_token(&line, &a2)==0 ){
2ad378d065 2007-09-23       jnc:           goto manifest_syntax_error;
2ad378d065 2007-09-23       jnc:         }
3dc92fdb7f 2007-09-21       drh:         zName = blob_terminate(&a1);
3dc92fdb7f 2007-09-21       drh:         zUuid = blob_terminate(&a2);
f73c0e792b 2007-09-22       drh:         if( blob_token(&line, &a3)==0 ){
f73c0e792b 2007-09-22       drh:           zValue = 0;
f73c0e792b 2007-09-22       drh:         }else{
f73c0e792b 2007-09-22       drh:           zValue = blob_terminate(&a3);
f73c0e792b 2007-09-22       drh:           defossilize(zValue);
f73c0e792b 2007-09-22       drh:         }
09c4adeb6f 2007-09-22       drh:         if( blob_size(&a2)==UUID_SIZE && validate16(zUuid, UUID_SIZE) ){
09c4adeb6f 2007-09-22       drh:           /* A valid uuid */
09c4adeb6f 2007-09-22       drh:         }else if( blob_size(&a2)==1 && zUuid[0]=='*' ){
09c4adeb6f 2007-09-22       drh:           zUuid = p->zUuid;
09c4adeb6f 2007-09-22       drh:         }else{
09c4adeb6f 2007-09-22       drh:           goto manifest_syntax_error;
09c4adeb6f 2007-09-22       drh:         }
3dc92fdb7f 2007-09-21       drh:         defossilize(zName);
09c4adeb6f 2007-09-22       drh:         if( zName[0]!='-' && zName[0]!='+' && zName[0]!='*' ){
3b5514ed82 2007-09-22       drh:           goto manifest_syntax_error;
3b5514ed82 2007-09-22       drh:         }
3b5514ed82 2007-09-22       drh:         if( validate16(&zName[1], strlen(&zName[1])) ){
3b5514ed82 2007-09-22       drh:           /* Do not allow tags whose names look like UUIDs */
3dc92fdb7f 2007-09-21       drh:           goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         }
3dc92fdb7f 2007-09-21       drh:         if( p->nTag>=p->nTagAlloc ){
3dc92fdb7f 2007-09-21       drh:           p->nTagAlloc = p->nTagAlloc*2 + 10;
3dc92fdb7f 2007-09-21       drh:           p->aTag = realloc(p->aTag, p->nTagAlloc*sizeof(p->aTag[0]) );
3dc92fdb7f 2007-09-21       drh:           if( p->aTag==0 ) fossil_panic("out of memory");
3dc92fdb7f 2007-09-21       drh:         }
3dc92fdb7f 2007-09-21       drh:         i = p->nTag++;
3dc92fdb7f 2007-09-21       drh:         p->aTag[i].zName = zName;
3dc92fdb7f 2007-09-21       drh:         p->aTag[i].zUuid = zUuid;
f73c0e792b 2007-09-22       drh:         p->aTag[i].zValue = zValue;
3dc92fdb7f 2007-09-21       drh:         if( i>0 && strcmp(p->aTag[i-1].zName, zName)>=0 ){
3dc92fdb7f 2007-09-21       drh:           goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         }
3dc92fdb7f 2007-09-21       drh:         break;
3dc92fdb7f 2007-09-21       drh:       }
3dc92fdb7f 2007-09-21       drh: 
3dc92fdb7f 2007-09-21       drh:       /*
3dc92fdb7f 2007-09-21       drh:       **     U <login>
3dc92fdb7f 2007-09-21       drh:       **
3dc92fdb7f 2007-09-21       drh:       ** Identify the user who created this control file by their
3dc92fdb7f 2007-09-21       drh:       ** login.  Only one U line is allowed.  Prohibited in clusters.
3dc92fdb7f 2007-09-21       drh:       */
3dc92fdb7f 2007-09-21       drh:       case 'U': {
3dc92fdb7f 2007-09-21       drh:         md5sum_step_text(blob_buffer(&line), blob_size(&line));
3dc92fdb7f 2007-09-21       drh:         if( p->zUser!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         p->zUser = blob_terminate(&a1);
3dc92fdb7f 2007-09-21       drh:         defossilize(p->zUser);
3dc92fdb7f 2007-09-21       drh:         break;
3dc92fdb7f 2007-09-21       drh:       }
3dc92fdb7f 2007-09-21       drh: 
3dc92fdb7f 2007-09-21       drh:       /*
3dc92fdb7f 2007-09-21       drh:       **     R <md5sum>
3dc92fdb7f 2007-09-21       drh:       **
3dc92fdb7f 2007-09-21       drh:       ** Specify the MD5 checksum of the entire baseline in a
3dc92fdb7f 2007-09-21       drh:       ** manifest.
3dc92fdb7f 2007-09-21       drh:       */
3dc92fdb7f 2007-09-21       drh:       case 'R': {
3dc92fdb7f 2007-09-21       drh:         md5sum_step_text(blob_buffer(&line), blob_size(&line));
3dc92fdb7f 2007-09-21       drh:         if( p->zRepoCksum!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_size(&a1)!=32 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         p->zRepoCksum = blob_terminate(&a1);
3dc92fdb7f 2007-09-21       drh:         if( !validate16(p->zRepoCksum, 32) ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         break;
3dc92fdb7f 2007-09-21       drh:       }
3dc92fdb7f 2007-09-21       drh: 
3dc92fdb7f 2007-09-21       drh:       /*
3dc92fdb7f 2007-09-21       drh:       **     P <uuid> ...
3dc92fdb7f 2007-09-21       drh:       **
3dc92fdb7f 2007-09-21       drh:       ** Specify one or more other artifacts where are the parents of
3dc92fdb7f 2007-09-21       drh:       ** this artifact.  The first parent is the primary parent.  All
3dc92fdb7f 2007-09-21       drh:       ** others are parents by merge.
3dc92fdb7f 2007-09-21       drh:       */
3dc92fdb7f 2007-09-21       drh:       case 'P': {
3dc92fdb7f 2007-09-21       drh:         md5sum_step_text(blob_buffer(&line), blob_size(&line));
3dc92fdb7f 2007-09-21       drh:         while( blob_token(&line, &a1) ){
3dc92fdb7f 2007-09-21       drh:           char *zUuid;
3dc92fdb7f 2007-09-21       drh:           if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:           zUuid = blob_terminate(&a1);
3dc92fdb7f 2007-09-21       drh:           if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:           if( p->nParent>=p->nParentAlloc ){
3dc92fdb7f 2007-09-21       drh:             p->nParentAlloc = p->nParentAlloc*2 + 5;
3dc92fdb7f 2007-09-21       drh:             p->azParent = realloc(p->azParent, p->nParentAlloc*sizeof(char*));
3dc92fdb7f 2007-09-21       drh:             if( p->azParent==0 ) fossil_panic("out of memory");
3dc92fdb7f 2007-09-21       drh:           }
3dc92fdb7f 2007-09-21       drh:           i = p->nParent++;
3dc92fdb7f 2007-09-21       drh:           p->azParent[i] = zUuid;
dbda8d6ce9 2007-07-21       drh:         }
3dc92fdb7f 2007-09-21       drh:         break;
3dc92fdb7f 2007-09-21       drh:       }
3dc92fdb7f 2007-09-21       drh: 
3dc92fdb7f 2007-09-21       drh:       /*
3dc92fdb7f 2007-09-21       drh:       **     Z <md5sum>
3dc92fdb7f 2007-09-21       drh:       **
3dc92fdb7f 2007-09-21       drh:       ** MD5 checksum on this control file.  The checksum is over all
3dc92fdb7f 2007-09-21       drh:       ** lines (other than PGP-signature lines) prior to the current
3dc92fdb7f 2007-09-21       drh:       ** line.  This must be the last record.
3dc92fdb7f 2007-09-21       drh:       */
3dc92fdb7f 2007-09-21       drh:       case 'Z': {
3dc92fdb7f 2007-09-21       drh:         int rc;
3dc92fdb7f 2007-09-21       drh:         Blob hash;
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( blob_size(&a1)!=32 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         if( !validate16(blob_buffer(&a1), 32) ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         md5sum_finish(&hash);
3dc92fdb7f 2007-09-21       drh:         rc = blob_compare(&hash, &a1);
3dc92fdb7f 2007-09-21       drh:         blob_reset(&hash);
3dc92fdb7f 2007-09-21       drh:         if( rc!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:         break;
dbda8d6ce9 2007-07-21       drh:       }
3dc92fdb7f 2007-09-21       drh:       default: {
3dc92fdb7f 2007-09-21       drh:         goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:       }
dbda8d6ce9 2007-07-21       drh:     }
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   if( !seenHeader ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh: 
3dc92fdb7f 2007-09-21       drh:   if( p->nFile>0 ){
3dc92fdb7f 2007-09-21       drh:     if( p->nCChild>0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:     if( p->rDate==0.0 ) goto manifest_syntax_error;
3b5514ed82 2007-09-22       drh:     p->type = CFTYPE_MANIFEST;
3dc92fdb7f 2007-09-21       drh:   }else if( p->nCChild>0 ){
3dc92fdb7f 2007-09-21       drh:     if( p->rDate>0.0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:     if( p->zComment!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:     if( p->zUser!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:     if( p->nTag>0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:     if( p->nParent>0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:     if( p->zRepoCksum!=0 ) goto manifest_syntax_error;
3b5514ed82 2007-09-22       drh:     p->type = CFTYPE_CLUSTER;
3dc92fdb7f 2007-09-21       drh:   }else if( p->nTag>0 ){
3dc92fdb7f 2007-09-21       drh:     if( p->rDate<=0.0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:     if( p->zRepoCksum!=0 ) goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:     if( p->nParent>0 ) goto manifest_syntax_error;
3b5514ed82 2007-09-22       drh:     p->type = CFTYPE_CONTROL;
3dc92fdb7f 2007-09-21       drh:   }else{
3dc92fdb7f 2007-09-21       drh:     goto manifest_syntax_error;
3dc92fdb7f 2007-09-21       drh:   }
3dc92fdb7f 2007-09-21       drh: 
dbda8d6ce9 2007-07-21       drh:   md5sum_init();
dbda8d6ce9 2007-07-21       drh:   return 1;
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: manifest_syntax_error:
2ad378d065 2007-09-23       jnc:   /*fprintf(stderr, "Manifest error on line %i\n", lineNo);fflush(stderr);*/
dbda8d6ce9 2007-07-21       drh:   md5sum_init();
dbda8d6ce9 2007-07-21       drh:   manifest_clear(p);
dbda8d6ce9 2007-07-21       drh:   return 0;
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Add a single entry to the mlink table.  Also add the filename to
dbda8d6ce9 2007-07-21       drh: ** the filename table if it is not there already.
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: static void add_one_mlink(
dbda8d6ce9 2007-07-21       drh:   int mid,                  /* The record ID of the manifest */
dbda8d6ce9 2007-07-21       drh:   const char *zFromUuid,    /* UUID for the mlink.pid field */
dbda8d6ce9 2007-07-21       drh:   const char *zToUuid,      /* UUID for the mlink.fid field */
dbda8d6ce9 2007-07-21       drh:   const char *zFilename     /* Filename */
dbda8d6ce9 2007-07-21       drh: ){
dbda8d6ce9 2007-07-21       drh:   int fnid, pid, fid;
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
dbda8d6ce9 2007-07-21       drh:   if( fnid==0 ){
dbda8d6ce9 2007-07-21       drh:     db_multi_exec("INSERT INTO filename(name) VALUES(%Q)", zFilename);
dbda8d6ce9 2007-07-21       drh:     fnid = db_last_insert_rowid();
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   if( zFromUuid==0 ){
dbda8d6ce9 2007-07-21       drh:     pid = 0;
dbda8d6ce9 2007-07-21       drh:   }else{
dbda8d6ce9 2007-07-21       drh:     pid = uuid_to_rid(zFromUuid, 1);
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   if( zToUuid==0 ){
dbda8d6ce9 2007-07-21       drh:     fid = 0;
dbda8d6ce9 2007-07-21       drh:   }else{
dbda8d6ce9 2007-07-21       drh:     fid = uuid_to_rid(zToUuid, 1);
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   db_multi_exec(
dbda8d6ce9 2007-07-21       drh:     "INSERT INTO mlink(mid,pid,fid,fnid)"
dbda8d6ce9 2007-07-21       drh:     "VALUES(%d,%d,%d,%d)", mid, pid, fid, fnid
dbda8d6ce9 2007-07-21       drh:   );
dbda8d6ce9 2007-07-21       drh:   if( pid && fid ){
dbda8d6ce9 2007-07-21       drh:     content_deltify(pid, fid, 0);
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Add mlink table entries associated with manifest cid.
dbda8d6ce9 2007-07-21       drh: ** There is an mlink entry for every file that changed going
dbda8d6ce9 2007-07-21       drh: ** from pid to cid.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** Deleted files have mlink.fid=0.
dbda8d6ce9 2007-07-21       drh: ** Added files have mlink.pid=0.
dbda8d6ce9 2007-07-21       drh: ** Edited files have both mlink.pid!=0 and mlink.fid!=0
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: static void add_mlink(int pid, Manifest *pParent, int cid, Manifest *pChild){
dbda8d6ce9 2007-07-21       drh:   Manifest other;
dbda8d6ce9 2007-07-21       drh:   Blob otherContent;
dbda8d6ce9 2007-07-21       drh:   int i, j;
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   if( db_exists("SELECT 1 FROM mlink WHERE mid=%d", cid) ){
dbda8d6ce9 2007-07-21       drh:     return;
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   assert( pParent==0 || pChild==0 );
dbda8d6ce9 2007-07-21       drh:   if( pParent==0 ){
dbda8d6ce9 2007-07-21       drh:     pParent = &other;
dbda8d6ce9 2007-07-21       drh:     content_get(pid, &otherContent);
dbda8d6ce9 2007-07-21       drh:   }else{
dbda8d6ce9 2007-07-21       drh:     pChild = &other;
dbda8d6ce9 2007-07-21       drh:     content_get(cid, &otherContent);
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   if( blob_size(&otherContent)==0 ) return;
dbda8d6ce9 2007-07-21       drh:   if( manifest_parse(&other, &otherContent)==0 ) return;
dbda8d6ce9 2007-07-21       drh:   content_deltify(pid, cid, 0);
5b58559c0c 2007-07-31       drh:   for(i=j=0; i<pParent->nFile && j<pChild->nFile; ){
dbda8d6ce9 2007-07-21       drh:     int c = strcmp(pParent->aFile[i].zName, pChild->aFile[j].zName);
dbda8d6ce9 2007-07-21       drh:     if( c<0 ){
dbda8d6ce9 2007-07-21       drh:       add_one_mlink(cid, pParent->aFile[i].zUuid, 0, pParent->aFile[i].zName);
dbda8d6ce9 2007-07-21       drh:       i++;
dbda8d6ce9 2007-07-21       drh:     }else if( c>0 ){
dbda8d6ce9 2007-07-21       drh:       add_one_mlink(cid, 0, pChild->aFile[j].zUuid, pChild->aFile[j].zName);
dbda8d6ce9 2007-07-21       drh:       j++;
dbda8d6ce9 2007-07-21       drh:     }else{
dbda8d6ce9 2007-07-21       drh:       if( strcmp(pParent->aFile[i].zUuid, pChild->aFile[j].zUuid)!=0 ){
dbda8d6ce9 2007-07-21       drh:       add_one_mlink(cid, pParent->aFile[i].zUuid, pChild->aFile[j].zUuid,
dbda8d6ce9 2007-07-21       drh:                     pChild->aFile[j].zName);
dbda8d6ce9 2007-07-21       drh:       }
dbda8d6ce9 2007-07-21       drh:       i++;
dbda8d6ce9 2007-07-21       drh:       j++;
dbda8d6ce9 2007-07-21       drh:     }
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   while( i<pParent->nFile ){
dbda8d6ce9 2007-07-21       drh:     add_one_mlink(cid, pParent->aFile[i].zUuid, 0, pParent->aFile[i].zName);
dbda8d6ce9 2007-07-21       drh:     i++;
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   while( j<pChild->nFile ){
dbda8d6ce9 2007-07-21       drh:     add_one_mlink(cid, 0, pChild->aFile[j].zUuid, pChild->aFile[j].zName);
dbda8d6ce9 2007-07-21       drh:     j++;
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   manifest_clear(&other);
dbda8d6ce9 2007-07-21       drh: }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Scan record rid/pContent to see if it is a manifest.  If
573a464cb7 2007-08-10       drh: ** it is a manifest, then populate the mlink, plink,
dbda8d6ce9 2007-07-21       drh: ** filename, and event tables with cross-reference information.
ba486fec5a 2007-09-03       drh: **
ba486fec5a 2007-09-03       drh: ** (Later:) Also check to see if pContent is a cluster.  If it
ba486fec5a 2007-09-03       drh: ** is a cluster then remove all referenced elements from the
ba486fec5a 2007-09-03       drh: ** unclustered table and create phantoms for any unknown elements.
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: int manifest_crosslink(int rid, Blob *pContent){
dbda8d6ce9 2007-07-21       drh:   int i;
dbda8d6ce9 2007-07-21       drh:   Manifest m;
dbda8d6ce9 2007-07-21       drh:   Stmt q;
913608a5a6 2007-09-25       drh:   int parentid = 0;
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   if( manifest_parse(&m, pContent)==0 ){
dbda8d6ce9 2007-07-21       drh:     return 0;
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   db_begin_transaction();
3b5514ed82 2007-09-22       drh:   if( m.type==CFTYPE_MANIFEST ){
3b5514ed82 2007-09-22       drh:     if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid) ){
3b5514ed82 2007-09-22       drh:       for(i=0; i<m.nParent; i++){
3b5514ed82 2007-09-22       drh:         int pid = uuid_to_rid(m.azParent[i], 1);
3b5514ed82 2007-09-22       drh:         db_multi_exec("INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime)"
3b5514ed82 2007-09-22       drh:                       "VALUES(%d, %d, %d, %.17g)", pid, rid, i==0, m.rDate);
3b5514ed82 2007-09-22       drh:         if( i==0 ){
3b5514ed82 2007-09-22       drh:           add_mlink(pid, 0, rid, &m);
913608a5a6 2007-09-25       drh:           parentid = pid;
3b5514ed82 2007-09-22       drh:         }
3b5514ed82 2007-09-22       drh:       }
3b5514ed82 2007-09-22       drh:       db_prepare(&q, "SELECT cid FROM plink WHERE pid=%d AND isprim", rid);
3b5514ed82 2007-09-22       drh:       while( db_step(&q)==SQLITE_ROW ){
3b5514ed82 2007-09-22       drh:         int cid = db_column_int(&q, 0);
3b5514ed82 2007-09-22       drh:         add_mlink(rid, &m, cid, 0);
3b5514ed82 2007-09-22       drh:       }
3b5514ed82 2007-09-22       drh:       db_finalize(&q);
3b5514ed82 2007-09-22       drh:       db_multi_exec(
ce7900a0b6 2007-09-25       drh:         "INSERT INTO event(type,mtime,objid,user,comment,"
ce7900a0b6 2007-09-25       drh:         "                  bgcolor,brbgcolor,euser,ecomment)"
ce7900a0b6 2007-09-25       drh:         "VALUES('ci',%.17g,%d,%Q,%Q,"
ce7900a0b6 2007-09-25       drh:         " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype=1),"
ce7900a0b6 2007-09-25       drh:         "(SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype!=1),"
ce7900a0b6 2007-09-25       drh:         "  (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),"
ce7900a0b6 2007-09-25       drh:         "  (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));",
ce7900a0b6 2007-09-25       drh:         m.rDate, rid, m.zUser, m.zComment,
ce7900a0b6 2007-09-25       drh:         TAG_BGCOLOR, rid,
ce7900a0b6 2007-09-25       drh:         TAG_BGCOLOR, rid,
ce7900a0b6 2007-09-25       drh:         TAG_USER, rid,
ce7900a0b6 2007-09-25       drh:         TAG_COMMENT, rid
3b5514ed82 2007-09-22       drh:       );
3b5514ed82 2007-09-22       drh:     }
3b5514ed82 2007-09-22       drh:   }
3b5514ed82 2007-09-22       drh:   if( m.type==CFTYPE_CLUSTER ){
3b5514ed82 2007-09-22       drh:     for(i=0; i<m.nCChild; i++){
3b5514ed82 2007-09-22       drh:       int mid;
3b5514ed82 2007-09-22       drh:       mid = uuid_to_rid(m.azCChild[i], 1);
3b5514ed82 2007-09-22       drh:       if( mid>0 ){
3b5514ed82 2007-09-22       drh:         db_multi_exec("DELETE FROM unclustered WHERE rid=%d", mid);
18b1f6788d 2007-08-28       drh:       }
dbda8d6ce9 2007-07-21       drh:     }
dbda8d6ce9 2007-07-21       drh:   }
3b5514ed82 2007-09-22       drh:   if( m.type==CFTYPE_CONTROL || m.type==CFTYPE_MANIFEST ){
3b5514ed82 2007-09-22       drh:     for(i=0; i<m.nTag; i++){
3b5514ed82 2007-09-22       drh:       int tid;
09c4adeb6f 2007-09-22       drh:       int type;
3b5514ed82 2007-09-22       drh:       tid = uuid_to_rid(m.aTag[i].zUuid, 1);
09c4adeb6f 2007-09-22       drh:       switch( m.aTag[i].zName[0] ){
09c4adeb6f 2007-09-22       drh:         case '+':  type = 1; break;
09c4adeb6f 2007-09-22       drh:         case '*':  type = 2; break;
09c4adeb6f 2007-09-22       drh:         case '-':  type = 0; break;
e63a9fd9d0 2007-09-25       jnc:         default:
e63a9fd9d0 2007-09-25       jnc:           fossil_fatal("unknown tag type in manifest: %s", m.aTag);
e63a9fd9d0 2007-09-25       jnc:           return 0;
09c4adeb6f 2007-09-22       drh:       }
09c4adeb6f 2007-09-22       drh:       tag_insert(&m.aTag[i].zName[1], type, m.aTag[i].zValue,
09c4adeb6f 2007-09-22       drh:                  rid, m.rDate, tid);
18b1f6788d 2007-08-28       drh:     }
913608a5a6 2007-09-25       drh:     if( parentid ){
913608a5a6 2007-09-25       drh:       tag_propagate_all(parentid);
e1c1877c99 2007-09-08       drh:     }
18b1f6788d 2007-08-28       drh:   }
dbda8d6ce9 2007-07-21       drh:   db_end_transaction(0);
dbda8d6ce9 2007-07-21       drh:   manifest_clear(&m);
dbda8d6ce9 2007-07-21       drh:   return 1;
dbda8d6ce9 2007-07-21       drh: }