Fossil SCM

more timeline/artifact refactoring.

stephan 2011-10-01 07:04 UTC json-multitag-test
Commit 22fc0ab81bf965cad657992932d559850a79bd8a
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -98,22 +98,23 @@
9898
}
9999
100100
if(zParent){
101101
SET("parentUuid", json_new_string(zParent));
102102
}
103
+
104
+ tmpV = json_tags_for_rid(rid);
105
+ if(tmpV){
106
+ SET("tags",tmpV);
107
+ }
103108
104109
if( showFiles ){
105
- cson_value * fileList = json_timeline_get_changed_files(rid);
110
+ cson_value * fileList = json_get_changed_files(rid);
106111
if(fileList){
107112
SET("files",fileList);
108113
}
109114
}
110115
111
- tmpV = json_tags_for_rid(rid);
112
- if(tmpV){
113
- SET("tags",tmpV);
114
- }
115116
116117
#undef SET
117118
}
118119
db_finalize(&q);
119120
return v;
@@ -178,12 +179,12 @@
178179
goto error;
179180
}else if(2==rc){
180181
g.json.resultCode = FSL_JSON_E_AMBIGUOUS_UUID;
181182
goto error;
182183
}
183
- zUuid = zName = blob_str(&uuid);
184
- rid = db_int(0, "SELECT rid FROM blob WHERE uuid='%s'", zName);
184
+ zUuid = blob_str(&uuid);
185
+ rid = db_int(0, "SELECT rid FROM blob WHERE uuid='%s'", zUuid);
185186
if(0==rid){
186187
g.json.resultCode = FSL_JSON_E_RESOURCE_NOT_FOUND;
187188
goto error;
188189
}
189190
if( db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid)
@@ -211,11 +212,12 @@
211212
end_ok:
212213
payV = cson_value_new_object();
213214
pay = cson_value_get_object(payV);
214215
assert( NULL != zType );
215216
cson_object_set( pay, "type", json_new_string(zType) );
216
- cson_object_set( pay, "id", json_new_string(zName) );
217
+ /*cson_object_set( pay, "uuid", json_new_string(zUuid) );*/
218
+ cson_object_set( pay, "name", json_new_string(zName ? zName : zUuid) );
217219
cson_object_set( pay, "rid", cson_value_new_integer(rid) );
218220
ArtifactDispatchEntry const * disp = &ArtifactDispatchList[0];
219221
for( ; disp->name; ++disp ){
220222
if(0!=strcmp(disp->name, zType)){
221223
continue;
@@ -229,10 +231,14 @@
229231
cson_object_set(pay, "artifact", entry);
230232
}
231233
break;
232234
}
233235
}
236
+ if( !disp->name ){
237
+ cson_object_set(pay,"artifact",
238
+ json_new_string("TODO: handle this artifact type!"));
239
+ }
234240
veryend:
235241
blob_reset(&uuid);
236242
return payV;
237243
}
238244
239245
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -98,22 +98,23 @@
98 }
99
100 if(zParent){
101 SET("parentUuid", json_new_string(zParent));
102 }
 
 
 
 
 
103
104 if( showFiles ){
105 cson_value * fileList = json_timeline_get_changed_files(rid);
106 if(fileList){
107 SET("files",fileList);
108 }
109 }
110
111 tmpV = json_tags_for_rid(rid);
112 if(tmpV){
113 SET("tags",tmpV);
114 }
115
116 #undef SET
117 }
118 db_finalize(&q);
119 return v;
@@ -178,12 +179,12 @@
178 goto error;
179 }else if(2==rc){
180 g.json.resultCode = FSL_JSON_E_AMBIGUOUS_UUID;
181 goto error;
182 }
183 zUuid = zName = blob_str(&uuid);
184 rid = db_int(0, "SELECT rid FROM blob WHERE uuid='%s'", zName);
185 if(0==rid){
186 g.json.resultCode = FSL_JSON_E_RESOURCE_NOT_FOUND;
187 goto error;
188 }
189 if( db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid)
@@ -211,11 +212,12 @@
211 end_ok:
212 payV = cson_value_new_object();
213 pay = cson_value_get_object(payV);
214 assert( NULL != zType );
215 cson_object_set( pay, "type", json_new_string(zType) );
216 cson_object_set( pay, "id", json_new_string(zName) );
 
217 cson_object_set( pay, "rid", cson_value_new_integer(rid) );
218 ArtifactDispatchEntry const * disp = &ArtifactDispatchList[0];
219 for( ; disp->name; ++disp ){
220 if(0!=strcmp(disp->name, zType)){
221 continue;
@@ -229,10 +231,14 @@
229 cson_object_set(pay, "artifact", entry);
230 }
231 break;
232 }
233 }
 
 
 
 
234 veryend:
235 blob_reset(&uuid);
236 return payV;
237 }
238
239
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -98,22 +98,23 @@
98 }
99
100 if(zParent){
101 SET("parentUuid", json_new_string(zParent));
102 }
103
104 tmpV = json_tags_for_rid(rid);
105 if(tmpV){
106 SET("tags",tmpV);
107 }
108
109 if( showFiles ){
110 cson_value * fileList = json_get_changed_files(rid);
111 if(fileList){
112 SET("files",fileList);
113 }
114 }
115
 
 
 
 
116
117 #undef SET
118 }
119 db_finalize(&q);
120 return v;
@@ -178,12 +179,12 @@
179 goto error;
180 }else if(2==rc){
181 g.json.resultCode = FSL_JSON_E_AMBIGUOUS_UUID;
182 goto error;
183 }
184 zUuid = blob_str(&uuid);
185 rid = db_int(0, "SELECT rid FROM blob WHERE uuid='%s'", zUuid);
186 if(0==rid){
187 g.json.resultCode = FSL_JSON_E_RESOURCE_NOT_FOUND;
188 goto error;
189 }
190 if( db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid)
@@ -211,11 +212,12 @@
212 end_ok:
213 payV = cson_value_new_object();
214 pay = cson_value_get_object(payV);
215 assert( NULL != zType );
216 cson_object_set( pay, "type", json_new_string(zType) );
217 /*cson_object_set( pay, "uuid", json_new_string(zUuid) );*/
218 cson_object_set( pay, "name", json_new_string(zName ? zName : zUuid) );
219 cson_object_set( pay, "rid", cson_value_new_integer(rid) );
220 ArtifactDispatchEntry const * disp = &ArtifactDispatchList[0];
221 for( ; disp->name; ++disp ){
222 if(0!=strcmp(disp->name, zType)){
223 continue;
@@ -229,10 +231,14 @@
231 cson_object_set(pay, "artifact", entry);
232 }
233 break;
234 }
235 }
236 if( !disp->name ){
237 cson_object_set(pay,"artifact",
238 json_new_string("TODO: handle this artifact type!"));
239 }
240 veryend:
241 blob_reset(&uuid);
242 return payV;
243 }
244
245
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -198,11 +198,11 @@
198198
/*
199199
** If any files are associated with the given rid, a JSON array
200200
** containing information about them is returned (and is owned by the
201201
** caller). If no files are associated with it then NULL is returned.
202202
*/
203
-cson_value * json_timeline_get_changed_files(int rid){
203
+cson_value * json_get_changed_files(int rid){
204204
cson_value * rowsV = NULL;
205205
cson_array * rows = NULL;
206206
Stmt q;
207207
db_prepare(&q,
208208
#if 0
@@ -216,12 +216,12 @@
216216
" ORDER BY 3 /*sort*/",
217217
#else
218218
"SELECT (pid==0) AS isnew,"
219219
" (fid==0) AS isdel,"
220220
" (SELECT name FROM filename WHERE fnid=mlink.fnid) AS name,"
221
- " (SELECT uuid FROM blob WHERE rid=fid),"
222
- " (SELECT uuid FROM blob WHERE rid=pid)"
221
+ " (SELECT uuid FROM blob WHERE rid=fid) as uuid,"
222
+ " (SELECT uuid FROM blob WHERE rid=pid) as prevUuid"
223223
" FROM mlink"
224224
" WHERE mid=%d AND pid!=fid"
225225
" ORDER BY 3 /*sort*/",
226226
#endif
227227
rid
@@ -302,14 +302,13 @@
302302
#endif
303303
" comment AS comment, "
304304
" user AS user,"
305305
" isLeaf AS isLeaf," /*FIXME: convert to JSON bool */
306306
" bgColor AS bgColor," /* why always null? */
307
- " eventType AS eventType,"
308
- " tags AS tags" /*FIXME: split this into
309
- a JSON array*/
307
+ " eventType AS eventType"
310308
#if 0
309
+ " tags AS tags"
311310
/*tagId is always null?*/
312311
" tagId AS tagId"
313312
#endif
314313
" FROM json_timeline"
315314
" ORDER BY sortId");
@@ -344,11 +343,11 @@
344343
? cson_value_true()
345344
: cson_value_false());
346345
tmp = NULL;
347346
}
348347
if( showFiles ){
349
- cson_value * flist = json_timeline_get_changed_files(rid);
348
+ cson_value * flist = json_get_changed_files(rid);
350349
if(flist){
351350
cson_object_set(row,"files",flist);
352351
}
353352
}
354353
}
355354
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -198,11 +198,11 @@
198 /*
199 ** If any files are associated with the given rid, a JSON array
200 ** containing information about them is returned (and is owned by the
201 ** caller). If no files are associated with it then NULL is returned.
202 */
203 cson_value * json_timeline_get_changed_files(int rid){
204 cson_value * rowsV = NULL;
205 cson_array * rows = NULL;
206 Stmt q;
207 db_prepare(&q,
208 #if 0
@@ -216,12 +216,12 @@
216 " ORDER BY 3 /*sort*/",
217 #else
218 "SELECT (pid==0) AS isnew,"
219 " (fid==0) AS isdel,"
220 " (SELECT name FROM filename WHERE fnid=mlink.fnid) AS name,"
221 " (SELECT uuid FROM blob WHERE rid=fid),"
222 " (SELECT uuid FROM blob WHERE rid=pid)"
223 " FROM mlink"
224 " WHERE mid=%d AND pid!=fid"
225 " ORDER BY 3 /*sort*/",
226 #endif
227 rid
@@ -302,14 +302,13 @@
302 #endif
303 " comment AS comment, "
304 " user AS user,"
305 " isLeaf AS isLeaf," /*FIXME: convert to JSON bool */
306 " bgColor AS bgColor," /* why always null? */
307 " eventType AS eventType,"
308 " tags AS tags" /*FIXME: split this into
309 a JSON array*/
310 #if 0
 
311 /*tagId is always null?*/
312 " tagId AS tagId"
313 #endif
314 " FROM json_timeline"
315 " ORDER BY sortId");
@@ -344,11 +343,11 @@
344 ? cson_value_true()
345 : cson_value_false());
346 tmp = NULL;
347 }
348 if( showFiles ){
349 cson_value * flist = json_timeline_get_changed_files(rid);
350 if(flist){
351 cson_object_set(row,"files",flist);
352 }
353 }
354 }
355
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -198,11 +198,11 @@
198 /*
199 ** If any files are associated with the given rid, a JSON array
200 ** containing information about them is returned (and is owned by the
201 ** caller). If no files are associated with it then NULL is returned.
202 */
203 cson_value * json_get_changed_files(int rid){
204 cson_value * rowsV = NULL;
205 cson_array * rows = NULL;
206 Stmt q;
207 db_prepare(&q,
208 #if 0
@@ -216,12 +216,12 @@
216 " ORDER BY 3 /*sort*/",
217 #else
218 "SELECT (pid==0) AS isnew,"
219 " (fid==0) AS isdel,"
220 " (SELECT name FROM filename WHERE fnid=mlink.fnid) AS name,"
221 " (SELECT uuid FROM blob WHERE rid=fid) as uuid,"
222 " (SELECT uuid FROM blob WHERE rid=pid) as prevUuid"
223 " FROM mlink"
224 " WHERE mid=%d AND pid!=fid"
225 " ORDER BY 3 /*sort*/",
226 #endif
227 rid
@@ -302,14 +302,13 @@
302 #endif
303 " comment AS comment, "
304 " user AS user,"
305 " isLeaf AS isLeaf," /*FIXME: convert to JSON bool */
306 " bgColor AS bgColor," /* why always null? */
307 " eventType AS eventType"
 
 
308 #if 0
309 " tags AS tags"
310 /*tagId is always null?*/
311 " tagId AS tagId"
312 #endif
313 " FROM json_timeline"
314 " ORDER BY sortId");
@@ -344,11 +343,11 @@
343 ? cson_value_true()
344 : cson_value_false());
345 tmp = NULL;
346 }
347 if( showFiles ){
348 cson_value * flist = json_get_changed_files(rid);
349 if(flist){
350 cson_object_set(row,"files",flist);
351 }
352 }
353 }
354

Keyboard Shortcuts

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