Fossil SCM

Renamed /json/artifact/?uuid=xxx to name=xxx (it now matches the docs), minor internal cleanups in /json/artifact.

stephan 2012-03-02 14:25 trunk
Commit d2c5b943f3d7ed23bd9608f2eee8a4714a745530
--- ajax/i-test/rhino-test.js
+++ ajax/i-test/rhino-test.js
@@ -3,11 +3,11 @@
33
'http://localhost:8080'
44
//'http://fjson/cgi-bin/fossil-json.cgi'
55
//'http://192.168.1.62:8080'
66
//'http://fossil.wanderinghorse.net/repos/fossil-json-java/index.cgi'
77
,
8
- verbose:false,
8
+ verbose:true,
99
fossilBinary:'fossil',
1010
wiki:{}
1111
};
1212
(function bootstrap() {
1313
var srcdir = '../js/';
@@ -171,10 +171,26 @@
171171
print("Got first wiki page: "+WhAjaj.stringify(rs.payload));
172172
173173
}
174174
testAnonWiki.description = 'Fetch wiki list as anonymous user.';
175175
176
+function testFetchCheckinArtifact(){
177
+ var art = '18dd383e5e7684ece';
178
+ var rs;
179
+ TestApp.fossil.sendCommand('/json/artifact',{
180
+ 'name': art
181
+ },
182
+ {
183
+ onResponse:function(resp,req){
184
+ rs = resp;
185
+ }
186
+ });
187
+ assertResponseOK(rs);
188
+ assert(3 == rs.payload.artifact.parents.length, 'Got 3 parent artifacts.');
189
+}
190
+testFetchCheckinArtifact.description = '/json/artifact/CHECKIN';
191
+
176192
function testAnonLogout(){
177193
var rs;
178194
TestApp.fossil.logout({
179195
onResponse:function(resp,req){
180196
rs = resp;
@@ -239,10 +255,11 @@
239255
var testList = [
240256
testHAI,
241257
testIAmNobody,
242258
testAnonymousLogin,
243259
testAnonWiki,
260
+ testFetchCheckinArtifact,
244261
testAnonLogout,
245262
testExternalProcess,
246263
testExternalProcessHandler
247264
];
248265
var i, f;
249266
--- ajax/i-test/rhino-test.js
+++ ajax/i-test/rhino-test.js
@@ -3,11 +3,11 @@
3 'http://localhost:8080'
4 //'http://fjson/cgi-bin/fossil-json.cgi'
5 //'http://192.168.1.62:8080'
6 //'http://fossil.wanderinghorse.net/repos/fossil-json-java/index.cgi'
7 ,
8 verbose:false,
9 fossilBinary:'fossil',
10 wiki:{}
11 };
12 (function bootstrap() {
13 var srcdir = '../js/';
@@ -171,10 +171,26 @@
171 print("Got first wiki page: "+WhAjaj.stringify(rs.payload));
172
173 }
174 testAnonWiki.description = 'Fetch wiki list as anonymous user.';
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176 function testAnonLogout(){
177 var rs;
178 TestApp.fossil.logout({
179 onResponse:function(resp,req){
180 rs = resp;
@@ -239,10 +255,11 @@
239 var testList = [
240 testHAI,
241 testIAmNobody,
242 testAnonymousLogin,
243 testAnonWiki,
 
244 testAnonLogout,
245 testExternalProcess,
246 testExternalProcessHandler
247 ];
248 var i, f;
249
--- ajax/i-test/rhino-test.js
+++ ajax/i-test/rhino-test.js
@@ -3,11 +3,11 @@
3 'http://localhost:8080'
4 //'http://fjson/cgi-bin/fossil-json.cgi'
5 //'http://192.168.1.62:8080'
6 //'http://fossil.wanderinghorse.net/repos/fossil-json-java/index.cgi'
7 ,
8 verbose:true,
9 fossilBinary:'fossil',
10 wiki:{}
11 };
12 (function bootstrap() {
13 var srcdir = '../js/';
@@ -171,10 +171,26 @@
171 print("Got first wiki page: "+WhAjaj.stringify(rs.payload));
172
173 }
174 testAnonWiki.description = 'Fetch wiki list as anonymous user.';
175
176 function testFetchCheckinArtifact(){
177 var art = '18dd383e5e7684ece';
178 var rs;
179 TestApp.fossil.sendCommand('/json/artifact',{
180 'name': art
181 },
182 {
183 onResponse:function(resp,req){
184 rs = resp;
185 }
186 });
187 assertResponseOK(rs);
188 assert(3 == rs.payload.artifact.parents.length, 'Got 3 parent artifacts.');
189 }
190 testFetchCheckinArtifact.description = '/json/artifact/CHECKIN';
191
192 function testAnonLogout(){
193 var rs;
194 TestApp.fossil.logout({
195 onResponse:function(resp,req){
196 rs = resp;
@@ -239,10 +255,11 @@
255 var testList = [
256 testHAI,
257 testIAmNobody,
258 testAnonymousLogin,
259 testAnonWiki,
260 testFetchCheckinArtifact,
261 testAnonLogout,
262 testExternalProcess,
263 testExternalProcessHandler
264 ];
265 var i, f;
266
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -81,47 +81,51 @@
8181
**
8282
** Returned value is NULL or an Object owned by the caller.
8383
*/
8484
cson_value * json_artifact_for_ci( int rid, char showFiles ){
8585
cson_value * v = NULL;
86
- Stmt q;
86
+ Stmt q = empty_Stmt;
8787
static cson_value * eventTypeLabel = NULL;
8888
if(!eventTypeLabel){
8989
eventTypeLabel = json_new_string("checkin");
9090
json_gc_add("$EVENT_TYPE_LABEL(commit)", eventTypeLabel);
9191
}
92
-
93
- db_prepare(&q,
94
- "SELECT uuid, "
95
- " cast(strftime('%%s',mtime) as int), "
96
- " user, "
97
- " comment,"
98
- " strftime('%%s',omtime)"
99
- " FROM blob, event"
100
- " WHERE blob.rid=%d"
101
- " AND event.objid=%d",
92
+
93
+ db_prepare(&q,
94
+ "SELECT b.uuid, "
95
+ " cast(strftime('%%s',e.mtime) as int), "
96
+ " strftime('%%s',e.omtime),"
97
+ " e.user, "
98
+ " e.comment"
99
+ " FROM blob b, event e"
100
+ " WHERE b.rid=%d"
101
+ " AND e.objid=%d",
102102
rid, rid
103103
);
104104
if( db_step(&q)==SQLITE_ROW ){
105105
cson_object * o;
106106
cson_value * tmpV = NULL;
107107
const char *zUuid = db_column_text(&q, 0);
108108
const char *zUser;
109109
const char *zComment;
110110
char * zEUser, * zEComment;
111
-#define ADD_PRIMARY_PARENT_UUID 0 /* temporary local macro */
112
-#if ADD_PRIMARY_PARENT_UUID
113
- char * zParent = NULL;
114
-#endif
115111
int mtime, omtime;
116112
v = cson_value_new_object();
117113
o = cson_value_get_object(v);
118114
#define SET(K,V) cson_object_set(o,(K), (V))
119115
SET("type", eventTypeLabel );
120116
SET("uuid",json_new_string(zUuid));
121117
SET("isLeaf", cson_value_new_bool(is_a_leaf(rid)));
122
- zUser = db_column_text(&q,2);
118
+
119
+ mtime = db_column_int(&q,1);
120
+ SET("mtime",json_new_int(mtime));
121
+ omtime = db_column_int(&q,2);
122
+ if(omtime && (omtime!=mtime)){
123
+ SET("originTime",json_new_int(omtime));
124
+ }
125
+
126
+ zUser = db_column_text(&q,3);
123127
zEUser = db_text(0,
124128
"SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
125129
TAG_USER, rid);
126130
if(zEUser){
127131
SET("user", json_new_string(zEUser));
@@ -131,11 +135,11 @@
131135
free(zEUser);
132136
}else{
133137
SET("user",json_new_string(zUser));
134138
}
135139
136
- zComment = db_column_text(&q,3);
140
+ zComment = db_column_text(&q,4);
137141
zEComment = db_text(0,
138142
"SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
139143
TAG_COMMENT, rid);
140144
if(zEComment){
141145
SET("comment",json_new_string(zEComment));
@@ -145,31 +149,10 @@
145149
free(zEComment);
146150
}else{
147151
SET("comment",json_new_string(zComment));
148152
}
149153
150
- mtime = db_column_int(&q,1);
151
- SET("mtime",json_new_int(mtime));
152
- omtime = db_column_int(&q,4);
153
- if(omtime && (omtime!=mtime)){
154
- SET("originTime",json_new_int(omtime));
155
- }
156
-
157
-#if ADD_PRIMARY_PARENT_UUID
158
- zParent = db_text(0,
159
- "SELECT uuid FROM plink, blob"
160
- " WHERE plink.cid=%d AND blob.rid=plink.pid"
161
- " AND plink.isprim",
162
- rid
163
- );
164
- tmpV = zParent ? json_new_string(zParent) : cson_value_null();
165
- free(zParent);
166
- zParent = NULL;
167
- SET("parentUuid", tmpV );
168
-#endif
169
-#undef ADD_PRIMARY_PARENT_UUID
170
-
171154
tmpV = json_parent_uuids_for_ci(rid);
172155
if(tmpV){
173156
SET("parents", tmpV);
174157
}
175158
@@ -223,11 +206,11 @@
223206
224207
/*
225208
** Sub-impl of /json/artifact for checkins.
226209
*/
227210
static cson_value * json_artifact_ci( int rid ){
228
- if(! g.perm.Read ){
211
+ if(! g.perm.History ){
229212
g.json.resultCode = FSL_JSON_E_DENIED;
230213
return NULL;
231214
}else{
232215
return json_artifact_for_ci(rid, 1);
233216
}
@@ -331,14 +314,14 @@
331314
cson_value * entry = NULL;
332315
Blob uuid = empty_blob;
333316
int rc;
334317
int rid = 0;
335318
ArtifactDispatchEntry const * dispatcher = &ArtifactDispatchList[0];
336
- zName = json_find_option_cstr2("uuid", NULL, NULL, 2);
319
+ zName = json_find_option_cstr2("name", NULL, NULL, 2);
337320
if(!zName || !*zName) {
338321
json_set_err(FSL_JSON_E_MISSING_ARGS,
339
- "Missing 'uuid' argument.");
322
+ "Missing 'name' argument.");
340323
return NULL;
341324
}
342325
343326
if( validate16(zName, strlen(zName)) ){
344327
if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'", zName) ){
345328
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -81,47 +81,51 @@
81 **
82 ** Returned value is NULL or an Object owned by the caller.
83 */
84 cson_value * json_artifact_for_ci( int rid, char showFiles ){
85 cson_value * v = NULL;
86 Stmt q;
87 static cson_value * eventTypeLabel = NULL;
88 if(!eventTypeLabel){
89 eventTypeLabel = json_new_string("checkin");
90 json_gc_add("$EVENT_TYPE_LABEL(commit)", eventTypeLabel);
91 }
92
93 db_prepare(&q,
94 "SELECT uuid, "
95 " cast(strftime('%%s',mtime) as int), "
96 " user, "
97 " comment,"
98 " strftime('%%s',omtime)"
99 " FROM blob, event"
100 " WHERE blob.rid=%d"
101 " AND event.objid=%d",
102 rid, rid
103 );
104 if( db_step(&q)==SQLITE_ROW ){
105 cson_object * o;
106 cson_value * tmpV = NULL;
107 const char *zUuid = db_column_text(&q, 0);
108 const char *zUser;
109 const char *zComment;
110 char * zEUser, * zEComment;
111 #define ADD_PRIMARY_PARENT_UUID 0 /* temporary local macro */
112 #if ADD_PRIMARY_PARENT_UUID
113 char * zParent = NULL;
114 #endif
115 int mtime, omtime;
116 v = cson_value_new_object();
117 o = cson_value_get_object(v);
118 #define SET(K,V) cson_object_set(o,(K), (V))
119 SET("type", eventTypeLabel );
120 SET("uuid",json_new_string(zUuid));
121 SET("isLeaf", cson_value_new_bool(is_a_leaf(rid)));
122 zUser = db_column_text(&q,2);
 
 
 
 
 
 
 
 
123 zEUser = db_text(0,
124 "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
125 TAG_USER, rid);
126 if(zEUser){
127 SET("user", json_new_string(zEUser));
@@ -131,11 +135,11 @@
131 free(zEUser);
132 }else{
133 SET("user",json_new_string(zUser));
134 }
135
136 zComment = db_column_text(&q,3);
137 zEComment = db_text(0,
138 "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
139 TAG_COMMENT, rid);
140 if(zEComment){
141 SET("comment",json_new_string(zEComment));
@@ -145,31 +149,10 @@
145 free(zEComment);
146 }else{
147 SET("comment",json_new_string(zComment));
148 }
149
150 mtime = db_column_int(&q,1);
151 SET("mtime",json_new_int(mtime));
152 omtime = db_column_int(&q,4);
153 if(omtime && (omtime!=mtime)){
154 SET("originTime",json_new_int(omtime));
155 }
156
157 #if ADD_PRIMARY_PARENT_UUID
158 zParent = db_text(0,
159 "SELECT uuid FROM plink, blob"
160 " WHERE plink.cid=%d AND blob.rid=plink.pid"
161 " AND plink.isprim",
162 rid
163 );
164 tmpV = zParent ? json_new_string(zParent) : cson_value_null();
165 free(zParent);
166 zParent = NULL;
167 SET("parentUuid", tmpV );
168 #endif
169 #undef ADD_PRIMARY_PARENT_UUID
170
171 tmpV = json_parent_uuids_for_ci(rid);
172 if(tmpV){
173 SET("parents", tmpV);
174 }
175
@@ -223,11 +206,11 @@
223
224 /*
225 ** Sub-impl of /json/artifact for checkins.
226 */
227 static cson_value * json_artifact_ci( int rid ){
228 if(! g.perm.Read ){
229 g.json.resultCode = FSL_JSON_E_DENIED;
230 return NULL;
231 }else{
232 return json_artifact_for_ci(rid, 1);
233 }
@@ -331,14 +314,14 @@
331 cson_value * entry = NULL;
332 Blob uuid = empty_blob;
333 int rc;
334 int rid = 0;
335 ArtifactDispatchEntry const * dispatcher = &ArtifactDispatchList[0];
336 zName = json_find_option_cstr2("uuid", NULL, NULL, 2);
337 if(!zName || !*zName) {
338 json_set_err(FSL_JSON_E_MISSING_ARGS,
339 "Missing 'uuid' argument.");
340 return NULL;
341 }
342
343 if( validate16(zName, strlen(zName)) ){
344 if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'", zName) ){
345
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -81,47 +81,51 @@
81 **
82 ** Returned value is NULL or an Object owned by the caller.
83 */
84 cson_value * json_artifact_for_ci( int rid, char showFiles ){
85 cson_value * v = NULL;
86 Stmt q = empty_Stmt;
87 static cson_value * eventTypeLabel = NULL;
88 if(!eventTypeLabel){
89 eventTypeLabel = json_new_string("checkin");
90 json_gc_add("$EVENT_TYPE_LABEL(commit)", eventTypeLabel);
91 }
92
93 db_prepare(&q,
94 "SELECT b.uuid, "
95 " cast(strftime('%%s',e.mtime) as int), "
96 " strftime('%%s',e.omtime),"
97 " e.user, "
98 " e.comment"
99 " FROM blob b, event e"
100 " WHERE b.rid=%d"
101 " AND e.objid=%d",
102 rid, rid
103 );
104 if( db_step(&q)==SQLITE_ROW ){
105 cson_object * o;
106 cson_value * tmpV = NULL;
107 const char *zUuid = db_column_text(&q, 0);
108 const char *zUser;
109 const char *zComment;
110 char * zEUser, * zEComment;
 
 
 
 
111 int mtime, omtime;
112 v = cson_value_new_object();
113 o = cson_value_get_object(v);
114 #define SET(K,V) cson_object_set(o,(K), (V))
115 SET("type", eventTypeLabel );
116 SET("uuid",json_new_string(zUuid));
117 SET("isLeaf", cson_value_new_bool(is_a_leaf(rid)));
118
119 mtime = db_column_int(&q,1);
120 SET("mtime",json_new_int(mtime));
121 omtime = db_column_int(&q,2);
122 if(omtime && (omtime!=mtime)){
123 SET("originTime",json_new_int(omtime));
124 }
125
126 zUser = db_column_text(&q,3);
127 zEUser = db_text(0,
128 "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
129 TAG_USER, rid);
130 if(zEUser){
131 SET("user", json_new_string(zEUser));
@@ -131,11 +135,11 @@
135 free(zEUser);
136 }else{
137 SET("user",json_new_string(zUser));
138 }
139
140 zComment = db_column_text(&q,4);
141 zEComment = db_text(0,
142 "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
143 TAG_COMMENT, rid);
144 if(zEComment){
145 SET("comment",json_new_string(zEComment));
@@ -145,31 +149,10 @@
149 free(zEComment);
150 }else{
151 SET("comment",json_new_string(zComment));
152 }
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154 tmpV = json_parent_uuids_for_ci(rid);
155 if(tmpV){
156 SET("parents", tmpV);
157 }
158
@@ -223,11 +206,11 @@
206
207 /*
208 ** Sub-impl of /json/artifact for checkins.
209 */
210 static cson_value * json_artifact_ci( int rid ){
211 if(! g.perm.History ){
212 g.json.resultCode = FSL_JSON_E_DENIED;
213 return NULL;
214 }else{
215 return json_artifact_for_ci(rid, 1);
216 }
@@ -331,14 +314,14 @@
314 cson_value * entry = NULL;
315 Blob uuid = empty_blob;
316 int rc;
317 int rid = 0;
318 ArtifactDispatchEntry const * dispatcher = &ArtifactDispatchList[0];
319 zName = json_find_option_cstr2("name", NULL, NULL, 2);
320 if(!zName || !*zName) {
321 json_set_err(FSL_JSON_E_MISSING_ARGS,
322 "Missing 'name' argument.");
323 return NULL;
324 }
325
326 if( validate16(zName, strlen(zName)) ){
327 if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'", zName) ){
328

Keyboard Shortcuts

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