Fossil SCM

give 'json status' the same rename treatment as recent status work As reported by larrybr on the forum: [forum:9e9778f2e6], 'fossil json status' reports renamed _and_ edited files as only renamed. This change reports such cases as both edited and renamed, and displays the filename prior to being renamed as well as the renamed path. We now also update the vfile table before generating the status report to ensure the current checkout state is reported.

mark 2023-07-01 16:06 trunk
Commit 771e592b4c59ad59a28f586bba12a528a27e8e4892e72d48000bc38c8cc6c623
1 file changed +19 -5
--- src/json_status.c
+++ src/json_status.c
@@ -60,10 +60,11 @@
6060
vid = db_lget_int("checkout", 0);
6161
if(!vid){
6262
json_set_err( FSL_JSON_E_UNKNOWN, "Can this even happen?" );
6363
return 0;
6464
}
65
+ vfile_check_signature(vid, 0);
6566
/* TODO: dupe show_common_info() state */
6667
tmpO = cson_new_object();
6768
cson_object_set(oPay, "checkout", cson_object_value(tmpO));
6869
6970
zTmp = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
@@ -93,16 +94,18 @@
9394
/* Now get the list of non-pristine files... */
9495
aFiles = cson_new_array();
9596
cson_object_set( oPay, "files", cson_array_value( aFiles ) );
9697
9798
db_prepare(&q,
98
- "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
99
+ "SELECT pathname, deleted, chnged, rid, "
100
+ " coalesce(origname!=pathname,0), origname"
99101
" FROM vfile "
100102
" WHERE is_selected(id)"
101103
" AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1"
102104
);
103105
while( db_step(&q)==SQLITE_ROW ){
106
+ cson_array *aStatuses = NULL;
104107
const char *zPathname = db_column_text(&q,0);
105108
int isDeleted = db_column_int(&q, 1);
106109
int isChnged = db_column_int(&q,2);
107110
int isNew = db_column_int(&q,3)==0;
108111
int isRenamed = db_column_int(&q,4);
@@ -112,12 +115,10 @@
112115
if( isDeleted ){
113116
zStatus = "deleted";
114117
}else if( isNew ){
115118
zStatus = "new" /* maintenance reminder: MUST come
116119
BEFORE the isChnged checks. */;
117
- }else if( isRenamed ){
118
- zStatus = "renamed";
119120
}else if( !file_isfile_or_link(zFullName) ){
120121
if( file_access(zFullName, F_OK)==0 ){
121122
zStatus = "notAFile";
122123
++nErr;
123124
}else{
@@ -137,17 +138,30 @@
137138
zStatus = "conflict";
138139
}else{
139140
zStatus = "edited";
140141
}
141142
}
142
-
143143
oFile = cson_new_object();
144144
cson_array_append( aFiles, cson_object_value(oFile) );
145
+ if( isRenamed ){
146
+ if( *zStatus!='?' ){
147
+ aStatuses = cson_new_array();
148
+ cson_object_set( oFile, "status", cson_array_value( aStatuses ) );
149
+ cson_array_append(aStatuses,
150
+ cson_value_new_string(zStatus, strlen(zStatus)));
151
+ cson_array_append(aStatuses, cson_value_new_string("renamed", 7));
152
+ }else{
153
+ zStatus = "renamed";
154
+ }
155
+ cson_object_set( oFile, "priorName",
156
+ cson_sqlite3_column_to_value(q.pStmt,5));
157
+ }
145158
/* optimization potential: move these keys into cson_strings
146159
to take advantage of refcounting. */
147160
cson_object_set( oFile, "name", json_new_string( zPathname ) );
148
- cson_object_set( oFile, "status", json_new_string( zStatus ) );
161
+ cson_object_set( oFile, "status", aStatuses!=NULL ?
162
+ cson_array_value(aStatuses) : json_new_string( zStatus ) );
149163
150164
free(zFullName);
151165
}
152166
cson_object_set( oPay, "errorCount", json_new_int( nErr ) );
153167
db_finalize(&q);
154168
--- src/json_status.c
+++ src/json_status.c
@@ -60,10 +60,11 @@
60 vid = db_lget_int("checkout", 0);
61 if(!vid){
62 json_set_err( FSL_JSON_E_UNKNOWN, "Can this even happen?" );
63 return 0;
64 }
 
65 /* TODO: dupe show_common_info() state */
66 tmpO = cson_new_object();
67 cson_object_set(oPay, "checkout", cson_object_value(tmpO));
68
69 zTmp = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
@@ -93,16 +94,18 @@
93 /* Now get the list of non-pristine files... */
94 aFiles = cson_new_array();
95 cson_object_set( oPay, "files", cson_array_value( aFiles ) );
96
97 db_prepare(&q,
98 "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
 
99 " FROM vfile "
100 " WHERE is_selected(id)"
101 " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1"
102 );
103 while( db_step(&q)==SQLITE_ROW ){
 
104 const char *zPathname = db_column_text(&q,0);
105 int isDeleted = db_column_int(&q, 1);
106 int isChnged = db_column_int(&q,2);
107 int isNew = db_column_int(&q,3)==0;
108 int isRenamed = db_column_int(&q,4);
@@ -112,12 +115,10 @@
112 if( isDeleted ){
113 zStatus = "deleted";
114 }else if( isNew ){
115 zStatus = "new" /* maintenance reminder: MUST come
116 BEFORE the isChnged checks. */;
117 }else if( isRenamed ){
118 zStatus = "renamed";
119 }else if( !file_isfile_or_link(zFullName) ){
120 if( file_access(zFullName, F_OK)==0 ){
121 zStatus = "notAFile";
122 ++nErr;
123 }else{
@@ -137,17 +138,30 @@
137 zStatus = "conflict";
138 }else{
139 zStatus = "edited";
140 }
141 }
142
143 oFile = cson_new_object();
144 cson_array_append( aFiles, cson_object_value(oFile) );
 
 
 
 
 
 
 
 
 
 
 
 
 
145 /* optimization potential: move these keys into cson_strings
146 to take advantage of refcounting. */
147 cson_object_set( oFile, "name", json_new_string( zPathname ) );
148 cson_object_set( oFile, "status", json_new_string( zStatus ) );
 
149
150 free(zFullName);
151 }
152 cson_object_set( oPay, "errorCount", json_new_int( nErr ) );
153 db_finalize(&q);
154
--- src/json_status.c
+++ src/json_status.c
@@ -60,10 +60,11 @@
60 vid = db_lget_int("checkout", 0);
61 if(!vid){
62 json_set_err( FSL_JSON_E_UNKNOWN, "Can this even happen?" );
63 return 0;
64 }
65 vfile_check_signature(vid, 0);
66 /* TODO: dupe show_common_info() state */
67 tmpO = cson_new_object();
68 cson_object_set(oPay, "checkout", cson_object_value(tmpO));
69
70 zTmp = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
@@ -93,16 +94,18 @@
94 /* Now get the list of non-pristine files... */
95 aFiles = cson_new_array();
96 cson_object_set( oPay, "files", cson_array_value( aFiles ) );
97
98 db_prepare(&q,
99 "SELECT pathname, deleted, chnged, rid, "
100 " coalesce(origname!=pathname,0), origname"
101 " FROM vfile "
102 " WHERE is_selected(id)"
103 " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1"
104 );
105 while( db_step(&q)==SQLITE_ROW ){
106 cson_array *aStatuses = NULL;
107 const char *zPathname = db_column_text(&q,0);
108 int isDeleted = db_column_int(&q, 1);
109 int isChnged = db_column_int(&q,2);
110 int isNew = db_column_int(&q,3)==0;
111 int isRenamed = db_column_int(&q,4);
@@ -112,12 +115,10 @@
115 if( isDeleted ){
116 zStatus = "deleted";
117 }else if( isNew ){
118 zStatus = "new" /* maintenance reminder: MUST come
119 BEFORE the isChnged checks. */;
 
 
120 }else if( !file_isfile_or_link(zFullName) ){
121 if( file_access(zFullName, F_OK)==0 ){
122 zStatus = "notAFile";
123 ++nErr;
124 }else{
@@ -137,17 +138,30 @@
138 zStatus = "conflict";
139 }else{
140 zStatus = "edited";
141 }
142 }
 
143 oFile = cson_new_object();
144 cson_array_append( aFiles, cson_object_value(oFile) );
145 if( isRenamed ){
146 if( *zStatus!='?' ){
147 aStatuses = cson_new_array();
148 cson_object_set( oFile, "status", cson_array_value( aStatuses ) );
149 cson_array_append(aStatuses,
150 cson_value_new_string(zStatus, strlen(zStatus)));
151 cson_array_append(aStatuses, cson_value_new_string("renamed", 7));
152 }else{
153 zStatus = "renamed";
154 }
155 cson_object_set( oFile, "priorName",
156 cson_sqlite3_column_to_value(q.pStmt,5));
157 }
158 /* optimization potential: move these keys into cson_strings
159 to take advantage of refcounting. */
160 cson_object_set( oFile, "name", json_new_string( zPathname ) );
161 cson_object_set( oFile, "status", aStatuses!=NULL ?
162 cson_array_value(aStatuses) : json_new_string( zStatus ) );
163
164 free(zFullName);
165 }
166 cson_object_set( oPay, "errorCount", json_new_int( nErr ) );
167 db_finalize(&q);
168

Keyboard Shortcuts

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