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
Commit
1b8cfdb01a876adcd74f9f432d84ff011de5f638a3334eb4ba53d302ce283f98
Parent
c026fb9ad9af539…
1 file changed
+10
-3
+10
-3
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -153,11 +153,12 @@ | ||
| 153 | 153 | blob_zero(&sql); |
| 154 | 154 | if( flags & C_ALL ){ |
| 155 | 155 | /* Start with a list of all managed files. */ |
| 156 | 156 | blob_append_sql(&sql, |
| 157 | 157 | "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" | |
| 159 | 160 | " FROM vfile LEFT JOIN blob USING (rid)" |
| 160 | 161 | " WHERE is_selected(id)%s", |
| 161 | 162 | flags & C_MTIME ? "datetime(checkin_mtime(:vid, rid), " |
| 162 | 163 | "'unixepoch', toLocal())" : "''" /*safe-for-%s*/, |
| 163 | 164 | flags & C_SIZE ? "coalesce(blob.size, 0)" : "0" /*safe-for-%s*/, |
| @@ -174,11 +175,11 @@ | ||
| 174 | 175 | if( flags & C_EXTRA ){ |
| 175 | 176 | if( blob_size(&sql) ){ |
| 176 | 177 | blob_append_sql(&sql, " UNION ALL"); |
| 177 | 178 | } |
| 178 | 179 | 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" | |
| 180 | 181 | " FROM sfile WHERE pathname NOT IN (%s)%s", |
| 181 | 182 | flags & C_MTIME ? "datetime(mtime, 'unixepoch', toLocal())" : "''", |
| 182 | 183 | flags & C_SIZE ? "size" : "0", |
| 183 | 184 | fossil_all_reserved_names(0), blob_sql_text(&where)); |
| 184 | 185 | } |
| @@ -211,10 +212,11 @@ | ||
| 211 | 212 | int size = db_column_int(&q, 2); |
| 212 | 213 | int isDeleted = db_column_int(&q, 3); |
| 213 | 214 | int isChnged = db_column_int(&q, 4); |
| 214 | 215 | int isNew = isManaged && !db_column_int(&q, 5); |
| 215 | 216 | int isRenamed = db_column_int(&q, 6); |
| 217 | + const char *zOrigName = 0; | |
| 216 | 218 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 217 | 219 | int isMissing = !file_isfile_or_link(zFullName); |
| 218 | 220 | |
| 219 | 221 | /* Determine the file change classification, if any. */ |
| 220 | 222 | if( isDeleted ){ |
| @@ -265,10 +267,11 @@ | ||
| 265 | 267 | }else if( (flags & (C_EDITED | C_CHANGED)) && isChnged |
| 266 | 268 | && (isChnged<2 || isChnged>9) ){ |
| 267 | 269 | zClass = "EDITED"; |
| 268 | 270 | }else if( (flags & C_RENAMED) && isRenamed ){ |
| 269 | 271 | zClass = "RENAMED"; |
| 272 | + zOrigName = db_column_text(&q,8); | |
| 270 | 273 | }else if( (flags & C_UNCHANGED) && isManaged && !isNew |
| 271 | 274 | && !isChnged && !isRenamed ){ |
| 272 | 275 | zClass = "UNCHANGED"; |
| 273 | 276 | }else if( (flags & C_EXTRA) && !isManaged ){ |
| 274 | 277 | zClass = "EXTRA"; |
| @@ -295,11 +298,15 @@ | ||
| 295 | 298 | file_relative_name(zFullName, &rewrittenPathname, 0); |
| 296 | 299 | zDisplayName = blob_str(&rewrittenPathname); |
| 297 | 300 | if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){ |
| 298 | 301 | zDisplayName += 2; /* no unnecessary ./ prefix */ |
| 299 | 302 | } |
| 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 | + } | |
| 301 | 308 | }else{ |
| 302 | 309 | /* If not C_RELPATH, display paths relative to project root. */ |
| 303 | 310 | blob_append(report, zPathname, -1); |
| 304 | 311 | } |
| 305 | 312 | blob_append(report, "\n", 1); |
| 306 | 313 |
| --- 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 |