Fossil SCM
Try to provide better information on manifest errors.
Commit
e9bccd1c1270145ee3e13d9e2df197af9779658f
Parent
bf3db3d16e15ee9…
2 files changed
+17
-2
+1
-1
+17
-2
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -361,10 +361,11 @@ | ||
| 361 | 361 | char *z; |
| 362 | 362 | int n; |
| 363 | 363 | char *zUuid; |
| 364 | 364 | int sz = 0; |
| 365 | 365 | int isRepeat, hasSelfRefTag = 0; |
| 366 | + Blob bUuid = BLOB_INITIALIZER; | |
| 366 | 367 | static Bag seen; |
| 367 | 368 | const char *zErr = 0; |
| 368 | 369 | |
| 369 | 370 | if( rid==0 ){ |
| 370 | 371 | isRepeat = 1; |
| @@ -404,10 +405,15 @@ | ||
| 404 | 405 | if( verify_z_card(z, n)==2 ){ |
| 405 | 406 | blob_reset(pContent); |
| 406 | 407 | blob_appendf(pErr, "incorrect Z-card cksum"); |
| 407 | 408 | return 0; |
| 408 | 409 | } |
| 410 | + | |
| 411 | + /* Store the UUID (before modifying the blob) only for error | |
| 412 | + ** reporting purposes. | |
| 413 | + */ | |
| 414 | + sha1sum_blob(pContent, &bUuid); | |
| 409 | 415 | |
| 410 | 416 | /* Allocate a Manifest object to hold the parsed control artifact. |
| 411 | 417 | */ |
| 412 | 418 | p = fossil_malloc( sizeof(*p) ); |
| 413 | 419 | memset(p, 0, sizeof(*p)); |
| @@ -945,13 +951,18 @@ | ||
| 945 | 951 | if( !seenZ ) SYNTAX("missing Z-card on control"); |
| 946 | 952 | p->type = CFTYPE_CONTROL; |
| 947 | 953 | } |
| 948 | 954 | md5sum_init(); |
| 949 | 955 | if( !isRepeat ) g.parseCnt[p->type]++; |
| 956 | + blob_reset(&bUuid); | |
| 950 | 957 | return p; |
| 951 | 958 | |
| 952 | 959 | manifest_syntax_error: |
| 960 | + if(bUuid.nUsed){ | |
| 961 | + blob_appendf(pErr, "manifest [%.40s] ", blob_str(&bUuid)); | |
| 962 | + blob_reset(&bUuid); | |
| 963 | + } | |
| 953 | 964 | if( zErr ){ |
| 954 | 965 | blob_appendf(pErr, "line %d: %s", lineNo, zErr); |
| 955 | 966 | }else{ |
| 956 | 967 | blob_appendf(pErr, "unknown error on line %d", lineNo); |
| 957 | 968 | } |
| @@ -1734,11 +1745,14 @@ | ||
| 1734 | 1745 | |
| 1735 | 1746 | if( (p = manifest_cache_find(rid))!=0 ){ |
| 1736 | 1747 | blob_reset(pContent); |
| 1737 | 1748 | }else if( (p = manifest_parse(pContent, rid, 0))==0 ){ |
| 1738 | 1749 | assert( blob_is_reset(pContent) || pContent==0 ); |
| 1739 | - if( (flags & MC_NO_ERRORS)==0 ) fossil_error(1, "syntax error in manifest"); | |
| 1750 | + if( (flags & MC_NO_ERRORS)==0 ){ | |
| 1751 | + fossil_error(1, "syntax error in manifest [%s]", | |
| 1752 | + db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid)); | |
| 1753 | + } | |
| 1740 | 1754 | return 0; |
| 1741 | 1755 | } |
| 1742 | 1756 | if( g.xlinkClusterOnly && p->type!=CFTYPE_CLUSTER ){ |
| 1743 | 1757 | manifest_destroy(p); |
| 1744 | 1758 | assert( blob_is_reset(pContent) ); |
| @@ -1747,11 +1761,12 @@ | ||
| 1747 | 1761 | } |
| 1748 | 1762 | if( p->type==CFTYPE_MANIFEST && fetch_baseline(p, 0) ){ |
| 1749 | 1763 | manifest_destroy(p); |
| 1750 | 1764 | assert( blob_is_reset(pContent) ); |
| 1751 | 1765 | if( (flags & MC_NO_ERRORS)==0 ){ |
| 1752 | - fossil_error(1, "cannot fetch baseline manifest"); | |
| 1766 | + fossil_error(1, "cannot fetch baseline for manifest [%s]", | |
| 1767 | + db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid)); | |
| 1753 | 1768 | } |
| 1754 | 1769 | return 0; |
| 1755 | 1770 | } |
| 1756 | 1771 | db_begin_transaction(); |
| 1757 | 1772 | if( p->type==CFTYPE_MANIFEST ){ |
| 1758 | 1773 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -361,10 +361,11 @@ | |
| 361 | char *z; |
| 362 | int n; |
| 363 | char *zUuid; |
| 364 | int sz = 0; |
| 365 | int isRepeat, hasSelfRefTag = 0; |
| 366 | static Bag seen; |
| 367 | const char *zErr = 0; |
| 368 | |
| 369 | if( rid==0 ){ |
| 370 | isRepeat = 1; |
| @@ -404,10 +405,15 @@ | |
| 404 | if( verify_z_card(z, n)==2 ){ |
| 405 | blob_reset(pContent); |
| 406 | blob_appendf(pErr, "incorrect Z-card cksum"); |
| 407 | return 0; |
| 408 | } |
| 409 | |
| 410 | /* Allocate a Manifest object to hold the parsed control artifact. |
| 411 | */ |
| 412 | p = fossil_malloc( sizeof(*p) ); |
| 413 | memset(p, 0, sizeof(*p)); |
| @@ -945,13 +951,18 @@ | |
| 945 | if( !seenZ ) SYNTAX("missing Z-card on control"); |
| 946 | p->type = CFTYPE_CONTROL; |
| 947 | } |
| 948 | md5sum_init(); |
| 949 | if( !isRepeat ) g.parseCnt[p->type]++; |
| 950 | return p; |
| 951 | |
| 952 | manifest_syntax_error: |
| 953 | if( zErr ){ |
| 954 | blob_appendf(pErr, "line %d: %s", lineNo, zErr); |
| 955 | }else{ |
| 956 | blob_appendf(pErr, "unknown error on line %d", lineNo); |
| 957 | } |
| @@ -1734,11 +1745,14 @@ | |
| 1734 | |
| 1735 | if( (p = manifest_cache_find(rid))!=0 ){ |
| 1736 | blob_reset(pContent); |
| 1737 | }else if( (p = manifest_parse(pContent, rid, 0))==0 ){ |
| 1738 | assert( blob_is_reset(pContent) || pContent==0 ); |
| 1739 | if( (flags & MC_NO_ERRORS)==0 ) fossil_error(1, "syntax error in manifest"); |
| 1740 | return 0; |
| 1741 | } |
| 1742 | if( g.xlinkClusterOnly && p->type!=CFTYPE_CLUSTER ){ |
| 1743 | manifest_destroy(p); |
| 1744 | assert( blob_is_reset(pContent) ); |
| @@ -1747,11 +1761,12 @@ | |
| 1747 | } |
| 1748 | if( p->type==CFTYPE_MANIFEST && fetch_baseline(p, 0) ){ |
| 1749 | manifest_destroy(p); |
| 1750 | assert( blob_is_reset(pContent) ); |
| 1751 | if( (flags & MC_NO_ERRORS)==0 ){ |
| 1752 | fossil_error(1, "cannot fetch baseline manifest"); |
| 1753 | } |
| 1754 | return 0; |
| 1755 | } |
| 1756 | db_begin_transaction(); |
| 1757 | if( p->type==CFTYPE_MANIFEST ){ |
| 1758 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -361,10 +361,11 @@ | |
| 361 | char *z; |
| 362 | int n; |
| 363 | char *zUuid; |
| 364 | int sz = 0; |
| 365 | int isRepeat, hasSelfRefTag = 0; |
| 366 | Blob bUuid = BLOB_INITIALIZER; |
| 367 | static Bag seen; |
| 368 | const char *zErr = 0; |
| 369 | |
| 370 | if( rid==0 ){ |
| 371 | isRepeat = 1; |
| @@ -404,10 +405,15 @@ | |
| 405 | if( verify_z_card(z, n)==2 ){ |
| 406 | blob_reset(pContent); |
| 407 | blob_appendf(pErr, "incorrect Z-card cksum"); |
| 408 | return 0; |
| 409 | } |
| 410 | |
| 411 | /* Store the UUID (before modifying the blob) only for error |
| 412 | ** reporting purposes. |
| 413 | */ |
| 414 | sha1sum_blob(pContent, &bUuid); |
| 415 | |
| 416 | /* Allocate a Manifest object to hold the parsed control artifact. |
| 417 | */ |
| 418 | p = fossil_malloc( sizeof(*p) ); |
| 419 | memset(p, 0, sizeof(*p)); |
| @@ -945,13 +951,18 @@ | |
| 951 | if( !seenZ ) SYNTAX("missing Z-card on control"); |
| 952 | p->type = CFTYPE_CONTROL; |
| 953 | } |
| 954 | md5sum_init(); |
| 955 | if( !isRepeat ) g.parseCnt[p->type]++; |
| 956 | blob_reset(&bUuid); |
| 957 | return p; |
| 958 | |
| 959 | manifest_syntax_error: |
| 960 | if(bUuid.nUsed){ |
| 961 | blob_appendf(pErr, "manifest [%.40s] ", blob_str(&bUuid)); |
| 962 | blob_reset(&bUuid); |
| 963 | } |
| 964 | if( zErr ){ |
| 965 | blob_appendf(pErr, "line %d: %s", lineNo, zErr); |
| 966 | }else{ |
| 967 | blob_appendf(pErr, "unknown error on line %d", lineNo); |
| 968 | } |
| @@ -1734,11 +1745,14 @@ | |
| 1745 | |
| 1746 | if( (p = manifest_cache_find(rid))!=0 ){ |
| 1747 | blob_reset(pContent); |
| 1748 | }else if( (p = manifest_parse(pContent, rid, 0))==0 ){ |
| 1749 | assert( blob_is_reset(pContent) || pContent==0 ); |
| 1750 | if( (flags & MC_NO_ERRORS)==0 ){ |
| 1751 | fossil_error(1, "syntax error in manifest [%s]", |
| 1752 | db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid)); |
| 1753 | } |
| 1754 | return 0; |
| 1755 | } |
| 1756 | if( g.xlinkClusterOnly && p->type!=CFTYPE_CLUSTER ){ |
| 1757 | manifest_destroy(p); |
| 1758 | assert( blob_is_reset(pContent) ); |
| @@ -1747,11 +1761,12 @@ | |
| 1761 | } |
| 1762 | if( p->type==CFTYPE_MANIFEST && fetch_baseline(p, 0) ){ |
| 1763 | manifest_destroy(p); |
| 1764 | assert( blob_is_reset(pContent) ); |
| 1765 | if( (flags & MC_NO_ERRORS)==0 ){ |
| 1766 | fossil_error(1, "cannot fetch baseline for manifest [%s]", |
| 1767 | db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid)); |
| 1768 | } |
| 1769 | return 0; |
| 1770 | } |
| 1771 | db_begin_transaction(); |
| 1772 | if( p->type==CFTYPE_MANIFEST ){ |
| 1773 |
+1
-1
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -201,11 +201,11 @@ | ||
| 201 | 201 | if( rid==0 ){ |
| 202 | 202 | blob_appendf(&pXfer->err, "%s", g.zErrMsg); |
| 203 | 203 | blob_reset(&content); |
| 204 | 204 | }else{ |
| 205 | 205 | if( !isPriv ) content_make_public(rid); |
| 206 | - manifest_crosslink(rid, &content, MC_NONE|MC_NO_ERRORS); | |
| 206 | + manifest_crosslink(rid, &content, MC_NO_ERRORS); | |
| 207 | 207 | } |
| 208 | 208 | assert( blob_is_reset(&content) ); |
| 209 | 209 | remote_has(rid); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -201,11 +201,11 @@ | |
| 201 | if( rid==0 ){ |
| 202 | blob_appendf(&pXfer->err, "%s", g.zErrMsg); |
| 203 | blob_reset(&content); |
| 204 | }else{ |
| 205 | if( !isPriv ) content_make_public(rid); |
| 206 | manifest_crosslink(rid, &content, MC_NONE|MC_NO_ERRORS); |
| 207 | } |
| 208 | assert( blob_is_reset(&content) ); |
| 209 | remote_has(rid); |
| 210 | } |
| 211 | |
| 212 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -201,11 +201,11 @@ | |
| 201 | if( rid==0 ){ |
| 202 | blob_appendf(&pXfer->err, "%s", g.zErrMsg); |
| 203 | blob_reset(&content); |
| 204 | }else{ |
| 205 | if( !isPriv ) content_make_public(rid); |
| 206 | manifest_crosslink(rid, &content, MC_NO_ERRORS); |
| 207 | } |
| 208 | assert( blob_is_reset(&content) ); |
| 209 | remote_has(rid); |
| 210 | } |
| 211 | |
| 212 |