Fossil SCM

Get the --ignore option and ignore-glob setting working for the "clean" command. Ticket [0bc90d7235404d16].

drh 2010-12-20 12:49 trunk
Commit f12a6962a77aa4c26d21a152a0b216e39f8bdc10
1 file changed +16 -3
+16 -3
--- src/checkin.c
+++ src/checkin.c
@@ -262,10 +262,14 @@
262262
** Print a list of all files in the source tree that are not part of
263263
** the current checkout. See also the "clean" command.
264264
**
265265
** Files and subdirectories whose names begin with "." are normally
266266
** ignored but can be included by adding the --dotfiles option.
267
+**
268
+** The GLOBPATTERN is a comma-separated list of GLOB expressions for
269
+** files that are ignored. The GLOBPATTERN specified by the "ignore-glob"
270
+** is used if the --ignore option is omitted.
267271
*/
268272
void extra_cmd(void){
269273
Blob path;
270274
Blob repo;
271275
Stmt q;
@@ -300,11 +304,11 @@
300304
db_finalize(&q);
301305
}
302306
303307
/*
304308
** COMMAND: clean
305
-** Usage: %fossil clean ?--force? ?--dotfiles?
309
+** Usage: %fossil clean ?--force? ?--dotfiles? ?--ignore GLOBPATTERN?
306310
**
307311
** Delete all "extra" files in the source tree. "Extra" files are
308312
** files that are not officially part of the checkout. See also
309313
** the "extra" command. This operation cannot be undone.
310314
**
@@ -313,29 +317,38 @@
313317
** optional --force flag and no prompts will be issued.
314318
**
315319
** Files and subdirectories whose names begin with "." are
316320
** normally ignored. They are included if the "--dotfiles" option
317321
** is used.
322
+**
323
+** The GLOBPATTERN is a comma-separated list of GLOB expressions for
324
+** files that are ignored. The GLOBPATTERN specified by the "ignore-glob"
325
+** is used if the --ignore option is omitted.
318326
*/
319327
void clean_cmd(void){
320328
int allFlag;
321329
int dotfilesFlag;
330
+ const char *zIgnoreFlag;
322331
Blob path, repo;
323332
Stmt q;
324333
int n;
325334
allFlag = find_option("force","f",0)!=0;
326335
dotfilesFlag = find_option("dotfiles",0,0)!=0;
336
+ zIgnoreFlag = find_option("ignore",0,1);
327337
db_must_be_within_tree();
338
+ if( zIgnoreFlag==0 ){
339
+ zIgnoreFlag = db_get("ignore-glob", 0);
340
+ }
328341
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
329342
n = strlen(g.zLocalRoot);
330343
blob_init(&path, g.zLocalRoot, n-1);
331344
vfile_scan(0, &path, blob_size(&path), dotfilesFlag);
332345
db_prepare(&q,
333346
"SELECT %Q || x FROM sfile"
334
- " WHERE x NOT IN (%s)"
347
+ " WHERE x NOT IN (%s) AND NOT %s"
335348
" ORDER BY 1",
336
- g.zLocalRoot, fossil_all_reserved_names()
349
+ g.zLocalRoot, fossil_all_reserved_names(), glob_expr("x",zIgnoreFlag)
337350
);
338351
if( file_tree_name(g.zRepositoryName, &repo, 0) ){
339352
db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
340353
}
341354
while( db_step(&q)==SQLITE_ROW ){
342355
--- src/checkin.c
+++ src/checkin.c
@@ -262,10 +262,14 @@
262 ** Print a list of all files in the source tree that are not part of
263 ** the current checkout. See also the "clean" command.
264 **
265 ** Files and subdirectories whose names begin with "." are normally
266 ** ignored but can be included by adding the --dotfiles option.
 
 
 
 
267 */
268 void extra_cmd(void){
269 Blob path;
270 Blob repo;
271 Stmt q;
@@ -300,11 +304,11 @@
300 db_finalize(&q);
301 }
302
303 /*
304 ** COMMAND: clean
305 ** Usage: %fossil clean ?--force? ?--dotfiles?
306 **
307 ** Delete all "extra" files in the source tree. "Extra" files are
308 ** files that are not officially part of the checkout. See also
309 ** the "extra" command. This operation cannot be undone.
310 **
@@ -313,29 +317,38 @@
313 ** optional --force flag and no prompts will be issued.
314 **
315 ** Files and subdirectories whose names begin with "." are
316 ** normally ignored. They are included if the "--dotfiles" option
317 ** is used.
 
 
 
 
318 */
319 void clean_cmd(void){
320 int allFlag;
321 int dotfilesFlag;
 
322 Blob path, repo;
323 Stmt q;
324 int n;
325 allFlag = find_option("force","f",0)!=0;
326 dotfilesFlag = find_option("dotfiles",0,0)!=0;
 
327 db_must_be_within_tree();
 
 
 
328 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
329 n = strlen(g.zLocalRoot);
330 blob_init(&path, g.zLocalRoot, n-1);
331 vfile_scan(0, &path, blob_size(&path), dotfilesFlag);
332 db_prepare(&q,
333 "SELECT %Q || x FROM sfile"
334 " WHERE x NOT IN (%s)"
335 " ORDER BY 1",
336 g.zLocalRoot, fossil_all_reserved_names()
337 );
338 if( file_tree_name(g.zRepositoryName, &repo, 0) ){
339 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
340 }
341 while( db_step(&q)==SQLITE_ROW ){
342
--- src/checkin.c
+++ src/checkin.c
@@ -262,10 +262,14 @@
262 ** Print a list of all files in the source tree that are not part of
263 ** the current checkout. See also the "clean" command.
264 **
265 ** Files and subdirectories whose names begin with "." are normally
266 ** ignored but can be included by adding the --dotfiles option.
267 **
268 ** The GLOBPATTERN is a comma-separated list of GLOB expressions for
269 ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob"
270 ** is used if the --ignore option is omitted.
271 */
272 void extra_cmd(void){
273 Blob path;
274 Blob repo;
275 Stmt q;
@@ -300,11 +304,11 @@
304 db_finalize(&q);
305 }
306
307 /*
308 ** COMMAND: clean
309 ** Usage: %fossil clean ?--force? ?--dotfiles? ?--ignore GLOBPATTERN?
310 **
311 ** Delete all "extra" files in the source tree. "Extra" files are
312 ** files that are not officially part of the checkout. See also
313 ** the "extra" command. This operation cannot be undone.
314 **
@@ -313,29 +317,38 @@
317 ** optional --force flag and no prompts will be issued.
318 **
319 ** Files and subdirectories whose names begin with "." are
320 ** normally ignored. They are included if the "--dotfiles" option
321 ** is used.
322 **
323 ** The GLOBPATTERN is a comma-separated list of GLOB expressions for
324 ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob"
325 ** is used if the --ignore option is omitted.
326 */
327 void clean_cmd(void){
328 int allFlag;
329 int dotfilesFlag;
330 const char *zIgnoreFlag;
331 Blob path, repo;
332 Stmt q;
333 int n;
334 allFlag = find_option("force","f",0)!=0;
335 dotfilesFlag = find_option("dotfiles",0,0)!=0;
336 zIgnoreFlag = find_option("ignore",0,1);
337 db_must_be_within_tree();
338 if( zIgnoreFlag==0 ){
339 zIgnoreFlag = db_get("ignore-glob", 0);
340 }
341 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
342 n = strlen(g.zLocalRoot);
343 blob_init(&path, g.zLocalRoot, n-1);
344 vfile_scan(0, &path, blob_size(&path), dotfilesFlag);
345 db_prepare(&q,
346 "SELECT %Q || x FROM sfile"
347 " WHERE x NOT IN (%s) AND NOT %s"
348 " ORDER BY 1",
349 g.zLocalRoot, fossil_all_reserved_names(), glob_expr("x",zIgnoreFlag)
350 );
351 if( file_tree_name(g.zRepositoryName, &repo, 0) ){
352 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
353 }
354 while( db_step(&q)==SQLITE_ROW ){
355

Keyboard Shortcuts

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