Fossil SCM

show original path of renamed files in changes/status output For context, print renamed files in the form "from -> to" except in the `fossil {changes,status} --renamed` case as suggested by wyoung. Requested by ams in [forum:9ca95426f]. ok stephan in /chat

mark 2022-07-13 07:38 trunk
Commit 1b8cfdb01a876adcd74f9f432d84ff011de5f638a3334eb4ba53d302ce283f98
1 file changed +10 -3
+10 -3
--- src/checkin.c
+++ src/checkin.c
@@ -153,11 +153,12 @@
153153
blob_zero(&sql);
154154
if( flags & C_ALL ){
155155
/* Start with a list of all managed files. */
156156
blob_append_sql(&sql,
157157
"SELECT pathname, %s as mtime, %s as size, deleted, chnged, rid,"
158
- " coalesce(origname!=pathname,0) AS renamed, 1 AS managed"
158
+ " coalesce(origname!=pathname,0) AS renamed, 1 AS managed,"
159
+ " origname"
159160
" FROM vfile LEFT JOIN blob USING (rid)"
160161
" WHERE is_selected(id)%s",
161162
flags & C_MTIME ? "datetime(checkin_mtime(:vid, rid), "
162163
"'unixepoch', toLocal())" : "''" /*safe-for-%s*/,
163164
flags & C_SIZE ? "coalesce(blob.size, 0)" : "0" /*safe-for-%s*/,
@@ -174,11 +175,11 @@
174175
if( flags & C_EXTRA ){
175176
if( blob_size(&sql) ){
176177
blob_append_sql(&sql, " UNION ALL");
177178
}
178179
blob_append_sql(&sql,
179
- " SELECT pathname, %s, %s, 0, 0, 0, 0, 0"
180
+ " SELECT pathname, %s, %s, 0, 0, 0, 0, 0, NULL"
180181
" FROM sfile WHERE pathname NOT IN (%s)%s",
181182
flags & C_MTIME ? "datetime(mtime, 'unixepoch', toLocal())" : "''",
182183
flags & C_SIZE ? "size" : "0",
183184
fossil_all_reserved_names(0), blob_sql_text(&where));
184185
}
@@ -211,10 +212,11 @@
211212
int size = db_column_int(&q, 2);
212213
int isDeleted = db_column_int(&q, 3);
213214
int isChnged = db_column_int(&q, 4);
214215
int isNew = isManaged && !db_column_int(&q, 5);
215216
int isRenamed = db_column_int(&q, 6);
217
+ const char *zOrigName = 0;
216218
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
217219
int isMissing = !file_isfile_or_link(zFullName);
218220
219221
/* Determine the file change classification, if any. */
220222
if( isDeleted ){
@@ -265,10 +267,11 @@
265267
}else if( (flags & (C_EDITED | C_CHANGED)) && isChnged
266268
&& (isChnged<2 || isChnged>9) ){
267269
zClass = "EDITED";
268270
}else if( (flags & C_RENAMED) && isRenamed ){
269271
zClass = "RENAMED";
272
+ zOrigName = db_column_text(&q,8);
270273
}else if( (flags & C_UNCHANGED) && isManaged && !isNew
271274
&& !isChnged && !isRenamed ){
272275
zClass = "UNCHANGED";
273276
}else if( (flags & C_EXTRA) && !isManaged ){
274277
zClass = "EXTRA";
@@ -295,11 +298,15 @@
295298
file_relative_name(zFullName, &rewrittenPathname, 0);
296299
zDisplayName = blob_str(&rewrittenPathname);
297300
if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){
298301
zDisplayName += 2; /* no unnecessary ./ prefix */
299302
}
300
- blob_append(report, zDisplayName, -1);
303
+ if( (flags & (C_FILTER ^ C_RENAMED)) && zOrigName ){
304
+ blob_appendf(report, "%s -> %s", zOrigName, zDisplayName);
305
+ }else{
306
+ blob_append(report, zDisplayName, -1);
307
+ }
301308
}else{
302309
/* If not C_RELPATH, display paths relative to project root. */
303310
blob_append(report, zPathname, -1);
304311
}
305312
blob_append(report, "\n", 1);
306313
--- src/checkin.c
+++ src/checkin.c
@@ -153,11 +153,12 @@
153 blob_zero(&sql);
154 if( flags & C_ALL ){
155 /* Start with a list of all managed files. */
156 blob_append_sql(&sql,
157 "SELECT pathname, %s as mtime, %s as size, deleted, chnged, rid,"
158 " coalesce(origname!=pathname,0) AS renamed, 1 AS managed"
 
159 " FROM vfile LEFT JOIN blob USING (rid)"
160 " WHERE is_selected(id)%s",
161 flags & C_MTIME ? "datetime(checkin_mtime(:vid, rid), "
162 "'unixepoch', toLocal())" : "''" /*safe-for-%s*/,
163 flags & C_SIZE ? "coalesce(blob.size, 0)" : "0" /*safe-for-%s*/,
@@ -174,11 +175,11 @@
174 if( flags & C_EXTRA ){
175 if( blob_size(&sql) ){
176 blob_append_sql(&sql, " UNION ALL");
177 }
178 blob_append_sql(&sql,
179 " SELECT pathname, %s, %s, 0, 0, 0, 0, 0"
180 " FROM sfile WHERE pathname NOT IN (%s)%s",
181 flags & C_MTIME ? "datetime(mtime, 'unixepoch', toLocal())" : "''",
182 flags & C_SIZE ? "size" : "0",
183 fossil_all_reserved_names(0), blob_sql_text(&where));
184 }
@@ -211,10 +212,11 @@
211 int size = db_column_int(&q, 2);
212 int isDeleted = db_column_int(&q, 3);
213 int isChnged = db_column_int(&q, 4);
214 int isNew = isManaged && !db_column_int(&q, 5);
215 int isRenamed = db_column_int(&q, 6);
 
216 char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
217 int isMissing = !file_isfile_or_link(zFullName);
218
219 /* Determine the file change classification, if any. */
220 if( isDeleted ){
@@ -265,10 +267,11 @@
265 }else if( (flags & (C_EDITED | C_CHANGED)) && isChnged
266 && (isChnged<2 || isChnged>9) ){
267 zClass = "EDITED";
268 }else if( (flags & C_RENAMED) && isRenamed ){
269 zClass = "RENAMED";
 
270 }else if( (flags & C_UNCHANGED) && isManaged && !isNew
271 && !isChnged && !isRenamed ){
272 zClass = "UNCHANGED";
273 }else if( (flags & C_EXTRA) && !isManaged ){
274 zClass = "EXTRA";
@@ -295,11 +298,15 @@
295 file_relative_name(zFullName, &rewrittenPathname, 0);
296 zDisplayName = blob_str(&rewrittenPathname);
297 if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){
298 zDisplayName += 2; /* no unnecessary ./ prefix */
299 }
300 blob_append(report, zDisplayName, -1);
 
 
 
 
301 }else{
302 /* If not C_RELPATH, display paths relative to project root. */
303 blob_append(report, zPathname, -1);
304 }
305 blob_append(report, "\n", 1);
306
--- src/checkin.c
+++ src/checkin.c
@@ -153,11 +153,12 @@
153 blob_zero(&sql);
154 if( flags & C_ALL ){
155 /* Start with a list of all managed files. */
156 blob_append_sql(&sql,
157 "SELECT pathname, %s as mtime, %s as size, deleted, chnged, rid,"
158 " coalesce(origname!=pathname,0) AS renamed, 1 AS managed,"
159 " origname"
160 " FROM vfile LEFT JOIN blob USING (rid)"
161 " WHERE is_selected(id)%s",
162 flags & C_MTIME ? "datetime(checkin_mtime(:vid, rid), "
163 "'unixepoch', toLocal())" : "''" /*safe-for-%s*/,
164 flags & C_SIZE ? "coalesce(blob.size, 0)" : "0" /*safe-for-%s*/,
@@ -174,11 +175,11 @@
175 if( flags & C_EXTRA ){
176 if( blob_size(&sql) ){
177 blob_append_sql(&sql, " UNION ALL");
178 }
179 blob_append_sql(&sql,
180 " SELECT pathname, %s, %s, 0, 0, 0, 0, 0, NULL"
181 " FROM sfile WHERE pathname NOT IN (%s)%s",
182 flags & C_MTIME ? "datetime(mtime, 'unixepoch', toLocal())" : "''",
183 flags & C_SIZE ? "size" : "0",
184 fossil_all_reserved_names(0), blob_sql_text(&where));
185 }
@@ -211,10 +212,11 @@
212 int size = db_column_int(&q, 2);
213 int isDeleted = db_column_int(&q, 3);
214 int isChnged = db_column_int(&q, 4);
215 int isNew = isManaged && !db_column_int(&q, 5);
216 int isRenamed = db_column_int(&q, 6);
217 const char *zOrigName = 0;
218 char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
219 int isMissing = !file_isfile_or_link(zFullName);
220
221 /* Determine the file change classification, if any. */
222 if( isDeleted ){
@@ -265,10 +267,11 @@
267 }else if( (flags & (C_EDITED | C_CHANGED)) && isChnged
268 && (isChnged<2 || isChnged>9) ){
269 zClass = "EDITED";
270 }else if( (flags & C_RENAMED) && isRenamed ){
271 zClass = "RENAMED";
272 zOrigName = db_column_text(&q,8);
273 }else if( (flags & C_UNCHANGED) && isManaged && !isNew
274 && !isChnged && !isRenamed ){
275 zClass = "UNCHANGED";
276 }else if( (flags & C_EXTRA) && !isManaged ){
277 zClass = "EXTRA";
@@ -295,11 +298,15 @@
298 file_relative_name(zFullName, &rewrittenPathname, 0);
299 zDisplayName = blob_str(&rewrittenPathname);
300 if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){
301 zDisplayName += 2; /* no unnecessary ./ prefix */
302 }
303 if( (flags & (C_FILTER ^ C_RENAMED)) && zOrigName ){
304 blob_appendf(report, "%s -> %s", zOrigName, zDisplayName);
305 }else{
306 blob_append(report, zDisplayName, -1);
307 }
308 }else{
309 /* If not C_RELPATH, display paths relative to project root. */
310 blob_append(report, zPathname, -1);
311 }
312 blob_append(report, "\n", 1);
313

Keyboard Shortcuts

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