Fossil SCM
Further minor internal artifact_to_json() cleanups.
Commit
ca8d6eee8a4d82bcbfb478a5d6c17d17a7ec62b140fee2404380590b3d1ffe75
Parent
94d5e322cd7054b…
1 file changed
+9
-14
+9
-14
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -2939,14 +2939,14 @@ | ||
| 2939 | 2939 | ** Creates a JSON representation of p, appending it to b. |
| 2940 | 2940 | ** |
| 2941 | 2941 | ** b is not cleared before rendering, so the caller needs to do that |
| 2942 | 2942 | ** if it's important for their use case. |
| 2943 | 2943 | ** |
| 2944 | -** Pedantic note: this routine traverses p->aFile directly, rather than | |
| 2945 | -** using manifest_file_next(), so that delta manifests are rendered as-is | |
| 2946 | -** instead of having their derived files. If that policy is ever changed, | |
| 2947 | -** p will need to be non-const. | |
| 2944 | +** Pedantic note: this routine traverses p->aFile directly, rather | |
| 2945 | +** than using manifest_file_next(), so that delta manifests are | |
| 2946 | +** rendered as-is instead of containing their derived F-cards. If that | |
| 2947 | +** policy is ever changed, p will need to be non-const. | |
| 2948 | 2948 | */ |
| 2949 | 2949 | void artifact_to_json(Manifest const *p, Blob *b){ |
| 2950 | 2950 | int i; |
| 2951 | 2951 | |
| 2952 | 2952 | blob_append_literal(b, "{"); |
| @@ -3016,11 +3016,11 @@ | ||
| 3016 | 3016 | } |
| 3017 | 3017 | blob_append_char(b, ']'); |
| 3018 | 3018 | } |
| 3019 | 3019 | CARD_STR2(K, p->zTicketUuid); |
| 3020 | 3020 | CARD_STR2(L, p->zWikiTitle); |
| 3021 | - ISA( CFTYPE_CLUSTER && p->nCChild>0 ){ | |
| 3021 | + ISA( CFTYPE_CLUSTER ){ | |
| 3022 | 3022 | CARD_LETTER(M); |
| 3023 | 3023 | blob_append_char(b, '['); |
| 3024 | 3024 | for( int i = 0; i < p->nCChild; ++i ){ |
| 3025 | 3025 | if( i>0 ) blob_append_char(b, ','); |
| 3026 | 3026 | blob_appendf(b, "%!j", p->azCChild[i]); |
| @@ -3035,13 +3035,12 @@ | ||
| 3035 | 3035 | for( i = 0; i < p->nParent; ++i ){ |
| 3036 | 3036 | if( i>0 ) blob_append_char(b, ','); |
| 3037 | 3037 | blob_appendf(b, "%!j", p->azParent[i]); |
| 3038 | 3038 | } |
| 3039 | 3039 | } |
| 3040 | - /* Special case: model checkins with no P-card as having | |
| 3041 | - ** an empty array, rather than no P-card, to hypothetically | |
| 3042 | - ** simplify handling in JSON queries. */ | |
| 3040 | + /* Special case: model checkins with no P-card as having an empty | |
| 3041 | + ** array, as per F-cards. */ | |
| 3043 | 3042 | blob_append_char(b, ']'); |
| 3044 | 3043 | } |
| 3045 | 3044 | if( p->nCherrypick ){ |
| 3046 | 3045 | CARD_LETTER(Q); |
| 3047 | 3046 | blob_append_char(b, '['); |
| @@ -3062,17 +3061,13 @@ | ||
| 3062 | 3061 | for( int i = 0; i < p->nTag; ++i ){ |
| 3063 | 3062 | const char *zName = p->aTag[i].zName; |
| 3064 | 3063 | if( i>0 ) blob_append_char(b, ','); |
| 3065 | 3064 | blob_append_char(b, '{'); |
| 3066 | 3065 | blob_appendf(b, "\"type\": \"%c\"", *zName); |
| 3067 | - ++zName; | |
| 3068 | - KVP_STR(1, name, zName); | |
| 3066 | + KVP_STR(1, name, &zName[1]); | |
| 3069 | 3067 | KVP_STR(1, target, p->aTag[i].zUuid ? p->aTag[i].zUuid : "*") |
| 3070 | - /* We could arguably resolve this to null. Per /chat | |
| 3071 | - discussion we don't want to resolve it to zUuid because | |
| 3072 | - that would effectively add information to the rendered | |
| 3073 | - manifest. */; | |
| 3068 | + /* We could arguably resolve the "*" as null or p's uuid. */; | |
| 3074 | 3069 | KVP_STR(1, value, p->aTag[i].zValue); |
| 3075 | 3070 | blob_append_char(b, '}'); |
| 3076 | 3071 | } |
| 3077 | 3072 | blob_append_char(b, ']'); |
| 3078 | 3073 | } |
| 3079 | 3074 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2939,14 +2939,14 @@ | |
| 2939 | ** Creates a JSON representation of p, appending it to b. |
| 2940 | ** |
| 2941 | ** b is not cleared before rendering, so the caller needs to do that |
| 2942 | ** if it's important for their use case. |
| 2943 | ** |
| 2944 | ** Pedantic note: this routine traverses p->aFile directly, rather than |
| 2945 | ** using manifest_file_next(), so that delta manifests are rendered as-is |
| 2946 | ** instead of having their derived files. If that policy is ever changed, |
| 2947 | ** p will need to be non-const. |
| 2948 | */ |
| 2949 | void artifact_to_json(Manifest const *p, Blob *b){ |
| 2950 | int i; |
| 2951 | |
| 2952 | blob_append_literal(b, "{"); |
| @@ -3016,11 +3016,11 @@ | |
| 3016 | } |
| 3017 | blob_append_char(b, ']'); |
| 3018 | } |
| 3019 | CARD_STR2(K, p->zTicketUuid); |
| 3020 | CARD_STR2(L, p->zWikiTitle); |
| 3021 | ISA( CFTYPE_CLUSTER && p->nCChild>0 ){ |
| 3022 | CARD_LETTER(M); |
| 3023 | blob_append_char(b, '['); |
| 3024 | for( int i = 0; i < p->nCChild; ++i ){ |
| 3025 | if( i>0 ) blob_append_char(b, ','); |
| 3026 | blob_appendf(b, "%!j", p->azCChild[i]); |
| @@ -3035,13 +3035,12 @@ | |
| 3035 | for( i = 0; i < p->nParent; ++i ){ |
| 3036 | if( i>0 ) blob_append_char(b, ','); |
| 3037 | blob_appendf(b, "%!j", p->azParent[i]); |
| 3038 | } |
| 3039 | } |
| 3040 | /* Special case: model checkins with no P-card as having |
| 3041 | ** an empty array, rather than no P-card, to hypothetically |
| 3042 | ** simplify handling in JSON queries. */ |
| 3043 | blob_append_char(b, ']'); |
| 3044 | } |
| 3045 | if( p->nCherrypick ){ |
| 3046 | CARD_LETTER(Q); |
| 3047 | blob_append_char(b, '['); |
| @@ -3062,17 +3061,13 @@ | |
| 3062 | for( int i = 0; i < p->nTag; ++i ){ |
| 3063 | const char *zName = p->aTag[i].zName; |
| 3064 | if( i>0 ) blob_append_char(b, ','); |
| 3065 | blob_append_char(b, '{'); |
| 3066 | blob_appendf(b, "\"type\": \"%c\"", *zName); |
| 3067 | ++zName; |
| 3068 | KVP_STR(1, name, zName); |
| 3069 | KVP_STR(1, target, p->aTag[i].zUuid ? p->aTag[i].zUuid : "*") |
| 3070 | /* We could arguably resolve this to null. Per /chat |
| 3071 | discussion we don't want to resolve it to zUuid because |
| 3072 | that would effectively add information to the rendered |
| 3073 | manifest. */; |
| 3074 | KVP_STR(1, value, p->aTag[i].zValue); |
| 3075 | blob_append_char(b, '}'); |
| 3076 | } |
| 3077 | blob_append_char(b, ']'); |
| 3078 | } |
| 3079 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2939,14 +2939,14 @@ | |
| 2939 | ** Creates a JSON representation of p, appending it to b. |
| 2940 | ** |
| 2941 | ** b is not cleared before rendering, so the caller needs to do that |
| 2942 | ** if it's important for their use case. |
| 2943 | ** |
| 2944 | ** Pedantic note: this routine traverses p->aFile directly, rather |
| 2945 | ** than using manifest_file_next(), so that delta manifests are |
| 2946 | ** rendered as-is instead of containing their derived F-cards. If that |
| 2947 | ** policy is ever changed, p will need to be non-const. |
| 2948 | */ |
| 2949 | void artifact_to_json(Manifest const *p, Blob *b){ |
| 2950 | int i; |
| 2951 | |
| 2952 | blob_append_literal(b, "{"); |
| @@ -3016,11 +3016,11 @@ | |
| 3016 | } |
| 3017 | blob_append_char(b, ']'); |
| 3018 | } |
| 3019 | CARD_STR2(K, p->zTicketUuid); |
| 3020 | CARD_STR2(L, p->zWikiTitle); |
| 3021 | ISA( CFTYPE_CLUSTER ){ |
| 3022 | CARD_LETTER(M); |
| 3023 | blob_append_char(b, '['); |
| 3024 | for( int i = 0; i < p->nCChild; ++i ){ |
| 3025 | if( i>0 ) blob_append_char(b, ','); |
| 3026 | blob_appendf(b, "%!j", p->azCChild[i]); |
| @@ -3035,13 +3035,12 @@ | |
| 3035 | for( i = 0; i < p->nParent; ++i ){ |
| 3036 | if( i>0 ) blob_append_char(b, ','); |
| 3037 | blob_appendf(b, "%!j", p->azParent[i]); |
| 3038 | } |
| 3039 | } |
| 3040 | /* Special case: model checkins with no P-card as having an empty |
| 3041 | ** array, as per F-cards. */ |
| 3042 | blob_append_char(b, ']'); |
| 3043 | } |
| 3044 | if( p->nCherrypick ){ |
| 3045 | CARD_LETTER(Q); |
| 3046 | blob_append_char(b, '['); |
| @@ -3062,17 +3061,13 @@ | |
| 3061 | for( int i = 0; i < p->nTag; ++i ){ |
| 3062 | const char *zName = p->aTag[i].zName; |
| 3063 | if( i>0 ) blob_append_char(b, ','); |
| 3064 | blob_append_char(b, '{'); |
| 3065 | blob_appendf(b, "\"type\": \"%c\"", *zName); |
| 3066 | KVP_STR(1, name, &zName[1]); |
| 3067 | KVP_STR(1, target, p->aTag[i].zUuid ? p->aTag[i].zUuid : "*") |
| 3068 | /* We could arguably resolve the "*" as null or p's uuid. */; |
| 3069 | KVP_STR(1, value, p->aTag[i].zValue); |
| 3070 | blob_append_char(b, '}'); |
| 3071 | } |
| 3072 | blob_append_char(b, ']'); |
| 3073 | } |
| 3074 |