Fossil SCM
Add the --setmtime option to the "checkout" and "open" commands. Add a new "touch" command that does nothing but run --setmtime on all named files.
Commit
a7e86f5b186b4812f5b76d973a02bf95d7d4b111e0695860b88696b7a50534f3
Parent
34fcaf829a908db…
6 files changed
+7
+7
+11
+11
+104
+104
+7
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -275,10 +275,13 @@ | ||
| 275 | 275 | ** |
| 276 | 276 | ** Options: |
| 277 | 277 | ** --force Ignore edited files in the current checkout |
| 278 | 278 | ** --keep Only update the manifest and manifest.uuid files |
| 279 | 279 | ** --force-missing Force checkout even if content is missing |
| 280 | +** --setmtime Set timestamps of all files to match their SCM-side | |
| 281 | +** times (the timestamp of the last checkin which modified | |
| 282 | +** them). | |
| 280 | 283 | ** |
| 281 | 284 | ** See also: update |
| 282 | 285 | */ |
| 283 | 286 | void checkout_cmd(void){ |
| 284 | 287 | int forceFlag; /* Force checkout even if edits exist */ |
| @@ -286,19 +289,21 @@ | ||
| 286 | 289 | int keepFlag; /* Do not change any files on disk */ |
| 287 | 290 | int latestFlag; /* Checkout the latest version */ |
| 288 | 291 | char *zVers; /* Version to checkout */ |
| 289 | 292 | int promptFlag; /* True to prompt before overwriting */ |
| 290 | 293 | int vid, prior; |
| 294 | + int setmtimeFlag; /* --setmtime. Set mtimes on files */ | |
| 291 | 295 | Blob cksum1, cksum1b, cksum2; |
| 292 | 296 | |
| 293 | 297 | db_must_be_within_tree(); |
| 294 | 298 | db_begin_transaction(); |
| 295 | 299 | forceFlag = find_option("force","f",0)!=0; |
| 296 | 300 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 297 | 301 | keepFlag = find_option("keep",0,0)!=0; |
| 298 | 302 | latestFlag = find_option("latest",0,0)!=0; |
| 299 | 303 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 304 | + setmtimeFlag = find_option("setmtime",0,0)!=0; | |
| 300 | 305 | |
| 301 | 306 | /* We should be done with options.. */ |
| 302 | 307 | verify_all_options(); |
| 303 | 308 | |
| 304 | 309 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| @@ -329,10 +334,11 @@ | ||
| 329 | 334 | }else{ |
| 330 | 335 | zVers = g.argv[2]; |
| 331 | 336 | } |
| 332 | 337 | vid = load_vfile(zVers, forceMissingFlag); |
| 333 | 338 | if( prior==vid ){ |
| 339 | + if( setmtimeFlag ) vfile_check_signature(vid, CKSIG_SETMTIME); | |
| 334 | 340 | db_end_transaction(0); |
| 335 | 341 | return; |
| 336 | 342 | } |
| 337 | 343 | if( !keepFlag ){ |
| 338 | 344 | uncheckout(prior); |
| @@ -355,10 +361,11 @@ | ||
| 355 | 361 | } |
| 356 | 362 | if( blob_size(&cksum1b) && blob_compare(&cksum1, &cksum1b) ){ |
| 357 | 363 | fossil_print("WARNING: manifest checksum does not agree with manifest\n"); |
| 358 | 364 | } |
| 359 | 365 | } |
| 366 | + if( setmtimeFlag ) vfile_check_signature(vid, CKSIG_SETMTIME); | |
| 360 | 367 | db_end_transaction(0); |
| 361 | 368 | } |
| 362 | 369 | |
| 363 | 370 | /* |
| 364 | 371 | ** Unlink the local database file |
| 365 | 372 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -275,10 +275,13 @@ | |
| 275 | ** |
| 276 | ** Options: |
| 277 | ** --force Ignore edited files in the current checkout |
| 278 | ** --keep Only update the manifest and manifest.uuid files |
| 279 | ** --force-missing Force checkout even if content is missing |
| 280 | ** |
| 281 | ** See also: update |
| 282 | */ |
| 283 | void checkout_cmd(void){ |
| 284 | int forceFlag; /* Force checkout even if edits exist */ |
| @@ -286,19 +289,21 @@ | |
| 286 | int keepFlag; /* Do not change any files on disk */ |
| 287 | int latestFlag; /* Checkout the latest version */ |
| 288 | char *zVers; /* Version to checkout */ |
| 289 | int promptFlag; /* True to prompt before overwriting */ |
| 290 | int vid, prior; |
| 291 | Blob cksum1, cksum1b, cksum2; |
| 292 | |
| 293 | db_must_be_within_tree(); |
| 294 | db_begin_transaction(); |
| 295 | forceFlag = find_option("force","f",0)!=0; |
| 296 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 297 | keepFlag = find_option("keep",0,0)!=0; |
| 298 | latestFlag = find_option("latest",0,0)!=0; |
| 299 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 300 | |
| 301 | /* We should be done with options.. */ |
| 302 | verify_all_options(); |
| 303 | |
| 304 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| @@ -329,10 +334,11 @@ | |
| 329 | }else{ |
| 330 | zVers = g.argv[2]; |
| 331 | } |
| 332 | vid = load_vfile(zVers, forceMissingFlag); |
| 333 | if( prior==vid ){ |
| 334 | db_end_transaction(0); |
| 335 | return; |
| 336 | } |
| 337 | if( !keepFlag ){ |
| 338 | uncheckout(prior); |
| @@ -355,10 +361,11 @@ | |
| 355 | } |
| 356 | if( blob_size(&cksum1b) && blob_compare(&cksum1, &cksum1b) ){ |
| 357 | fossil_print("WARNING: manifest checksum does not agree with manifest\n"); |
| 358 | } |
| 359 | } |
| 360 | db_end_transaction(0); |
| 361 | } |
| 362 | |
| 363 | /* |
| 364 | ** Unlink the local database file |
| 365 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -275,10 +275,13 @@ | |
| 275 | ** |
| 276 | ** Options: |
| 277 | ** --force Ignore edited files in the current checkout |
| 278 | ** --keep Only update the manifest and manifest.uuid files |
| 279 | ** --force-missing Force checkout even if content is missing |
| 280 | ** --setmtime Set timestamps of all files to match their SCM-side |
| 281 | ** times (the timestamp of the last checkin which modified |
| 282 | ** them). |
| 283 | ** |
| 284 | ** See also: update |
| 285 | */ |
| 286 | void checkout_cmd(void){ |
| 287 | int forceFlag; /* Force checkout even if edits exist */ |
| @@ -286,19 +289,21 @@ | |
| 289 | int keepFlag; /* Do not change any files on disk */ |
| 290 | int latestFlag; /* Checkout the latest version */ |
| 291 | char *zVers; /* Version to checkout */ |
| 292 | int promptFlag; /* True to prompt before overwriting */ |
| 293 | int vid, prior; |
| 294 | int setmtimeFlag; /* --setmtime. Set mtimes on files */ |
| 295 | Blob cksum1, cksum1b, cksum2; |
| 296 | |
| 297 | db_must_be_within_tree(); |
| 298 | db_begin_transaction(); |
| 299 | forceFlag = find_option("force","f",0)!=0; |
| 300 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 301 | keepFlag = find_option("keep",0,0)!=0; |
| 302 | latestFlag = find_option("latest",0,0)!=0; |
| 303 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 304 | setmtimeFlag = find_option("setmtime",0,0)!=0; |
| 305 | |
| 306 | /* We should be done with options.. */ |
| 307 | verify_all_options(); |
| 308 | |
| 309 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| @@ -329,10 +334,11 @@ | |
| 334 | }else{ |
| 335 | zVers = g.argv[2]; |
| 336 | } |
| 337 | vid = load_vfile(zVers, forceMissingFlag); |
| 338 | if( prior==vid ){ |
| 339 | if( setmtimeFlag ) vfile_check_signature(vid, CKSIG_SETMTIME); |
| 340 | db_end_transaction(0); |
| 341 | return; |
| 342 | } |
| 343 | if( !keepFlag ){ |
| 344 | uncheckout(prior); |
| @@ -355,10 +361,11 @@ | |
| 361 | } |
| 362 | if( blob_size(&cksum1b) && blob_compare(&cksum1, &cksum1b) ){ |
| 363 | fossil_print("WARNING: manifest checksum does not agree with manifest\n"); |
| 364 | } |
| 365 | } |
| 366 | if( setmtimeFlag ) vfile_check_signature(vid, CKSIG_SETMTIME); |
| 367 | db_end_transaction(0); |
| 368 | } |
| 369 | |
| 370 | /* |
| 371 | ** Unlink the local database file |
| 372 |
+7
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -275,10 +275,13 @@ | ||
| 275 | 275 | ** |
| 276 | 276 | ** Options: |
| 277 | 277 | ** --force Ignore edited files in the current checkout |
| 278 | 278 | ** --keep Only update the manifest and manifest.uuid files |
| 279 | 279 | ** --force-missing Force checkout even if content is missing |
| 280 | +** --setmtime Set timestamps of all files to match their SCM-side | |
| 281 | +** times (the timestamp of the last checkin which modified | |
| 282 | +** them). | |
| 280 | 283 | ** |
| 281 | 284 | ** See also: update |
| 282 | 285 | */ |
| 283 | 286 | void checkout_cmd(void){ |
| 284 | 287 | int forceFlag; /* Force checkout even if edits exist */ |
| @@ -286,19 +289,21 @@ | ||
| 286 | 289 | int keepFlag; /* Do not change any files on disk */ |
| 287 | 290 | int latestFlag; /* Checkout the latest version */ |
| 288 | 291 | char *zVers; /* Version to checkout */ |
| 289 | 292 | int promptFlag; /* True to prompt before overwriting */ |
| 290 | 293 | int vid, prior; |
| 294 | + int setmtimeFlag; /* --setmtime. Set mtimes on files */ | |
| 291 | 295 | Blob cksum1, cksum1b, cksum2; |
| 292 | 296 | |
| 293 | 297 | db_must_be_within_tree(); |
| 294 | 298 | db_begin_transaction(); |
| 295 | 299 | forceFlag = find_option("force","f",0)!=0; |
| 296 | 300 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 297 | 301 | keepFlag = find_option("keep",0,0)!=0; |
| 298 | 302 | latestFlag = find_option("latest",0,0)!=0; |
| 299 | 303 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 304 | + setmtimeFlag = find_option("setmtime",0,0)!=0; | |
| 300 | 305 | |
| 301 | 306 | /* We should be done with options.. */ |
| 302 | 307 | verify_all_options(); |
| 303 | 308 | |
| 304 | 309 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| @@ -329,10 +334,11 @@ | ||
| 329 | 334 | }else{ |
| 330 | 335 | zVers = g.argv[2]; |
| 331 | 336 | } |
| 332 | 337 | vid = load_vfile(zVers, forceMissingFlag); |
| 333 | 338 | if( prior==vid ){ |
| 339 | + if( setmtimeFlag ) vfile_check_signature(vid, CKSIG_SETMTIME); | |
| 334 | 340 | db_end_transaction(0); |
| 335 | 341 | return; |
| 336 | 342 | } |
| 337 | 343 | if( !keepFlag ){ |
| 338 | 344 | uncheckout(prior); |
| @@ -355,10 +361,11 @@ | ||
| 355 | 361 | } |
| 356 | 362 | if( blob_size(&cksum1b) && blob_compare(&cksum1, &cksum1b) ){ |
| 357 | 363 | fossil_print("WARNING: manifest checksum does not agree with manifest\n"); |
| 358 | 364 | } |
| 359 | 365 | } |
| 366 | + if( setmtimeFlag ) vfile_check_signature(vid, CKSIG_SETMTIME); | |
| 360 | 367 | db_end_transaction(0); |
| 361 | 368 | } |
| 362 | 369 | |
| 363 | 370 | /* |
| 364 | 371 | ** Unlink the local database file |
| 365 | 372 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -275,10 +275,13 @@ | |
| 275 | ** |
| 276 | ** Options: |
| 277 | ** --force Ignore edited files in the current checkout |
| 278 | ** --keep Only update the manifest and manifest.uuid files |
| 279 | ** --force-missing Force checkout even if content is missing |
| 280 | ** |
| 281 | ** See also: update |
| 282 | */ |
| 283 | void checkout_cmd(void){ |
| 284 | int forceFlag; /* Force checkout even if edits exist */ |
| @@ -286,19 +289,21 @@ | |
| 286 | int keepFlag; /* Do not change any files on disk */ |
| 287 | int latestFlag; /* Checkout the latest version */ |
| 288 | char *zVers; /* Version to checkout */ |
| 289 | int promptFlag; /* True to prompt before overwriting */ |
| 290 | int vid, prior; |
| 291 | Blob cksum1, cksum1b, cksum2; |
| 292 | |
| 293 | db_must_be_within_tree(); |
| 294 | db_begin_transaction(); |
| 295 | forceFlag = find_option("force","f",0)!=0; |
| 296 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 297 | keepFlag = find_option("keep",0,0)!=0; |
| 298 | latestFlag = find_option("latest",0,0)!=0; |
| 299 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 300 | |
| 301 | /* We should be done with options.. */ |
| 302 | verify_all_options(); |
| 303 | |
| 304 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| @@ -329,10 +334,11 @@ | |
| 329 | }else{ |
| 330 | zVers = g.argv[2]; |
| 331 | } |
| 332 | vid = load_vfile(zVers, forceMissingFlag); |
| 333 | if( prior==vid ){ |
| 334 | db_end_transaction(0); |
| 335 | return; |
| 336 | } |
| 337 | if( !keepFlag ){ |
| 338 | uncheckout(prior); |
| @@ -355,10 +361,11 @@ | |
| 355 | } |
| 356 | if( blob_size(&cksum1b) && blob_compare(&cksum1, &cksum1b) ){ |
| 357 | fossil_print("WARNING: manifest checksum does not agree with manifest\n"); |
| 358 | } |
| 359 | } |
| 360 | db_end_transaction(0); |
| 361 | } |
| 362 | |
| 363 | /* |
| 364 | ** Unlink the local database file |
| 365 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -275,10 +275,13 @@ | |
| 275 | ** |
| 276 | ** Options: |
| 277 | ** --force Ignore edited files in the current checkout |
| 278 | ** --keep Only update the manifest and manifest.uuid files |
| 279 | ** --force-missing Force checkout even if content is missing |
| 280 | ** --setmtime Set timestamps of all files to match their SCM-side |
| 281 | ** times (the timestamp of the last checkin which modified |
| 282 | ** them). |
| 283 | ** |
| 284 | ** See also: update |
| 285 | */ |
| 286 | void checkout_cmd(void){ |
| 287 | int forceFlag; /* Force checkout even if edits exist */ |
| @@ -286,19 +289,21 @@ | |
| 289 | int keepFlag; /* Do not change any files on disk */ |
| 290 | int latestFlag; /* Checkout the latest version */ |
| 291 | char *zVers; /* Version to checkout */ |
| 292 | int promptFlag; /* True to prompt before overwriting */ |
| 293 | int vid, prior; |
| 294 | int setmtimeFlag; /* --setmtime. Set mtimes on files */ |
| 295 | Blob cksum1, cksum1b, cksum2; |
| 296 | |
| 297 | db_must_be_within_tree(); |
| 298 | db_begin_transaction(); |
| 299 | forceFlag = find_option("force","f",0)!=0; |
| 300 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 301 | keepFlag = find_option("keep",0,0)!=0; |
| 302 | latestFlag = find_option("latest",0,0)!=0; |
| 303 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 304 | setmtimeFlag = find_option("setmtime",0,0)!=0; |
| 305 | |
| 306 | /* We should be done with options.. */ |
| 307 | verify_all_options(); |
| 308 | |
| 309 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| @@ -329,10 +334,11 @@ | |
| 334 | }else{ |
| 335 | zVers = g.argv[2]; |
| 336 | } |
| 337 | vid = load_vfile(zVers, forceMissingFlag); |
| 338 | if( prior==vid ){ |
| 339 | if( setmtimeFlag ) vfile_check_signature(vid, CKSIG_SETMTIME); |
| 340 | db_end_transaction(0); |
| 341 | return; |
| 342 | } |
| 343 | if( !keepFlag ){ |
| 344 | uncheckout(prior); |
| @@ -355,10 +361,11 @@ | |
| 361 | } |
| 362 | if( blob_size(&cksum1b) && blob_compare(&cksum1, &cksum1b) ){ |
| 363 | fossil_print("WARNING: manifest checksum does not agree with manifest\n"); |
| 364 | } |
| 365 | } |
| 366 | if( setmtimeFlag ) vfile_check_signature(vid, CKSIG_SETMTIME); |
| 367 | db_end_transaction(0); |
| 368 | } |
| 369 | |
| 370 | /* |
| 371 | ** Unlink the local database file |
| 372 |
M
src/db.c
+11
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -2880,26 +2880,31 @@ | ||
| 2880 | 2880 | ** with the local repository. If you commit this checkout, |
| 2881 | 2881 | ** it will become a new "initial" commit in the repository. |
| 2882 | 2882 | ** --keep Only modify the manifest and manifest.uuid files |
| 2883 | 2883 | ** --nested Allow opening a repository inside an opened checkout |
| 2884 | 2884 | ** --force-missing Force opening a repository with missing content |
| 2885 | +** --setmtime Set timestamps of all files to match their SCM-side | |
| 2886 | +** times (the timestamp of the last checkin which modified | |
| 2887 | +** them). | |
| 2885 | 2888 | ** |
| 2886 | 2889 | ** See also: close |
| 2887 | 2890 | */ |
| 2888 | 2891 | void cmd_open(void){ |
| 2889 | 2892 | int emptyFlag; |
| 2890 | 2893 | int keepFlag; |
| 2891 | 2894 | int forceMissingFlag; |
| 2892 | 2895 | int allowNested; |
| 2893 | 2896 | int allowSymlinks; |
| 2897 | + int setmtimeFlag; /* --setmtime. Set mtimes on files */ | |
| 2894 | 2898 | static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 }; |
| 2895 | 2899 | |
| 2896 | 2900 | url_proxy_options(); |
| 2897 | 2901 | emptyFlag = find_option("empty",0,0)!=0; |
| 2898 | 2902 | keepFlag = find_option("keep",0,0)!=0; |
| 2899 | 2903 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 2900 | 2904 | allowNested = find_option("nested",0,0)!=0; |
| 2905 | + setmtimeFlag = find_option("setmtime",0,0)!=0; | |
| 2901 | 2906 | |
| 2902 | 2907 | /* We should be done with options.. */ |
| 2903 | 2908 | verify_all_options(); |
| 2904 | 2909 | |
| 2905 | 2910 | if( g.argc!=3 && g.argc!=4 ){ |
| @@ -2978,10 +2983,16 @@ | ||
| 2978 | 2983 | } |
| 2979 | 2984 | if( forceMissingFlag ){ |
| 2980 | 2985 | azNewArgv[g.argc++] = "--force-missing"; |
| 2981 | 2986 | } |
| 2982 | 2987 | checkout_cmd(); |
| 2988 | + } | |
| 2989 | + if( setmtimeFlag ){ | |
| 2990 | + int const vid = db_lget_int("checkout", 0); | |
| 2991 | + if(vid!=0){ | |
| 2992 | + vfile_check_signature(vid, CKSIG_SETMTIME); | |
| 2993 | + } | |
| 2983 | 2994 | } |
| 2984 | 2995 | g.argc = 2; |
| 2985 | 2996 | info_cmd(); |
| 2986 | 2997 | } |
| 2987 | 2998 | |
| 2988 | 2999 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2880,26 +2880,31 @@ | |
| 2880 | ** with the local repository. If you commit this checkout, |
| 2881 | ** it will become a new "initial" commit in the repository. |
| 2882 | ** --keep Only modify the manifest and manifest.uuid files |
| 2883 | ** --nested Allow opening a repository inside an opened checkout |
| 2884 | ** --force-missing Force opening a repository with missing content |
| 2885 | ** |
| 2886 | ** See also: close |
| 2887 | */ |
| 2888 | void cmd_open(void){ |
| 2889 | int emptyFlag; |
| 2890 | int keepFlag; |
| 2891 | int forceMissingFlag; |
| 2892 | int allowNested; |
| 2893 | int allowSymlinks; |
| 2894 | static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 }; |
| 2895 | |
| 2896 | url_proxy_options(); |
| 2897 | emptyFlag = find_option("empty",0,0)!=0; |
| 2898 | keepFlag = find_option("keep",0,0)!=0; |
| 2899 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 2900 | allowNested = find_option("nested",0,0)!=0; |
| 2901 | |
| 2902 | /* We should be done with options.. */ |
| 2903 | verify_all_options(); |
| 2904 | |
| 2905 | if( g.argc!=3 && g.argc!=4 ){ |
| @@ -2978,10 +2983,16 @@ | |
| 2978 | } |
| 2979 | if( forceMissingFlag ){ |
| 2980 | azNewArgv[g.argc++] = "--force-missing"; |
| 2981 | } |
| 2982 | checkout_cmd(); |
| 2983 | } |
| 2984 | g.argc = 2; |
| 2985 | info_cmd(); |
| 2986 | } |
| 2987 | |
| 2988 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2880,26 +2880,31 @@ | |
| 2880 | ** with the local repository. If you commit this checkout, |
| 2881 | ** it will become a new "initial" commit in the repository. |
| 2882 | ** --keep Only modify the manifest and manifest.uuid files |
| 2883 | ** --nested Allow opening a repository inside an opened checkout |
| 2884 | ** --force-missing Force opening a repository with missing content |
| 2885 | ** --setmtime Set timestamps of all files to match their SCM-side |
| 2886 | ** times (the timestamp of the last checkin which modified |
| 2887 | ** them). |
| 2888 | ** |
| 2889 | ** See also: close |
| 2890 | */ |
| 2891 | void cmd_open(void){ |
| 2892 | int emptyFlag; |
| 2893 | int keepFlag; |
| 2894 | int forceMissingFlag; |
| 2895 | int allowNested; |
| 2896 | int allowSymlinks; |
| 2897 | int setmtimeFlag; /* --setmtime. Set mtimes on files */ |
| 2898 | static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 }; |
| 2899 | |
| 2900 | url_proxy_options(); |
| 2901 | emptyFlag = find_option("empty",0,0)!=0; |
| 2902 | keepFlag = find_option("keep",0,0)!=0; |
| 2903 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 2904 | allowNested = find_option("nested",0,0)!=0; |
| 2905 | setmtimeFlag = find_option("setmtime",0,0)!=0; |
| 2906 | |
| 2907 | /* We should be done with options.. */ |
| 2908 | verify_all_options(); |
| 2909 | |
| 2910 | if( g.argc!=3 && g.argc!=4 ){ |
| @@ -2978,10 +2983,16 @@ | |
| 2983 | } |
| 2984 | if( forceMissingFlag ){ |
| 2985 | azNewArgv[g.argc++] = "--force-missing"; |
| 2986 | } |
| 2987 | checkout_cmd(); |
| 2988 | } |
| 2989 | if( setmtimeFlag ){ |
| 2990 | int const vid = db_lget_int("checkout", 0); |
| 2991 | if(vid!=0){ |
| 2992 | vfile_check_signature(vid, CKSIG_SETMTIME); |
| 2993 | } |
| 2994 | } |
| 2995 | g.argc = 2; |
| 2996 | info_cmd(); |
| 2997 | } |
| 2998 | |
| 2999 |
M
src/db.c
+11
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -2880,26 +2880,31 @@ | ||
| 2880 | 2880 | ** with the local repository. If you commit this checkout, |
| 2881 | 2881 | ** it will become a new "initial" commit in the repository. |
| 2882 | 2882 | ** --keep Only modify the manifest and manifest.uuid files |
| 2883 | 2883 | ** --nested Allow opening a repository inside an opened checkout |
| 2884 | 2884 | ** --force-missing Force opening a repository with missing content |
| 2885 | +** --setmtime Set timestamps of all files to match their SCM-side | |
| 2886 | +** times (the timestamp of the last checkin which modified | |
| 2887 | +** them). | |
| 2885 | 2888 | ** |
| 2886 | 2889 | ** See also: close |
| 2887 | 2890 | */ |
| 2888 | 2891 | void cmd_open(void){ |
| 2889 | 2892 | int emptyFlag; |
| 2890 | 2893 | int keepFlag; |
| 2891 | 2894 | int forceMissingFlag; |
| 2892 | 2895 | int allowNested; |
| 2893 | 2896 | int allowSymlinks; |
| 2897 | + int setmtimeFlag; /* --setmtime. Set mtimes on files */ | |
| 2894 | 2898 | static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 }; |
| 2895 | 2899 | |
| 2896 | 2900 | url_proxy_options(); |
| 2897 | 2901 | emptyFlag = find_option("empty",0,0)!=0; |
| 2898 | 2902 | keepFlag = find_option("keep",0,0)!=0; |
| 2899 | 2903 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 2900 | 2904 | allowNested = find_option("nested",0,0)!=0; |
| 2905 | + setmtimeFlag = find_option("setmtime",0,0)!=0; | |
| 2901 | 2906 | |
| 2902 | 2907 | /* We should be done with options.. */ |
| 2903 | 2908 | verify_all_options(); |
| 2904 | 2909 | |
| 2905 | 2910 | if( g.argc!=3 && g.argc!=4 ){ |
| @@ -2978,10 +2983,16 @@ | ||
| 2978 | 2983 | } |
| 2979 | 2984 | if( forceMissingFlag ){ |
| 2980 | 2985 | azNewArgv[g.argc++] = "--force-missing"; |
| 2981 | 2986 | } |
| 2982 | 2987 | checkout_cmd(); |
| 2988 | + } | |
| 2989 | + if( setmtimeFlag ){ | |
| 2990 | + int const vid = db_lget_int("checkout", 0); | |
| 2991 | + if(vid!=0){ | |
| 2992 | + vfile_check_signature(vid, CKSIG_SETMTIME); | |
| 2993 | + } | |
| 2983 | 2994 | } |
| 2984 | 2995 | g.argc = 2; |
| 2985 | 2996 | info_cmd(); |
| 2986 | 2997 | } |
| 2987 | 2998 | |
| 2988 | 2999 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2880,26 +2880,31 @@ | |
| 2880 | ** with the local repository. If you commit this checkout, |
| 2881 | ** it will become a new "initial" commit in the repository. |
| 2882 | ** --keep Only modify the manifest and manifest.uuid files |
| 2883 | ** --nested Allow opening a repository inside an opened checkout |
| 2884 | ** --force-missing Force opening a repository with missing content |
| 2885 | ** |
| 2886 | ** See also: close |
| 2887 | */ |
| 2888 | void cmd_open(void){ |
| 2889 | int emptyFlag; |
| 2890 | int keepFlag; |
| 2891 | int forceMissingFlag; |
| 2892 | int allowNested; |
| 2893 | int allowSymlinks; |
| 2894 | static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 }; |
| 2895 | |
| 2896 | url_proxy_options(); |
| 2897 | emptyFlag = find_option("empty",0,0)!=0; |
| 2898 | keepFlag = find_option("keep",0,0)!=0; |
| 2899 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 2900 | allowNested = find_option("nested",0,0)!=0; |
| 2901 | |
| 2902 | /* We should be done with options.. */ |
| 2903 | verify_all_options(); |
| 2904 | |
| 2905 | if( g.argc!=3 && g.argc!=4 ){ |
| @@ -2978,10 +2983,16 @@ | |
| 2978 | } |
| 2979 | if( forceMissingFlag ){ |
| 2980 | azNewArgv[g.argc++] = "--force-missing"; |
| 2981 | } |
| 2982 | checkout_cmd(); |
| 2983 | } |
| 2984 | g.argc = 2; |
| 2985 | info_cmd(); |
| 2986 | } |
| 2987 | |
| 2988 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2880,26 +2880,31 @@ | |
| 2880 | ** with the local repository. If you commit this checkout, |
| 2881 | ** it will become a new "initial" commit in the repository. |
| 2882 | ** --keep Only modify the manifest and manifest.uuid files |
| 2883 | ** --nested Allow opening a repository inside an opened checkout |
| 2884 | ** --force-missing Force opening a repository with missing content |
| 2885 | ** --setmtime Set timestamps of all files to match their SCM-side |
| 2886 | ** times (the timestamp of the last checkin which modified |
| 2887 | ** them). |
| 2888 | ** |
| 2889 | ** See also: close |
| 2890 | */ |
| 2891 | void cmd_open(void){ |
| 2892 | int emptyFlag; |
| 2893 | int keepFlag; |
| 2894 | int forceMissingFlag; |
| 2895 | int allowNested; |
| 2896 | int allowSymlinks; |
| 2897 | int setmtimeFlag; /* --setmtime. Set mtimes on files */ |
| 2898 | static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 }; |
| 2899 | |
| 2900 | url_proxy_options(); |
| 2901 | emptyFlag = find_option("empty",0,0)!=0; |
| 2902 | keepFlag = find_option("keep",0,0)!=0; |
| 2903 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 2904 | allowNested = find_option("nested",0,0)!=0; |
| 2905 | setmtimeFlag = find_option("setmtime",0,0)!=0; |
| 2906 | |
| 2907 | /* We should be done with options.. */ |
| 2908 | verify_all_options(); |
| 2909 | |
| 2910 | if( g.argc!=3 && g.argc!=4 ){ |
| @@ -2978,10 +2983,16 @@ | |
| 2983 | } |
| 2984 | if( forceMissingFlag ){ |
| 2985 | azNewArgv[g.argc++] = "--force-missing"; |
| 2986 | } |
| 2987 | checkout_cmd(); |
| 2988 | } |
| 2989 | if( setmtimeFlag ){ |
| 2990 | int const vid = db_lget_int("checkout", 0); |
| 2991 | if(vid!=0){ |
| 2992 | vfile_check_signature(vid, CKSIG_SETMTIME); |
| 2993 | } |
| 2994 | } |
| 2995 | g.argc = 2; |
| 2996 | info_cmd(); |
| 2997 | } |
| 2998 | |
| 2999 |
+104
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -1798,5 +1798,109 @@ | ||
| 1798 | 1798 | } |
| 1799 | 1799 | zDir = g.argv[2]; |
| 1800 | 1800 | zGlob = g.argc==4 ? g.argv[3] : 0; |
| 1801 | 1801 | fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles)); |
| 1802 | 1802 | } |
| 1803 | + | |
| 1804 | + | |
| 1805 | +/* | |
| 1806 | +** COMMAND: touch* | |
| 1807 | +** | |
| 1808 | +** Usage: %fossil touch ?OPTIONS? | |
| 1809 | +** | |
| 1810 | +** For each file in the current checkout matching one of the provided | |
| 1811 | +** list of glob patterns, or all files if no globs are provided, sets | |
| 1812 | +** the file's mtime to the time of the last checkin which modified | |
| 1813 | +** that file. | |
| 1814 | +** | |
| 1815 | +** This command gets its name from the conventional Unix "touch" | |
| 1816 | +** command. | |
| 1817 | +** | |
| 1818 | +** Options: | |
| 1819 | +** -g GLOBLIST Comma-separated list of glob patterns. Default | |
| 1820 | +** is to touch all SCM-controlled files. | |
| 1821 | +** -G GLOBFILE Similar to -g but reads its globs from a | |
| 1822 | +** fossil-conventional glob list file. | |
| 1823 | +** -v|-verbose Outputs information about its globs and each | |
| 1824 | +** file it touches. | |
| 1825 | +** -n|--dry-run Outputs which files would require touching, | |
| 1826 | +** but does not touch them. | |
| 1827 | +** | |
| 1828 | +** Only one of -g or -G may be used. | |
| 1829 | +** | |
| 1830 | +*/ | |
| 1831 | +void touch_cmd(){ | |
| 1832 | + const char * zGlobList; /* -g List of glob patterns */ | |
| 1833 | + const char * zGlobFile; /* -G File of glob patterns */ | |
| 1834 | + Glob * pGlob = 0; /* List of glob patterns */ | |
| 1835 | + int verboseFlag; | |
| 1836 | + int dryRunFlag; | |
| 1837 | + int vid; /* Checkout version */ | |
| 1838 | + int changeCount = 0; /* Number of files touched */ | |
| 1839 | + Stmt q; | |
| 1840 | + | |
| 1841 | + verboseFlag = find_option("verbose","v",0)!=0; | |
| 1842 | + dryRunFlag = find_option("dry-run","n",0)!=0; | |
| 1843 | + zGlobList = find_option("glob", "g",1); | |
| 1844 | + zGlobFile = find_option("globfile", "G",1); | |
| 1845 | + | |
| 1846 | + verify_all_options(); | |
| 1847 | + if(zGlobList && zGlobFile){ | |
| 1848 | + fossil_fatal("Cannot use both -g and -G options."); | |
| 1849 | + } | |
| 1850 | + | |
| 1851 | + db_must_be_within_tree(); | |
| 1852 | + vid = db_lget_int("checkout", 0); | |
| 1853 | + if(vid==0){ | |
| 1854 | + fossil_fatal("Cannot determine checkout version."); | |
| 1855 | + } | |
| 1856 | + if(zGlobList){ | |
| 1857 | + pGlob = *zGlobList ? glob_create(zGlobList) : 0; | |
| 1858 | + }else if(zGlobFile){ | |
| 1859 | + Blob globs; | |
| 1860 | + blob_read_from_file(&globs, zGlobFile, ExtFILE); | |
| 1861 | + pGlob = glob_create( globs.aData ); | |
| 1862 | + blob_reset(&globs); | |
| 1863 | + } | |
| 1864 | + db_begin_transaction(); | |
| 1865 | + db_prepare(&q, "SELECT vfile.mrid, pathname " | |
| 1866 | + "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid " | |
| 1867 | + "WHERE vid=%d", vid); | |
| 1868 | + if( pGlob && verboseFlag!=0 ){ | |
| 1869 | + int i; | |
| 1870 | + for(i=0; i<pGlob->nPattern; ++i){ | |
| 1871 | + fossil_print("glob: %s\n", pGlob->azPattern[i]); | |
| 1872 | + } | |
| 1873 | + } | |
| 1874 | + while(SQLITE_ROW==db_step(&q)){ | |
| 1875 | + const char * zName = db_column_text(&q, 1); | |
| 1876 | + int const fid = db_column_int(&q, 0); | |
| 1877 | + i64 scmMtime; | |
| 1878 | + i64 currentMtime; | |
| 1879 | + if(pGlob){ | |
| 1880 | + if(glob_match(pGlob, zName)==0) continue; | |
| 1881 | + } | |
| 1882 | + currentMtime = file_mtime(zName, 0); | |
| 1883 | + if( mtime_of_manifest_file(vid, fid, &scmMtime)==0 ){ | |
| 1884 | + if( currentMtime!=scmMtime ){ | |
| 1885 | + ++changeCount; | |
| 1886 | + if( dryRunFlag!=0 ){ | |
| 1887 | + fossil_print( "dry-run: %s\n", zName ); | |
| 1888 | + }else{ | |
| 1889 | + file_set_mtime(zName, scmMtime); | |
| 1890 | + if( verboseFlag!=0 ){ | |
| 1891 | + fossil_print( "touched %s\n", zName ); | |
| 1892 | + } | |
| 1893 | + } | |
| 1894 | + } | |
| 1895 | + } | |
| 1896 | + } | |
| 1897 | + db_finalize(&q); | |
| 1898 | + db_end_transaction(0); | |
| 1899 | + glob_free(pGlob); | |
| 1900 | + if( dryRunFlag!=0 ){ | |
| 1901 | + fossil_print("dry-run: would have touched %d file(s)\n", | |
| 1902 | + changeCount); | |
| 1903 | + }else if( verboseFlag!=0 ){ | |
| 1904 | + fossil_print("Touched %d file(s)\n", changeCount); | |
| 1905 | + } | |
| 1906 | +} | |
| 1803 | 1907 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1798,5 +1798,109 @@ | |
| 1798 | } |
| 1799 | zDir = g.argv[2]; |
| 1800 | zGlob = g.argc==4 ? g.argv[3] : 0; |
| 1801 | fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles)); |
| 1802 | } |
| 1803 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1798,5 +1798,109 @@ | |
| 1798 | } |
| 1799 | zDir = g.argv[2]; |
| 1800 | zGlob = g.argc==4 ? g.argv[3] : 0; |
| 1801 | fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles)); |
| 1802 | } |
| 1803 | |
| 1804 | |
| 1805 | /* |
| 1806 | ** COMMAND: touch* |
| 1807 | ** |
| 1808 | ** Usage: %fossil touch ?OPTIONS? |
| 1809 | ** |
| 1810 | ** For each file in the current checkout matching one of the provided |
| 1811 | ** list of glob patterns, or all files if no globs are provided, sets |
| 1812 | ** the file's mtime to the time of the last checkin which modified |
| 1813 | ** that file. |
| 1814 | ** |
| 1815 | ** This command gets its name from the conventional Unix "touch" |
| 1816 | ** command. |
| 1817 | ** |
| 1818 | ** Options: |
| 1819 | ** -g GLOBLIST Comma-separated list of glob patterns. Default |
| 1820 | ** is to touch all SCM-controlled files. |
| 1821 | ** -G GLOBFILE Similar to -g but reads its globs from a |
| 1822 | ** fossil-conventional glob list file. |
| 1823 | ** -v|-verbose Outputs information about its globs and each |
| 1824 | ** file it touches. |
| 1825 | ** -n|--dry-run Outputs which files would require touching, |
| 1826 | ** but does not touch them. |
| 1827 | ** |
| 1828 | ** Only one of -g or -G may be used. |
| 1829 | ** |
| 1830 | */ |
| 1831 | void touch_cmd(){ |
| 1832 | const char * zGlobList; /* -g List of glob patterns */ |
| 1833 | const char * zGlobFile; /* -G File of glob patterns */ |
| 1834 | Glob * pGlob = 0; /* List of glob patterns */ |
| 1835 | int verboseFlag; |
| 1836 | int dryRunFlag; |
| 1837 | int vid; /* Checkout version */ |
| 1838 | int changeCount = 0; /* Number of files touched */ |
| 1839 | Stmt q; |
| 1840 | |
| 1841 | verboseFlag = find_option("verbose","v",0)!=0; |
| 1842 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 1843 | zGlobList = find_option("glob", "g",1); |
| 1844 | zGlobFile = find_option("globfile", "G",1); |
| 1845 | |
| 1846 | verify_all_options(); |
| 1847 | if(zGlobList && zGlobFile){ |
| 1848 | fossil_fatal("Cannot use both -g and -G options."); |
| 1849 | } |
| 1850 | |
| 1851 | db_must_be_within_tree(); |
| 1852 | vid = db_lget_int("checkout", 0); |
| 1853 | if(vid==0){ |
| 1854 | fossil_fatal("Cannot determine checkout version."); |
| 1855 | } |
| 1856 | if(zGlobList){ |
| 1857 | pGlob = *zGlobList ? glob_create(zGlobList) : 0; |
| 1858 | }else if(zGlobFile){ |
| 1859 | Blob globs; |
| 1860 | blob_read_from_file(&globs, zGlobFile, ExtFILE); |
| 1861 | pGlob = glob_create( globs.aData ); |
| 1862 | blob_reset(&globs); |
| 1863 | } |
| 1864 | db_begin_transaction(); |
| 1865 | db_prepare(&q, "SELECT vfile.mrid, pathname " |
| 1866 | "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid " |
| 1867 | "WHERE vid=%d", vid); |
| 1868 | if( pGlob && verboseFlag!=0 ){ |
| 1869 | int i; |
| 1870 | for(i=0; i<pGlob->nPattern; ++i){ |
| 1871 | fossil_print("glob: %s\n", pGlob->azPattern[i]); |
| 1872 | } |
| 1873 | } |
| 1874 | while(SQLITE_ROW==db_step(&q)){ |
| 1875 | const char * zName = db_column_text(&q, 1); |
| 1876 | int const fid = db_column_int(&q, 0); |
| 1877 | i64 scmMtime; |
| 1878 | i64 currentMtime; |
| 1879 | if(pGlob){ |
| 1880 | if(glob_match(pGlob, zName)==0) continue; |
| 1881 | } |
| 1882 | currentMtime = file_mtime(zName, 0); |
| 1883 | if( mtime_of_manifest_file(vid, fid, &scmMtime)==0 ){ |
| 1884 | if( currentMtime!=scmMtime ){ |
| 1885 | ++changeCount; |
| 1886 | if( dryRunFlag!=0 ){ |
| 1887 | fossil_print( "dry-run: %s\n", zName ); |
| 1888 | }else{ |
| 1889 | file_set_mtime(zName, scmMtime); |
| 1890 | if( verboseFlag!=0 ){ |
| 1891 | fossil_print( "touched %s\n", zName ); |
| 1892 | } |
| 1893 | } |
| 1894 | } |
| 1895 | } |
| 1896 | } |
| 1897 | db_finalize(&q); |
| 1898 | db_end_transaction(0); |
| 1899 | glob_free(pGlob); |
| 1900 | if( dryRunFlag!=0 ){ |
| 1901 | fossil_print("dry-run: would have touched %d file(s)\n", |
| 1902 | changeCount); |
| 1903 | }else if( verboseFlag!=0 ){ |
| 1904 | fossil_print("Touched %d file(s)\n", changeCount); |
| 1905 | } |
| 1906 | } |
| 1907 |
+104
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -1798,5 +1798,109 @@ | ||
| 1798 | 1798 | } |
| 1799 | 1799 | zDir = g.argv[2]; |
| 1800 | 1800 | zGlob = g.argc==4 ? g.argv[3] : 0; |
| 1801 | 1801 | fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles)); |
| 1802 | 1802 | } |
| 1803 | + | |
| 1804 | + | |
| 1805 | +/* | |
| 1806 | +** COMMAND: touch* | |
| 1807 | +** | |
| 1808 | +** Usage: %fossil touch ?OPTIONS? | |
| 1809 | +** | |
| 1810 | +** For each file in the current checkout matching one of the provided | |
| 1811 | +** list of glob patterns, or all files if no globs are provided, sets | |
| 1812 | +** the file's mtime to the time of the last checkin which modified | |
| 1813 | +** that file. | |
| 1814 | +** | |
| 1815 | +** This command gets its name from the conventional Unix "touch" | |
| 1816 | +** command. | |
| 1817 | +** | |
| 1818 | +** Options: | |
| 1819 | +** -g GLOBLIST Comma-separated list of glob patterns. Default | |
| 1820 | +** is to touch all SCM-controlled files. | |
| 1821 | +** -G GLOBFILE Similar to -g but reads its globs from a | |
| 1822 | +** fossil-conventional glob list file. | |
| 1823 | +** -v|-verbose Outputs information about its globs and each | |
| 1824 | +** file it touches. | |
| 1825 | +** -n|--dry-run Outputs which files would require touching, | |
| 1826 | +** but does not touch them. | |
| 1827 | +** | |
| 1828 | +** Only one of -g or -G may be used. | |
| 1829 | +** | |
| 1830 | +*/ | |
| 1831 | +void touch_cmd(){ | |
| 1832 | + const char * zGlobList; /* -g List of glob patterns */ | |
| 1833 | + const char * zGlobFile; /* -G File of glob patterns */ | |
| 1834 | + Glob * pGlob = 0; /* List of glob patterns */ | |
| 1835 | + int verboseFlag; | |
| 1836 | + int dryRunFlag; | |
| 1837 | + int vid; /* Checkout version */ | |
| 1838 | + int changeCount = 0; /* Number of files touched */ | |
| 1839 | + Stmt q; | |
| 1840 | + | |
| 1841 | + verboseFlag = find_option("verbose","v",0)!=0; | |
| 1842 | + dryRunFlag = find_option("dry-run","n",0)!=0; | |
| 1843 | + zGlobList = find_option("glob", "g",1); | |
| 1844 | + zGlobFile = find_option("globfile", "G",1); | |
| 1845 | + | |
| 1846 | + verify_all_options(); | |
| 1847 | + if(zGlobList && zGlobFile){ | |
| 1848 | + fossil_fatal("Cannot use both -g and -G options."); | |
| 1849 | + } | |
| 1850 | + | |
| 1851 | + db_must_be_within_tree(); | |
| 1852 | + vid = db_lget_int("checkout", 0); | |
| 1853 | + if(vid==0){ | |
| 1854 | + fossil_fatal("Cannot determine checkout version."); | |
| 1855 | + } | |
| 1856 | + if(zGlobList){ | |
| 1857 | + pGlob = *zGlobList ? glob_create(zGlobList) : 0; | |
| 1858 | + }else if(zGlobFile){ | |
| 1859 | + Blob globs; | |
| 1860 | + blob_read_from_file(&globs, zGlobFile, ExtFILE); | |
| 1861 | + pGlob = glob_create( globs.aData ); | |
| 1862 | + blob_reset(&globs); | |
| 1863 | + } | |
| 1864 | + db_begin_transaction(); | |
| 1865 | + db_prepare(&q, "SELECT vfile.mrid, pathname " | |
| 1866 | + "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid " | |
| 1867 | + "WHERE vid=%d", vid); | |
| 1868 | + if( pGlob && verboseFlag!=0 ){ | |
| 1869 | + int i; | |
| 1870 | + for(i=0; i<pGlob->nPattern; ++i){ | |
| 1871 | + fossil_print("glob: %s\n", pGlob->azPattern[i]); | |
| 1872 | + } | |
| 1873 | + } | |
| 1874 | + while(SQLITE_ROW==db_step(&q)){ | |
| 1875 | + const char * zName = db_column_text(&q, 1); | |
| 1876 | + int const fid = db_column_int(&q, 0); | |
| 1877 | + i64 scmMtime; | |
| 1878 | + i64 currentMtime; | |
| 1879 | + if(pGlob){ | |
| 1880 | + if(glob_match(pGlob, zName)==0) continue; | |
| 1881 | + } | |
| 1882 | + currentMtime = file_mtime(zName, 0); | |
| 1883 | + if( mtime_of_manifest_file(vid, fid, &scmMtime)==0 ){ | |
| 1884 | + if( currentMtime!=scmMtime ){ | |
| 1885 | + ++changeCount; | |
| 1886 | + if( dryRunFlag!=0 ){ | |
| 1887 | + fossil_print( "dry-run: %s\n", zName ); | |
| 1888 | + }else{ | |
| 1889 | + file_set_mtime(zName, scmMtime); | |
| 1890 | + if( verboseFlag!=0 ){ | |
| 1891 | + fossil_print( "touched %s\n", zName ); | |
| 1892 | + } | |
| 1893 | + } | |
| 1894 | + } | |
| 1895 | + } | |
| 1896 | + } | |
| 1897 | + db_finalize(&q); | |
| 1898 | + db_end_transaction(0); | |
| 1899 | + glob_free(pGlob); | |
| 1900 | + if( dryRunFlag!=0 ){ | |
| 1901 | + fossil_print("dry-run: would have touched %d file(s)\n", | |
| 1902 | + changeCount); | |
| 1903 | + }else if( verboseFlag!=0 ){ | |
| 1904 | + fossil_print("Touched %d file(s)\n", changeCount); | |
| 1905 | + } | |
| 1906 | +} | |
| 1803 | 1907 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1798,5 +1798,109 @@ | |
| 1798 | } |
| 1799 | zDir = g.argv[2]; |
| 1800 | zGlob = g.argc==4 ? g.argv[3] : 0; |
| 1801 | fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles)); |
| 1802 | } |
| 1803 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1798,5 +1798,109 @@ | |
| 1798 | } |
| 1799 | zDir = g.argv[2]; |
| 1800 | zGlob = g.argc==4 ? g.argv[3] : 0; |
| 1801 | fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles)); |
| 1802 | } |
| 1803 | |
| 1804 | |
| 1805 | /* |
| 1806 | ** COMMAND: touch* |
| 1807 | ** |
| 1808 | ** Usage: %fossil touch ?OPTIONS? |
| 1809 | ** |
| 1810 | ** For each file in the current checkout matching one of the provided |
| 1811 | ** list of glob patterns, or all files if no globs are provided, sets |
| 1812 | ** the file's mtime to the time of the last checkin which modified |
| 1813 | ** that file. |
| 1814 | ** |
| 1815 | ** This command gets its name from the conventional Unix "touch" |
| 1816 | ** command. |
| 1817 | ** |
| 1818 | ** Options: |
| 1819 | ** -g GLOBLIST Comma-separated list of glob patterns. Default |
| 1820 | ** is to touch all SCM-controlled files. |
| 1821 | ** -G GLOBFILE Similar to -g but reads its globs from a |
| 1822 | ** fossil-conventional glob list file. |
| 1823 | ** -v|-verbose Outputs information about its globs and each |
| 1824 | ** file it touches. |
| 1825 | ** -n|--dry-run Outputs which files would require touching, |
| 1826 | ** but does not touch them. |
| 1827 | ** |
| 1828 | ** Only one of -g or -G may be used. |
| 1829 | ** |
| 1830 | */ |
| 1831 | void touch_cmd(){ |
| 1832 | const char * zGlobList; /* -g List of glob patterns */ |
| 1833 | const char * zGlobFile; /* -G File of glob patterns */ |
| 1834 | Glob * pGlob = 0; /* List of glob patterns */ |
| 1835 | int verboseFlag; |
| 1836 | int dryRunFlag; |
| 1837 | int vid; /* Checkout version */ |
| 1838 | int changeCount = 0; /* Number of files touched */ |
| 1839 | Stmt q; |
| 1840 | |
| 1841 | verboseFlag = find_option("verbose","v",0)!=0; |
| 1842 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 1843 | zGlobList = find_option("glob", "g",1); |
| 1844 | zGlobFile = find_option("globfile", "G",1); |
| 1845 | |
| 1846 | verify_all_options(); |
| 1847 | if(zGlobList && zGlobFile){ |
| 1848 | fossil_fatal("Cannot use both -g and -G options."); |
| 1849 | } |
| 1850 | |
| 1851 | db_must_be_within_tree(); |
| 1852 | vid = db_lget_int("checkout", 0); |
| 1853 | if(vid==0){ |
| 1854 | fossil_fatal("Cannot determine checkout version."); |
| 1855 | } |
| 1856 | if(zGlobList){ |
| 1857 | pGlob = *zGlobList ? glob_create(zGlobList) : 0; |
| 1858 | }else if(zGlobFile){ |
| 1859 | Blob globs; |
| 1860 | blob_read_from_file(&globs, zGlobFile, ExtFILE); |
| 1861 | pGlob = glob_create( globs.aData ); |
| 1862 | blob_reset(&globs); |
| 1863 | } |
| 1864 | db_begin_transaction(); |
| 1865 | db_prepare(&q, "SELECT vfile.mrid, pathname " |
| 1866 | "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid " |
| 1867 | "WHERE vid=%d", vid); |
| 1868 | if( pGlob && verboseFlag!=0 ){ |
| 1869 | int i; |
| 1870 | for(i=0; i<pGlob->nPattern; ++i){ |
| 1871 | fossil_print("glob: %s\n", pGlob->azPattern[i]); |
| 1872 | } |
| 1873 | } |
| 1874 | while(SQLITE_ROW==db_step(&q)){ |
| 1875 | const char * zName = db_column_text(&q, 1); |
| 1876 | int const fid = db_column_int(&q, 0); |
| 1877 | i64 scmMtime; |
| 1878 | i64 currentMtime; |
| 1879 | if(pGlob){ |
| 1880 | if(glob_match(pGlob, zName)==0) continue; |
| 1881 | } |
| 1882 | currentMtime = file_mtime(zName, 0); |
| 1883 | if( mtime_of_manifest_file(vid, fid, &scmMtime)==0 ){ |
| 1884 | if( currentMtime!=scmMtime ){ |
| 1885 | ++changeCount; |
| 1886 | if( dryRunFlag!=0 ){ |
| 1887 | fossil_print( "dry-run: %s\n", zName ); |
| 1888 | }else{ |
| 1889 | file_set_mtime(zName, scmMtime); |
| 1890 | if( verboseFlag!=0 ){ |
| 1891 | fossil_print( "touched %s\n", zName ); |
| 1892 | } |
| 1893 | } |
| 1894 | } |
| 1895 | } |
| 1896 | } |
| 1897 | db_finalize(&q); |
| 1898 | db_end_transaction(0); |
| 1899 | glob_free(pGlob); |
| 1900 | if( dryRunFlag!=0 ){ |
| 1901 | fossil_print("dry-run: would have touched %d file(s)\n", |
| 1902 | changeCount); |
| 1903 | }else if( verboseFlag!=0 ){ |
| 1904 | fossil_print("Touched %d file(s)\n", changeCount); |
| 1905 | } |
| 1906 | } |
| 1907 |