Fossil SCM

Change behavior of "fossil clear --ignore": The ignore setting now specifies which files can be removed without confirmation Add versionable "ignore-glob" setting for fossil, in order to demonstrate the desired behavior.

jan.nijtmans 2013-03-10 09:57 trunk
Commit 5a3855f68b3ddb0d87a091c0e04c7a896f4695b7
--- a/.fossil-settings/ignore-glob
+++ b/.fossil-settings/ignore-glob
@@ -0,0 +1,11 @@
1
+*.a
2
+*.dll
3
+*.o
4
+*.obj
5
+*_.c
6
+*_.h
7
+Makefile
8
+wbld/*
9
+bld/*
10
+autoconfig.h
11
+config.log
--- a/.fossil-settings/ignore-glob
+++ b/.fossil-settings/ignore-glob
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
--- a/.fossil-settings/ignore-glob
+++ b/.fossil-settings/ignore-glob
@@ -0,0 +1,11 @@
1 *.a
2 *.dll
3 *.o
4 *.obj
5 *_.c
6 *_.h
7 Makefile
8 wbld/*
9 bld/*
10 autoconfig.h
11 config.log
+7 -10
--- src/checkin.c
+++ src/checkin.c
@@ -380,25 +380,22 @@
380380
** files that are not officially part of the checkout. This operation
381381
** cannot be undone.
382382
**
383383
** You will be prompted before removing each file. If you are
384384
** sure you wish to remove all "extra" files you can specify the
385
-** optional --force flag and no prompts will be issued.
385
+** optional --force flag and no prompts will be issued. The
386
+** "ignore-glob" setting specifies for which files the prompting
387
+** will be skipped. You can override this with --ignore option.
386388
**
387389
** Files and subdirectories whose names begin with "." are
388390
** normally ignored. They are included if the "--dotfiles" option
389391
** is used.
390392
**
391
-** The GLOBPATTERN is a comma-separated list of GLOB expressions for
392
-** files that are ignored. The GLOBPATTERN specified by the "ignore-glob"
393
-** is used if the --ignore option is omitted.
394
-**
395393
** Options:
396394
** --dotfiles include files beginning with a dot (".")
397395
** --force Remove files without prompting
398
-** --ignore <CSG> ignore files matching patterns from the
399
-** comma separated list of glob patterns.
396
+** --ignore <CSG> Override the "ignore-glob" setting
400397
** --temp Remove only Fossil-generated temporary files
401398
**
402399
** See also: addremove, extra, status
403400
*/
404401
void clean_cmd(void){
@@ -423,12 +420,11 @@
423420
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
424421
filename_collation());
425422
n = strlen(g.zLocalRoot);
426423
blob_init(&path, g.zLocalRoot, n-1);
427424
pIgnore = glob_create(zIgnoreFlag);
428
- vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
429
- glob_free(pIgnore);
425
+ vfile_scan(&path, blob_size(&path), scanFlags, NULL);
430426
db_prepare(&q,
431427
"SELECT %Q || x FROM sfile"
432428
" WHERE x NOT IN (%s)"
433429
" ORDER BY 1",
434430
g.zLocalRoot, fossil_all_reserved_names(0)
@@ -438,11 +434,11 @@
438434
}
439435
db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
440436
while( db_step(&q)==SQLITE_ROW ){
441437
if( testFlag ){
442438
fossil_print("%s\n", db_column_text(&q,0));
443
- }else if( allFlag ){
439
+ }else if( allFlag || glob_match(pIgnore, db_column_text(&q, 0)+n) ){
444440
file_delete(db_column_text(&q, 0));
445441
}else{
446442
Blob ans;
447443
char cReply;
448444
char *prompt = mprintf("remove unmanaged file \"%s\" (y/N)? ",
@@ -453,10 +449,11 @@
453449
if( cReply=='y' || cReply=='Y' ){
454450
file_delete(db_column_text(&q, 0));
455451
}
456452
}
457453
}
454
+ glob_free(pIgnore);
458455
db_finalize(&q);
459456
}
460457
461458
/*
462459
** Prompt the user for a check-in or stash comment (given in pPrompt),
463460
--- src/checkin.c
+++ src/checkin.c
@@ -380,25 +380,22 @@
380 ** files that are not officially part of the checkout. This operation
381 ** cannot be undone.
382 **
383 ** You will be prompted before removing each file. If you are
384 ** sure you wish to remove all "extra" files you can specify the
385 ** optional --force flag and no prompts will be issued.
 
 
386 **
387 ** Files and subdirectories whose names begin with "." are
388 ** normally ignored. They are included if the "--dotfiles" option
389 ** is used.
390 **
391 ** The GLOBPATTERN is a comma-separated list of GLOB expressions for
392 ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob"
393 ** is used if the --ignore option is omitted.
394 **
395 ** Options:
396 ** --dotfiles include files beginning with a dot (".")
397 ** --force Remove files without prompting
398 ** --ignore <CSG> ignore files matching patterns from the
399 ** comma separated list of glob patterns.
400 ** --temp Remove only Fossil-generated temporary files
401 **
402 ** See also: addremove, extra, status
403 */
404 void clean_cmd(void){
@@ -423,12 +420,11 @@
423 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
424 filename_collation());
425 n = strlen(g.zLocalRoot);
426 blob_init(&path, g.zLocalRoot, n-1);
427 pIgnore = glob_create(zIgnoreFlag);
428 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
429 glob_free(pIgnore);
430 db_prepare(&q,
431 "SELECT %Q || x FROM sfile"
432 " WHERE x NOT IN (%s)"
433 " ORDER BY 1",
434 g.zLocalRoot, fossil_all_reserved_names(0)
@@ -438,11 +434,11 @@
438 }
439 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
440 while( db_step(&q)==SQLITE_ROW ){
441 if( testFlag ){
442 fossil_print("%s\n", db_column_text(&q,0));
443 }else if( allFlag ){
444 file_delete(db_column_text(&q, 0));
445 }else{
446 Blob ans;
447 char cReply;
448 char *prompt = mprintf("remove unmanaged file \"%s\" (y/N)? ",
@@ -453,10 +449,11 @@
453 if( cReply=='y' || cReply=='Y' ){
454 file_delete(db_column_text(&q, 0));
455 }
456 }
457 }
 
458 db_finalize(&q);
459 }
460
461 /*
462 ** Prompt the user for a check-in or stash comment (given in pPrompt),
463
--- src/checkin.c
+++ src/checkin.c
@@ -380,25 +380,22 @@
380 ** files that are not officially part of the checkout. This operation
381 ** cannot be undone.
382 **
383 ** You will be prompted before removing each file. If you are
384 ** sure you wish to remove all "extra" files you can specify the
385 ** optional --force flag and no prompts will be issued. The
386 ** "ignore-glob" setting specifies for which files the prompting
387 ** will be skipped. You can override this with --ignore option.
388 **
389 ** Files and subdirectories whose names begin with "." are
390 ** normally ignored. They are included if the "--dotfiles" option
391 ** is used.
392 **
 
 
 
 
393 ** Options:
394 ** --dotfiles include files beginning with a dot (".")
395 ** --force Remove files without prompting
396 ** --ignore <CSG> Override the "ignore-glob" setting
 
397 ** --temp Remove only Fossil-generated temporary files
398 **
399 ** See also: addremove, extra, status
400 */
401 void clean_cmd(void){
@@ -423,12 +420,11 @@
420 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
421 filename_collation());
422 n = strlen(g.zLocalRoot);
423 blob_init(&path, g.zLocalRoot, n-1);
424 pIgnore = glob_create(zIgnoreFlag);
425 vfile_scan(&path, blob_size(&path), scanFlags, NULL);
 
426 db_prepare(&q,
427 "SELECT %Q || x FROM sfile"
428 " WHERE x NOT IN (%s)"
429 " ORDER BY 1",
430 g.zLocalRoot, fossil_all_reserved_names(0)
@@ -438,11 +434,11 @@
434 }
435 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
436 while( db_step(&q)==SQLITE_ROW ){
437 if( testFlag ){
438 fossil_print("%s\n", db_column_text(&q,0));
439 }else if( allFlag || glob_match(pIgnore, db_column_text(&q, 0)+n) ){
440 file_delete(db_column_text(&q, 0));
441 }else{
442 Blob ans;
443 char cReply;
444 char *prompt = mprintf("remove unmanaged file \"%s\" (y/N)? ",
@@ -453,10 +449,11 @@
449 if( cReply=='y' || cReply=='Y' ){
450 file_delete(db_column_text(&q, 0));
451 }
452 }
453 }
454 glob_free(pIgnore);
455 db_finalize(&q);
456 }
457
458 /*
459 ** Prompt the user for a check-in or stash comment (given in pPrompt),
460

Keyboard Shortcuts

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