Fossil SCM

Improvement on the checkout/co command. "co --keep" now imply "--force" since it's guaranteed that no file from the checkout will be affected. Add short flag version of --keep and --force. Document the existence of the "--prompt" flag.

mgagnon 2025-03-21 15:39 trunk
Commit 5bc31db11a8e6112cd06fda0e153809fd42263e93b1bcc2e3c7af1ee80ff6ea5
1 file changed +10 -4
+10 -4
--- src/checkout.c
+++ src/checkout.c
@@ -276,13 +276,14 @@
276276
**
277277
** The --latest flag can be used in place of VERSION to check-out the
278278
** latest version in the repository.
279279
**
280280
** Options:
281
-** --force Ignore edited files in the current check-out
282
-** --keep Only update the manifest file(s)
281
+** -f|--force Ignore edited files in the current check-out
282
+** -k|--keep Only update the manifest file(s)
283283
** --force-missing Force check-out even if content is missing
284
+** --prompt Prompt before overwritting when --force is used
284285
** --setmtime Set timestamps of all files to match their SCM-side
285286
** times (the timestamp of the last check-in which modified
286287
** them)
287288
**
288289
** See also: [[update]]
@@ -298,16 +299,21 @@
298299
int setmtimeFlag; /* --setmtime. Set mtimes on files */
299300
Blob cksum1, cksum1b, cksum2;
300301
301302
db_must_be_within_tree();
302303
db_begin_transaction();
303
- forceFlag = find_option("force","f",0)!=0;
304304
forceMissingFlag = find_option("force-missing",0,0)!=0;
305
- keepFlag = find_option("keep",0,0)!=0;
305
+ keepFlag = find_option("keep","k",0)!=0;
306
+ forceFlag = find_option("force","f",0)!=0;
306307
latestFlag = find_option("latest",0,0)!=0;
307308
promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0;
308309
setmtimeFlag = find_option("setmtime",0,0)!=0;
310
+
311
+ if( keepFlag != 0 ){
312
+ /* After flag collection to explicitly don't affect promptFlag */
313
+ forceFlag=1;
314
+ }
309315
310316
/* We should be done with options.. */
311317
verify_all_options();
312318
313319
if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){
314320
--- src/checkout.c
+++ src/checkout.c
@@ -276,13 +276,14 @@
276 **
277 ** The --latest flag can be used in place of VERSION to check-out the
278 ** latest version in the repository.
279 **
280 ** Options:
281 ** --force Ignore edited files in the current check-out
282 ** --keep Only update the manifest file(s)
283 ** --force-missing Force check-out even if content is missing
 
284 ** --setmtime Set timestamps of all files to match their SCM-side
285 ** times (the timestamp of the last check-in which modified
286 ** them)
287 **
288 ** See also: [[update]]
@@ -298,16 +299,21 @@
298 int setmtimeFlag; /* --setmtime. Set mtimes on files */
299 Blob cksum1, cksum1b, cksum2;
300
301 db_must_be_within_tree();
302 db_begin_transaction();
303 forceFlag = find_option("force","f",0)!=0;
304 forceMissingFlag = find_option("force-missing",0,0)!=0;
305 keepFlag = find_option("keep",0,0)!=0;
 
306 latestFlag = find_option("latest",0,0)!=0;
307 promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0;
308 setmtimeFlag = find_option("setmtime",0,0)!=0;
 
 
 
 
 
309
310 /* We should be done with options.. */
311 verify_all_options();
312
313 if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){
314
--- src/checkout.c
+++ src/checkout.c
@@ -276,13 +276,14 @@
276 **
277 ** The --latest flag can be used in place of VERSION to check-out the
278 ** latest version in the repository.
279 **
280 ** Options:
281 ** -f|--force Ignore edited files in the current check-out
282 ** -k|--keep Only update the manifest file(s)
283 ** --force-missing Force check-out even if content is missing
284 ** --prompt Prompt before overwritting when --force is used
285 ** --setmtime Set timestamps of all files to match their SCM-side
286 ** times (the timestamp of the last check-in which modified
287 ** them)
288 **
289 ** See also: [[update]]
@@ -298,16 +299,21 @@
299 int setmtimeFlag; /* --setmtime. Set mtimes on files */
300 Blob cksum1, cksum1b, cksum2;
301
302 db_must_be_within_tree();
303 db_begin_transaction();
 
304 forceMissingFlag = find_option("force-missing",0,0)!=0;
305 keepFlag = find_option("keep","k",0)!=0;
306 forceFlag = find_option("force","f",0)!=0;
307 latestFlag = find_option("latest",0,0)!=0;
308 promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0;
309 setmtimeFlag = find_option("setmtime",0,0)!=0;
310
311 if( keepFlag != 0 ){
312 /* After flag collection to explicitly don't affect promptFlag */
313 forceFlag=1;
314 }
315
316 /* We should be done with options.. */
317 verify_all_options();
318
319 if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){
320

Keyboard Shortcuts

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