Fossil SCM

added current branch name to /json/branch/list payload when in an opened checkout.

stephan 2011-09-21 20:03 json
Commit 7592fe934be48540dd6e7d6ea35d0a0c5c21eda1
1 file changed +22
+22
--- src/json.c
+++ src/json.c
@@ -275,10 +275,18 @@
275275
*/
276276
cson_value * json_rc_string( int code ){
277277
return cson_value_new_string( json_rc_cstr(code), 11 );
278278
}
279279
280
+/*
281
+** Convenience wrapper around cson_value_new_string().
282
+*/
283
+cson_value * json_new_string( char const * str ){
284
+ return str
285
+ ? cson_value_new_string(str,strlen(str))
286
+ : NULL;
287
+}
280288
281289
/*
282290
** Gets a POST/POST.payload/GET/COOKIE/ENV value. The returned memory
283291
** is owned by the g.json object (one of its sub-objects). Returns
284292
** NULL if no match is found.
@@ -1630,10 +1638,24 @@
16301638
range = "open";
16311639
which = 0;
16321640
break;
16331641
};
16341642
cson_object_set(pay,"range",cson_value_new_string(range,strlen(range)));
1643
+
1644
+ if( g.localOpen ){
1645
+ int vid = db_lget_int("checkout", 0);
1646
+ char const * zCurrent = vid
1647
+ ? db_text(0, "SELECT value FROM tagxref"
1648
+ " WHERE rid=%d AND tagid=%d",
1649
+ vid, TAG_BRANCH)
1650
+ : 0;
1651
+ if(zCurrent){
1652
+ cson_object_set(pay,"current",json_new_string(zCurrent));
1653
+ }
1654
+ }
1655
+
1656
+
16351657
branch_prepare_list_query(&q, which);
16361658
cson_object_set(pay,"branches",listV);
16371659
while((SQLITE_ROW==db_step(&q))){
16381660
cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0);
16391661
if(v){
16401662
--- src/json.c
+++ src/json.c
@@ -275,10 +275,18 @@
275 */
276 cson_value * json_rc_string( int code ){
277 return cson_value_new_string( json_rc_cstr(code), 11 );
278 }
279
 
 
 
 
 
 
 
 
280
281 /*
282 ** Gets a POST/POST.payload/GET/COOKIE/ENV value. The returned memory
283 ** is owned by the g.json object (one of its sub-objects). Returns
284 ** NULL if no match is found.
@@ -1630,10 +1638,24 @@
1630 range = "open";
1631 which = 0;
1632 break;
1633 };
1634 cson_object_set(pay,"range",cson_value_new_string(range,strlen(range)));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1635 branch_prepare_list_query(&q, which);
1636 cson_object_set(pay,"branches",listV);
1637 while((SQLITE_ROW==db_step(&q))){
1638 cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0);
1639 if(v){
1640
--- src/json.c
+++ src/json.c
@@ -275,10 +275,18 @@
275 */
276 cson_value * json_rc_string( int code ){
277 return cson_value_new_string( json_rc_cstr(code), 11 );
278 }
279
280 /*
281 ** Convenience wrapper around cson_value_new_string().
282 */
283 cson_value * json_new_string( char const * str ){
284 return str
285 ? cson_value_new_string(str,strlen(str))
286 : NULL;
287 }
288
289 /*
290 ** Gets a POST/POST.payload/GET/COOKIE/ENV value. The returned memory
291 ** is owned by the g.json object (one of its sub-objects). Returns
292 ** NULL if no match is found.
@@ -1630,10 +1638,24 @@
1638 range = "open";
1639 which = 0;
1640 break;
1641 };
1642 cson_object_set(pay,"range",cson_value_new_string(range,strlen(range)));
1643
1644 if( g.localOpen ){
1645 int vid = db_lget_int("checkout", 0);
1646 char const * zCurrent = vid
1647 ? db_text(0, "SELECT value FROM tagxref"
1648 " WHERE rid=%d AND tagid=%d",
1649 vid, TAG_BRANCH)
1650 : 0;
1651 if(zCurrent){
1652 cson_object_set(pay,"current",json_new_string(zCurrent));
1653 }
1654 }
1655
1656
1657 branch_prepare_list_query(&q, which);
1658 cson_object_set(pay,"branches",listV);
1659 while((SQLITE_ROW==db_step(&q))){
1660 cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0);
1661 if(v){
1662

Keyboard Shortcuts

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