| ︙ | | | ︙ | |
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
|
if( zName==0 || zTarget==0 ) goto manifest_syntax_error;
if( p->zAttachName!=0 ) goto manifest_syntax_error;
defossilize(zName);
if( !file_is_simple_pathname(zName, 0) ){
SYNTAX("invalid filename on A-card");
}
defossilize(zTarget);
if( hname_validate(zTarget,nTarget)==HNAME_NONE
&& !wiki_name_is_wellformed((const unsigned char *)zTarget) ){
SYNTAX("invalid target on A-card");
}
if( zSrc && hname_validate(zSrc,nSrc)==HNAME_NONE ){
SYNTAX("invalid source on A-card");
}
p->zAttachName = (char*)file_tail(zName);
p->zAttachSrc = zSrc;
p->zAttachTarget = zTarget;
break;
}
/*
** B <uuid>
**
** A B-line gives the artifact hash for the baseline of a delta-manifest.
*/
case 'B': {
if( p->zBaseline ) SYNTAX("more than one B-card");
p->zBaseline = next_token(&x, &sz);
if( p->zBaseline==0 ) SYNTAX("missing hash on B-card");
if( hname_validate(p->zBaseline,sz)==HNAME_NONE ){
SYNTAX("invalid hash on B-card");
}
break;
}
/*
|
|
|
|
|
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
|
if( zName==0 || zTarget==0 ) goto manifest_syntax_error;
if( p->zAttachName!=0 ) goto manifest_syntax_error;
defossilize(zName);
if( !file_is_simple_pathname(zName, 0) ){
SYNTAX("invalid filename on A-card");
}
defossilize(zTarget);
if( !hname_validate(zTarget,nTarget)
&& !wiki_name_is_wellformed((const unsigned char *)zTarget) ){
SYNTAX("invalid target on A-card");
}
if( zSrc && !hname_validate(zSrc,nSrc) ){
SYNTAX("invalid source on A-card");
}
p->zAttachName = (char*)file_tail(zName);
p->zAttachSrc = zSrc;
p->zAttachTarget = zTarget;
break;
}
/*
** B <uuid>
**
** A B-line gives the artifact hash for the baseline of a delta-manifest.
*/
case 'B': {
if( p->zBaseline ) SYNTAX("more than one B-card");
p->zBaseline = next_token(&x, &sz);
if( p->zBaseline==0 ) SYNTAX("missing hash on B-card");
if( !hname_validate(p->zBaseline,sz) ){
SYNTAX("invalid hash on B-card");
}
break;
}
/*
|
| ︙ | | | ︙ | |
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
|
** is when the specific event is said to occur.
*/
case 'E': {
if( p->rEventDate>0.0 ) SYNTAX("more than one E-card");
p->rEventDate = db_double(0.0,"SELECT julianday(%Q)", next_token(&x,0));
if( p->rEventDate<=0.0 ) SYNTAX("malformed date on E-card");
p->zEventId = next_token(&x, &sz);
if( hname_validate(p->zEventId, sz)==HNAME_NONE ){
SYNTAX("malformed hash on E-card");
}
break;
}
/*
** F <filename> ?<uuid>? ?<permissions>? ?<old-name>?
|
|
|
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
|
** is when the specific event is said to occur.
*/
case 'E': {
if( p->rEventDate>0.0 ) SYNTAX("more than one E-card");
p->rEventDate = db_double(0.0,"SELECT julianday(%Q)", next_token(&x,0));
if( p->rEventDate<=0.0 ) SYNTAX("malformed date on E-card");
p->zEventId = next_token(&x, &sz);
if( !hname_validate(p->zEventId, sz) ){
SYNTAX("malformed hash on E-card");
}
break;
}
/*
** F <filename> ?<uuid>? ?<permissions>? ?<old-name>?
|
| ︙ | | | ︙ | |
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
|
if( zName==0 ) SYNTAX("missing filename on F-card");
defossilize(zName);
if( !file_is_simple_pathname(zName, 0) ){
SYNTAX("F-card filename is not a simple path");
}
zUuid = next_token(&x, &sz);
if( p->zBaseline==0 || zUuid!=0 ){
if( hname_validate(zUuid,sz)==HNAME_NONE ){
SYNTAX("F-card hash invalid");
}
}
zPerm = next_token(&x,0);
zPriorName = next_token(&x,0);
if( zPriorName ){
defossilize(zPriorName);
|
|
|
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
|
if( zName==0 ) SYNTAX("missing filename on F-card");
defossilize(zName);
if( !file_is_simple_pathname(zName, 0) ){
SYNTAX("F-card filename is not a simple path");
}
zUuid = next_token(&x, &sz);
if( p->zBaseline==0 || zUuid!=0 ){
if( !hname_validate(zUuid,sz) ){
SYNTAX("F-card hash invalid");
}
}
zPerm = next_token(&x,0);
zPriorName = next_token(&x,0);
if( zPriorName ){
defossilize(zPriorName);
|
| ︙ | | | ︙ | |
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
|
**
** An M-line identifies another artifact by its hash. M-lines
** occur in clusters only.
*/
case 'M': {
zUuid = next_token(&x, &sz);
if( zUuid==0 ) SYNTAX("missing hash on M-card");
if( hname_validate(zUuid,sz)==HNAME_NONE ){
SYNTAX("Invalid hash on M-card");
}
if( p->nCChild>=p->nCChildAlloc ){
p->nCChildAlloc = p->nCChildAlloc*2 + 10;
p->azCChild = fossil_realloc(p->azCChild
, p->nCChildAlloc*sizeof(p->azCChild[0]) );
}
|
|
|
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
|
**
** An M-line identifies another artifact by its hash. M-lines
** occur in clusters only.
*/
case 'M': {
zUuid = next_token(&x, &sz);
if( zUuid==0 ) SYNTAX("missing hash on M-card");
if( !hname_validate(zUuid,sz) ){
SYNTAX("Invalid hash on M-card");
}
if( p->nCChild>=p->nCChildAlloc ){
p->nCChildAlloc = p->nCChildAlloc*2 + 10;
p->azCChild = fossil_realloc(p->azCChild
, p->nCChildAlloc*sizeof(p->azCChild[0]) );
}
|
| ︙ | | | ︙ | |
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
|
** this artifact. The first parent is the primary parent. All
** others are parents by merge. Note that the initial empty
** check-in historically has an empty P-card, so empty P-cards
** must be accepted.
*/
case 'P': {
while( (zUuid = next_token(&x, &sz))!=0 ){
if( hname_validate(zUuid, sz)==HNAME_NONE ){
SYNTAX("invalid hash on P-card");
}
if( p->nParent>=p->nParentAlloc ){
p->nParentAlloc = p->nParentAlloc*2 + 5;
p->azParent = fossil_realloc(p->azParent,
p->nParentAlloc*sizeof(char*));
}
|
|
|
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
|
** this artifact. The first parent is the primary parent. All
** others are parents by merge. Note that the initial empty
** check-in historically has an empty P-card, so empty P-cards
** must be accepted.
*/
case 'P': {
while( (zUuid = next_token(&x, &sz))!=0 ){
if( !hname_validate(zUuid, sz) ){
SYNTAX("invalid hash on P-card");
}
if( p->nParent>=p->nParentAlloc ){
p->nParentAlloc = p->nParentAlloc*2 + 5;
p->azParent = fossil_realloc(p->azParent,
p->nParentAlloc*sizeof(char*));
}
|
| ︙ | | | ︙ | |
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
|
** this check-in ("+") or backed out of this check-in ("-").
*/
case 'Q': {
if( (zUuid=next_token(&x, &sz))==0 ) SYNTAX("missing hash on Q-card");
if( zUuid[0]!='+' && zUuid[0]!='-' ){
SYNTAX("Q-card does not begin with '+' or '-'");
}
if( hname_validate(&zUuid[1], sz-1)==HNAME_NONE ){
SYNTAX("invalid hash on Q-card");
}
n = p->nCherrypick;
p->nCherrypick++;
p->aCherrypick = fossil_realloc(p->aCherrypick,
p->nCherrypick*sizeof(p->aCherrypick[0]));
p->aCherrypick[n].zCPTarget = zUuid;
p->aCherrypick[n].zCPBase = zUuid = next_token(&x, &sz);
if( zUuid && hname_validate(zUuid,sz)==HNAME_NONE ){
SYNTAX("invalid second hash on Q-card");
}
break;
}
/*
** R <md5sum>
|
|
|
|
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
|
** this check-in ("+") or backed out of this check-in ("-").
*/
case 'Q': {
if( (zUuid=next_token(&x, &sz))==0 ) SYNTAX("missing hash on Q-card");
if( zUuid[0]!='+' && zUuid[0]!='-' ){
SYNTAX("Q-card does not begin with '+' or '-'");
}
if( !hname_validate(&zUuid[1], sz-1) ){
SYNTAX("invalid hash on Q-card");
}
n = p->nCherrypick;
p->nCherrypick++;
p->aCherrypick = fossil_realloc(p->aCherrypick,
p->nCherrypick*sizeof(p->aCherrypick[0]));
p->aCherrypick[n].zCPTarget = zUuid;
p->aCherrypick[n].zCPBase = zUuid = next_token(&x, &sz);
if( zUuid && !hname_validate(zUuid,sz) ){
SYNTAX("invalid second hash on Q-card");
}
break;
}
/*
** R <md5sum>
|
| ︙ | | | ︙ | |
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
|
char *zName, *zValue;
zName = next_token(&x, 0);
if( zName==0 ) SYNTAX("missing name on T-card");
zUuid = next_token(&x, &sz);
if( zUuid==0 ) SYNTAX("missing artifact hash on T-card");
zValue = next_token(&x, 0);
if( zValue ) defossilize(zValue);
if( hname_validate(zUuid, sz)!=HNAME_NONE ){
/* A valid artifact hash */
if( p->zEventId ) SYNTAX("non-self-referential T-card in event");
}else if( sz==1 && zUuid[0]=='*' ){
zUuid = 0;
hasSelfRefTag = 1;
if( p->zEventId && zName[0]!='+' ){
SYNTAX("propagating T-card in event");
|
|
|
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
|
char *zName, *zValue;
zName = next_token(&x, 0);
if( zName==0 ) SYNTAX("missing name on T-card");
zUuid = next_token(&x, &sz);
if( zUuid==0 ) SYNTAX("missing artifact hash on T-card");
zValue = next_token(&x, 0);
if( zValue ) defossilize(zValue);
if( hname_validate(zUuid, sz) ){
/* A valid artifact hash */
if( p->zEventId ) SYNTAX("non-self-referential T-card in event");
}else if( sz==1 && zUuid[0]=='*' ){
zUuid = 0;
hasSelfRefTag = 1;
if( p->zEventId && zName[0]!='+' ){
SYNTAX("propagating T-card in event");
|
| ︙ | | | ︙ | |
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
|
void manifest_reparent_checkin(int rid, const char *zValue){
int nParent = 0;
char *zCopy = 0;
char **azParent = 0;
Manifest *p = 0;
int i, j;
int n = (int)strlen(zValue);
int mxParent = (n+1)/(HNAME_LEN_MIN+1);
if( mxParent<1 ) return;
zCopy = fossil_strdup(zValue);
azParent = fossil_malloc( sizeof(azParent[0])*mxParent );
for(nParent=0, i=0; zCopy[i]; i++){
char *z = &zCopy[i];
azParent[nParent++] = z;
if( nParent>mxParent ) goto reparent_abort;
for(j=HNAME_LEN_MIN; z[j]>' '; j++){}
if( hname_validate(z, j)==HNAME_NONE ) goto reparent_abort;
if( z[j]==0 ) break;
z[j] = 0;
i += j;
}
if( !db_exists("SELECT 1 FROM plink WHERE cid=%d AND pid=%d",
rid, uuid_to_rid(azParent[0],0))
){
|
|
|
|
|
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
|
void manifest_reparent_checkin(int rid, const char *zValue){
int nParent = 0;
char *zCopy = 0;
char **azParent = 0;
Manifest *p = 0;
int i, j;
int n = (int)strlen(zValue);
int mxParent = (n+1)/(HNAME_MIN+1);
if( mxParent<1 ) return;
zCopy = fossil_strdup(zValue);
azParent = fossil_malloc( sizeof(azParent[0])*mxParent );
for(nParent=0, i=0; zCopy[i]; i++){
char *z = &zCopy[i];
azParent[nParent++] = z;
if( nParent>mxParent ) goto reparent_abort;
for(j=HNAME_MIN; z[j]>' '; j++){}
if( !hname_validate(z, j) ) goto reparent_abort;
if( z[j]==0 ) break;
z[j] = 0;
i += j;
}
if( !db_exists("SELECT 1 FROM plink WHERE cid=%d AND pid=%d",
rid, uuid_to_rid(azParent[0],0))
){
|
| ︙ | | | ︙ | |