Fossil SCM

Further minor internal artifact_to_json() cleanups.

stephan 2025-03-24 19:02 trunk
Commit ca8d6eee8a4d82bcbfb478a5d6c17d17a7ec62b140fee2404380590b3d1ffe75
1 file changed +9 -14
+9 -14
--- src/manifest.c
+++ src/manifest.c
@@ -2939,14 +2939,14 @@
29392939
** Creates a JSON representation of p, appending it to b.
29402940
**
29412941
** b is not cleared before rendering, so the caller needs to do that
29422942
** if it's important for their use case.
29432943
**
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.
29482948
*/
29492949
void artifact_to_json(Manifest const *p, Blob *b){
29502950
int i;
29512951
29522952
blob_append_literal(b, "{");
@@ -3016,11 +3016,11 @@
30163016
}
30173017
blob_append_char(b, ']');
30183018
}
30193019
CARD_STR2(K, p->zTicketUuid);
30203020
CARD_STR2(L, p->zWikiTitle);
3021
- ISA( CFTYPE_CLUSTER && p->nCChild>0 ){
3021
+ ISA( CFTYPE_CLUSTER ){
30223022
CARD_LETTER(M);
30233023
blob_append_char(b, '[');
30243024
for( int i = 0; i < p->nCChild; ++i ){
30253025
if( i>0 ) blob_append_char(b, ',');
30263026
blob_appendf(b, "%!j", p->azCChild[i]);
@@ -3035,13 +3035,12 @@
30353035
for( i = 0; i < p->nParent; ++i ){
30363036
if( i>0 ) blob_append_char(b, ',');
30373037
blob_appendf(b, "%!j", p->azParent[i]);
30383038
}
30393039
}
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. */
30433042
blob_append_char(b, ']');
30443043
}
30453044
if( p->nCherrypick ){
30463045
CARD_LETTER(Q);
30473046
blob_append_char(b, '[');
@@ -3062,17 +3061,13 @@
30623061
for( int i = 0; i < p->nTag; ++i ){
30633062
const char *zName = p->aTag[i].zName;
30643063
if( i>0 ) blob_append_char(b, ',');
30653064
blob_append_char(b, '{');
30663065
blob_appendf(b, "\"type\": \"%c\"", *zName);
3067
- ++zName;
3068
- KVP_STR(1, name, zName);
3066
+ KVP_STR(1, name, &zName[1]);
30693067
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. */;
30743069
KVP_STR(1, value, p->aTag[i].zValue);
30753070
blob_append_char(b, '}');
30763071
}
30773072
blob_append_char(b, ']');
30783073
}
30793074
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button