| | @@ -205,46 +205,74 @@ |
| 205 | 205 | show_common_info(vid, "checkout:", 1, 1); |
| 206 | 206 | } |
| 207 | 207 | db_record_repository_filename(0); |
| 208 | 208 | changes_cmd(); |
| 209 | 209 | } |
| 210 | + |
| 211 | +/* |
| 212 | +** Implementation of the checkin_mtime SQL function |
| 213 | +*/ |
| 214 | + |
| 210 | 215 | |
| 211 | 216 | /* |
| 212 | 217 | ** COMMAND: ls |
| 213 | 218 | ** |
| 214 | | -** Usage: %fossil ls ?OPTIONS? |
| 219 | +** Usage: %fossil ls ?OPTIONS? ?VERSION? |
| 215 | 220 | ** |
| 216 | 221 | ** Show the names of all files in the current checkout. The -l provides |
| 217 | 222 | ** extra information about each file. |
| 218 | 223 | ** |
| 219 | 224 | ** Options: |
| 220 | | -** -l Provide extra information about each file. |
| 225 | +** -l Provide extra information about each file. |
| 226 | +** --age Show when each file was committed |
| 221 | 227 | ** |
| 222 | 228 | ** See also: changes, extra, status |
| 223 | 229 | */ |
| 224 | 230 | void ls_cmd(void){ |
| 225 | 231 | int vid; |
| 226 | 232 | Stmt q; |
| 227 | 233 | int isBrief; |
| 234 | + int showAge; |
| 235 | + char *zOrderBy = "pathname"; |
| 228 | 236 | |
| 229 | 237 | isBrief = find_option("l","l", 0)==0; |
| 238 | + showAge = find_option("age",0,0)!=0; |
| 230 | 239 | db_must_be_within_tree(); |
| 231 | 240 | vid = db_lget_int("checkout", 0); |
| 241 | + if( find_option("t","t",0)!=0 ){ |
| 242 | + if( showAge ){ |
| 243 | + zOrderBy = mprintf("checkin_mtime(%d,rid) DESC", vid); |
| 244 | + }else{ |
| 245 | + zOrderBy = "mtime DESC"; |
| 246 | + } |
| 247 | + } |
| 248 | + verify_all_options(); |
| 232 | 249 | vfile_check_signature(vid, 0, 0); |
| 233 | | - db_prepare(&q, |
| 234 | | - "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 235 | | - " FROM vfile" |
| 236 | | - " ORDER BY 1" |
| 237 | | - ); |
| 250 | + if( showAge ){ |
| 251 | + db_prepare(&q, |
| 252 | + "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)," |
| 253 | + " datetime(checkin_mtime(%d,rid),'unixepoch','localtime')" |
| 254 | + " FROM vfile" |
| 255 | + " ORDER BY %s", vid, zOrderBy |
| 256 | + ); |
| 257 | + }else{ |
| 258 | + db_prepare(&q, |
| 259 | + "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 260 | + " FROM vfile" |
| 261 | + " ORDER BY %s", zOrderBy |
| 262 | + ); |
| 263 | + } |
| 238 | 264 | while( db_step(&q)==SQLITE_ROW ){ |
| 239 | 265 | const char *zPathname = db_column_text(&q,0); |
| 240 | 266 | int isDeleted = db_column_int(&q, 1); |
| 241 | 267 | int isNew = db_column_int(&q,2)==0; |
| 242 | 268 | int chnged = db_column_int(&q,3); |
| 243 | 269 | int renamed = db_column_int(&q,4); |
| 244 | 270 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 245 | | - if( isBrief ){ |
| 271 | + if( showAge ){ |
| 272 | + fossil_print("%s %s\n", db_column_text(&q, 5), zPathname); |
| 273 | + }else if( isBrief ){ |
| 246 | 274 | fossil_print("%s\n", zPathname); |
| 247 | 275 | }else if( isNew ){ |
| 248 | 276 | fossil_print("ADDED %s\n", zPathname); |
| 249 | 277 | }else if( isDeleted ){ |
| 250 | 278 | fossil_print("DELETED %s\n", zPathname); |
| 251 | 279 | |