Fossil SCM

Added /json/tag/cancel.

stephan 2011-10-06 21:25 UTC json-multitag-test
Commit 0b685fcc0f2ef0952e1665c19cfce33664705bfe
1 file changed +40 -4
+40 -4
--- src/json_tag.c
+++ src/json_tag.c
@@ -137,14 +137,50 @@
137137
138138
/*
139139
** Impl of /json/tag/cancel.
140140
*/
141141
static cson_value * json_tag_cancel(){
142
- cson_value * payV = NULL;
143
- cson_object * pay = NULL;
144
- g.json.resultCode = FSL_JSON_E_NYI;
145
- return payV;
142
+ char const * zName = NULL;
143
+ char const * zCheckin = NULL;
144
+ char fRaw = 0;
145
+ const char *zPrefix = NULL;
146
+
147
+ if( !g.perm.Write ){
148
+ json_set_err(FSL_JSON_E_DENIED,
149
+ "Requires 'i' permissions.");
150
+ return NULL;
151
+ }
152
+
153
+ fRaw = json_find_option_bool("raw",NULL,NULL,0);
154
+ zPrefix = fRaw ? "" : "sym-";
155
+ zName = json_find_option_cstr("name",NULL,NULL);
156
+ if(!zName || !*zName){
157
+ if(!fossil_is_json()){
158
+ zName = json_command_arg(3);
159
+ }
160
+ if(!zName || !*zName){
161
+ json_set_err(FSL_JSON_E_MISSING_ARGS,
162
+ "'name' parameter is missing.");
163
+ return NULL;
164
+ }
165
+ }
166
+
167
+ zCheckin = json_find_option_cstr("checkin",NULL,NULL);
168
+ if( !zCheckin ){
169
+ if(!fossil_is_json()){
170
+ zCheckin = json_command_arg(4);
171
+ }
172
+ if(!zCheckin || !*zCheckin){
173
+ json_set_err(FSL_JSON_E_MISSING_ARGS,
174
+ "'checkin' parameter is missing.");
175
+ return NULL;
176
+ }
177
+ }
178
+ db_begin_transaction();
179
+ tag_add_artifact(zPrefix, zName, zCheckin, NULL, 0, 0, 0);
180
+ db_end_transaction(0);
181
+ return NULL;
146182
}
147183
148184
149185
/*
150186
** Impl of /json/tag/find.
151187
--- src/json_tag.c
+++ src/json_tag.c
@@ -137,14 +137,50 @@
137
138 /*
139 ** Impl of /json/tag/cancel.
140 */
141 static cson_value * json_tag_cancel(){
142 cson_value * payV = NULL;
143 cson_object * pay = NULL;
144 g.json.resultCode = FSL_JSON_E_NYI;
145 return payV;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146 }
147
148
149 /*
150 ** Impl of /json/tag/find.
151
--- src/json_tag.c
+++ src/json_tag.c
@@ -137,14 +137,50 @@
137
138 /*
139 ** Impl of /json/tag/cancel.
140 */
141 static cson_value * json_tag_cancel(){
142 char const * zName = NULL;
143 char const * zCheckin = NULL;
144 char fRaw = 0;
145 const char *zPrefix = NULL;
146
147 if( !g.perm.Write ){
148 json_set_err(FSL_JSON_E_DENIED,
149 "Requires 'i' permissions.");
150 return NULL;
151 }
152
153 fRaw = json_find_option_bool("raw",NULL,NULL,0);
154 zPrefix = fRaw ? "" : "sym-";
155 zName = json_find_option_cstr("name",NULL,NULL);
156 if(!zName || !*zName){
157 if(!fossil_is_json()){
158 zName = json_command_arg(3);
159 }
160 if(!zName || !*zName){
161 json_set_err(FSL_JSON_E_MISSING_ARGS,
162 "'name' parameter is missing.");
163 return NULL;
164 }
165 }
166
167 zCheckin = json_find_option_cstr("checkin",NULL,NULL);
168 if( !zCheckin ){
169 if(!fossil_is_json()){
170 zCheckin = json_command_arg(4);
171 }
172 if(!zCheckin || !*zCheckin){
173 json_set_err(FSL_JSON_E_MISSING_ARGS,
174 "'checkin' parameter is missing.");
175 return NULL;
176 }
177 }
178 db_begin_transaction();
179 tag_add_artifact(zPrefix, zName, zCheckin, NULL, 0, 0, 0);
180 db_end_transaction(0);
181 return NULL;
182 }
183
184
185 /*
186 ** Impl of /json/tag/find.
187

Keyboard Shortcuts

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