Fossil SCM

rebase

jan.nijtmans 2013-06-19 07:20 UTC trunk merge
Commit 4279e6465abb571e9159d042924d2a0645766155
2 files changed +62 -8 +62 -8
+62 -8
--- src/checkin.c
+++ src/checkin.c
@@ -300,14 +300,15 @@
300300
db_finalize(&q);
301301
}
302302
303303
/*
304304
** COMMAND: extras
305
-** Usage: %fossil extras ?OPTIONS?
305
+** Usage: %fossil extras ?OPTIONS? ?PATH1 ...?
306306
**
307307
** Print a list of all files in the source tree that are not part of
308
-** the current checkout. See also the "clean" command.
308
+** the current checkout. See also the "clean" command. If paths are
309
+** specified, only files in the given directories will be listed.
309310
**
310311
** Files and subdirectories whose names begin with "." are normally
311312
** ignored but can be included by adding the --dotfiles option.
312313
**
313314
** The GLOBPATTERN is a comma-separated list of GLOB expressions for
@@ -328,11 +329,11 @@
328329
** See also: changes, clean, status
329330
*/
330331
void extra_cmd(void){
331332
Blob path;
332333
Stmt q;
333
- int n;
334
+ int n, i;
334335
const char *zIgnoreFlag = find_option("ignore",0,1);
335336
unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
336337
int cwdRelative = 0;
337338
Glob *pIgnore;
338339
Blob rewrittenPathname;
@@ -348,11 +349,37 @@
348349
blob_init(&path, g.zLocalRoot, n-1);
349350
if( zIgnoreFlag==0 ){
350351
zIgnoreFlag = db_get("ignore-glob", 0);
351352
}
352353
pIgnore = glob_create(zIgnoreFlag);
353
- vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
354
+
355
+ /* Load the names of all files that are candidates to be listed into sfile temp table */
356
+ if( g.argc < 3 ){
357
+ vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
358
+ }
359
+ for( i=2; i<g.argc; i++ ){
360
+ char *zName;
361
+ int isDir;
362
+ Blob fullName;
363
+
364
+ file_canonical_name(g.argv[i], &fullName, 0);
365
+ zName = blob_str(&fullName);
366
+ isDir = file_wd_isdir(zName);
367
+ if( isDir==1 ){
368
+ vfile_scan(&fullName, n-1, scanFlags, pIgnore);
369
+ }else if( isDir==0 ){
370
+ fossil_warning("not found: %s", zName);
371
+ }else if( file_access(zName, R_OK) ){
372
+ fossil_fatal("cannot open %s", zName);
373
+ }else{
374
+ db_multi_exec(
375
+ "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
376
+ &zName[n]
377
+ );
378
+ }
379
+ blob_reset(&fullName);
380
+ }
354381
glob_free(pIgnore);
355382
db_prepare(&q,
356383
"SELECT x FROM sfile"
357384
" WHERE x NOT IN (%s)"
358385
" ORDER BY 1",
@@ -377,15 +404,16 @@
377404
db_finalize(&q);
378405
}
379406
380407
/*
381408
** COMMAND: clean
382
-** Usage: %fossil clean ?OPTIONS?
409
+** Usage: %fossil clean ?OPTIONS? ?PATH1 ...?
383410
**
384411
** Delete all "extra" files in the source tree. "Extra" files are
385412
** files that are not officially part of the checkout. This operation
386
-** cannot be undone.
413
+** cannot be undone. If paths are specified, only the directories or
414
+** files specified will be considered for cleaning.
387415
**
388416
** You will be prompted before removing each eligible file unless the
389417
** --force flag is in use or it matches the --clean option. The
390418
** GLOBPATTERN specified by the "ignore-glob" setting is used if the
391419
** --ignore option is omitted, the same with "clean-glob" and --clean
@@ -419,11 +447,11 @@
419447
int allFlag, dryRunFlag, verboseFlag;
420448
unsigned scanFlags = 0;
421449
const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
422450
Blob path, repo;
423451
Stmt q;
424
- int n;
452
+ int n, i;
425453
Glob *pIgnore, *pKeep, *pClean;
426454
427455
dryRunFlag = find_option("dry-run","n",0)!=0;
428456
if( !dryRunFlag ){
429457
dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
@@ -452,11 +480,37 @@
452480
n = strlen(g.zLocalRoot);
453481
blob_init(&path, g.zLocalRoot, n-1);
454482
pIgnore = glob_create(zIgnoreFlag);
455483
pKeep = glob_create(zKeepFlag);
456484
pClean = glob_create(zCleanFlag);
457
- vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep);
485
+
486
+ /* Load the names of all files that are candidates to be cleaned into sfile temp table */
487
+ if( g.argc < 3 ){
488
+ vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep);
489
+ }
490
+ for( i=2; i<g.argc; i++ ){
491
+ char *zName;
492
+ int isDir;
493
+ Blob fullName;
494
+
495
+ file_canonical_name(g.argv[i], &fullName, 0);
496
+ zName = blob_str(&fullName);
497
+ isDir = file_wd_isdir(zName);
498
+ if( isDir==1 ){
499
+ vfile_scan2(&fullName, n-1, scanFlags, pIgnore, pKeep);
500
+ }else if( isDir==0 ){
501
+ fossil_warning("not found: %s", zName);
502
+ }else if( file_access(zName, R_OK) ){
503
+ fossil_fatal("cannot open %s", zName);
504
+ }else{
505
+ db_multi_exec(
506
+ "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
507
+ &zName[n]
508
+ );
509
+ }
510
+ blob_reset(&fullName);
511
+ }
458512
glob_free(pKeep);
459513
glob_free(pIgnore);
460514
db_prepare(&q,
461515
"SELECT %Q || x FROM sfile"
462516
" WHERE x NOT IN (%s)"
463517
--- src/checkin.c
+++ src/checkin.c
@@ -300,14 +300,15 @@
300 db_finalize(&q);
301 }
302
303 /*
304 ** COMMAND: extras
305 ** Usage: %fossil extras ?OPTIONS?
306 **
307 ** Print a list of all files in the source tree that are not part of
308 ** the current checkout. See also the "clean" command.
 
309 **
310 ** Files and subdirectories whose names begin with "." are normally
311 ** ignored but can be included by adding the --dotfiles option.
312 **
313 ** The GLOBPATTERN is a comma-separated list of GLOB expressions for
@@ -328,11 +329,11 @@
328 ** See also: changes, clean, status
329 */
330 void extra_cmd(void){
331 Blob path;
332 Stmt q;
333 int n;
334 const char *zIgnoreFlag = find_option("ignore",0,1);
335 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
336 int cwdRelative = 0;
337 Glob *pIgnore;
338 Blob rewrittenPathname;
@@ -348,11 +349,37 @@
348 blob_init(&path, g.zLocalRoot, n-1);
349 if( zIgnoreFlag==0 ){
350 zIgnoreFlag = db_get("ignore-glob", 0);
351 }
352 pIgnore = glob_create(zIgnoreFlag);
353 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354 glob_free(pIgnore);
355 db_prepare(&q,
356 "SELECT x FROM sfile"
357 " WHERE x NOT IN (%s)"
358 " ORDER BY 1",
@@ -377,15 +404,16 @@
377 db_finalize(&q);
378 }
379
380 /*
381 ** COMMAND: clean
382 ** Usage: %fossil clean ?OPTIONS?
383 **
384 ** Delete all "extra" files in the source tree. "Extra" files are
385 ** files that are not officially part of the checkout. This operation
386 ** cannot be undone.
 
387 **
388 ** You will be prompted before removing each eligible file unless the
389 ** --force flag is in use or it matches the --clean option. The
390 ** GLOBPATTERN specified by the "ignore-glob" setting is used if the
391 ** --ignore option is omitted, the same with "clean-glob" and --clean
@@ -419,11 +447,11 @@
419 int allFlag, dryRunFlag, verboseFlag;
420 unsigned scanFlags = 0;
421 const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
422 Blob path, repo;
423 Stmt q;
424 int n;
425 Glob *pIgnore, *pKeep, *pClean;
426
427 dryRunFlag = find_option("dry-run","n",0)!=0;
428 if( !dryRunFlag ){
429 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
@@ -452,11 +480,37 @@
452 n = strlen(g.zLocalRoot);
453 blob_init(&path, g.zLocalRoot, n-1);
454 pIgnore = glob_create(zIgnoreFlag);
455 pKeep = glob_create(zKeepFlag);
456 pClean = glob_create(zCleanFlag);
457 vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458 glob_free(pKeep);
459 glob_free(pIgnore);
460 db_prepare(&q,
461 "SELECT %Q || x FROM sfile"
462 " WHERE x NOT IN (%s)"
463
--- src/checkin.c
+++ src/checkin.c
@@ -300,14 +300,15 @@
300 db_finalize(&q);
301 }
302
303 /*
304 ** COMMAND: extras
305 ** Usage: %fossil extras ?OPTIONS? ?PATH1 ...?
306 **
307 ** Print a list of all files in the source tree that are not part of
308 ** the current checkout. See also the "clean" command. If paths are
309 ** specified, only files in the given directories will be listed.
310 **
311 ** Files and subdirectories whose names begin with "." are normally
312 ** ignored but can be included by adding the --dotfiles option.
313 **
314 ** The GLOBPATTERN is a comma-separated list of GLOB expressions for
@@ -328,11 +329,11 @@
329 ** See also: changes, clean, status
330 */
331 void extra_cmd(void){
332 Blob path;
333 Stmt q;
334 int n, i;
335 const char *zIgnoreFlag = find_option("ignore",0,1);
336 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
337 int cwdRelative = 0;
338 Glob *pIgnore;
339 Blob rewrittenPathname;
@@ -348,11 +349,37 @@
349 blob_init(&path, g.zLocalRoot, n-1);
350 if( zIgnoreFlag==0 ){
351 zIgnoreFlag = db_get("ignore-glob", 0);
352 }
353 pIgnore = glob_create(zIgnoreFlag);
354
355 /* Load the names of all files that are candidates to be listed into sfile temp table */
356 if( g.argc < 3 ){
357 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
358 }
359 for( i=2; i<g.argc; i++ ){
360 char *zName;
361 int isDir;
362 Blob fullName;
363
364 file_canonical_name(g.argv[i], &fullName, 0);
365 zName = blob_str(&fullName);
366 isDir = file_wd_isdir(zName);
367 if( isDir==1 ){
368 vfile_scan(&fullName, n-1, scanFlags, pIgnore);
369 }else if( isDir==0 ){
370 fossil_warning("not found: %s", zName);
371 }else if( file_access(zName, R_OK) ){
372 fossil_fatal("cannot open %s", zName);
373 }else{
374 db_multi_exec(
375 "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
376 &zName[n]
377 );
378 }
379 blob_reset(&fullName);
380 }
381 glob_free(pIgnore);
382 db_prepare(&q,
383 "SELECT x FROM sfile"
384 " WHERE x NOT IN (%s)"
385 " ORDER BY 1",
@@ -377,15 +404,16 @@
404 db_finalize(&q);
405 }
406
407 /*
408 ** COMMAND: clean
409 ** Usage: %fossil clean ?OPTIONS? ?PATH1 ...?
410 **
411 ** Delete all "extra" files in the source tree. "Extra" files are
412 ** files that are not officially part of the checkout. This operation
413 ** cannot be undone. If paths are specified, only the directories or
414 ** files specified will be considered for cleaning.
415 **
416 ** You will be prompted before removing each eligible file unless the
417 ** --force flag is in use or it matches the --clean option. The
418 ** GLOBPATTERN specified by the "ignore-glob" setting is used if the
419 ** --ignore option is omitted, the same with "clean-glob" and --clean
@@ -419,11 +447,11 @@
447 int allFlag, dryRunFlag, verboseFlag;
448 unsigned scanFlags = 0;
449 const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
450 Blob path, repo;
451 Stmt q;
452 int n, i;
453 Glob *pIgnore, *pKeep, *pClean;
454
455 dryRunFlag = find_option("dry-run","n",0)!=0;
456 if( !dryRunFlag ){
457 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
@@ -452,11 +480,37 @@
480 n = strlen(g.zLocalRoot);
481 blob_init(&path, g.zLocalRoot, n-1);
482 pIgnore = glob_create(zIgnoreFlag);
483 pKeep = glob_create(zKeepFlag);
484 pClean = glob_create(zCleanFlag);
485
486 /* Load the names of all files that are candidates to be cleaned into sfile temp table */
487 if( g.argc < 3 ){
488 vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep);
489 }
490 for( i=2; i<g.argc; i++ ){
491 char *zName;
492 int isDir;
493 Blob fullName;
494
495 file_canonical_name(g.argv[i], &fullName, 0);
496 zName = blob_str(&fullName);
497 isDir = file_wd_isdir(zName);
498 if( isDir==1 ){
499 vfile_scan2(&fullName, n-1, scanFlags, pIgnore, pKeep);
500 }else if( isDir==0 ){
501 fossil_warning("not found: %s", zName);
502 }else if( file_access(zName, R_OK) ){
503 fossil_fatal("cannot open %s", zName);
504 }else{
505 db_multi_exec(
506 "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
507 &zName[n]
508 );
509 }
510 blob_reset(&fullName);
511 }
512 glob_free(pKeep);
513 glob_free(pIgnore);
514 db_prepare(&q,
515 "SELECT %Q || x FROM sfile"
516 " WHERE x NOT IN (%s)"
517
+62 -8
--- src/checkin.c
+++ src/checkin.c
@@ -300,14 +300,15 @@
300300
db_finalize(&q);
301301
}
302302
303303
/*
304304
** COMMAND: extras
305
-** Usage: %fossil extras ?OPTIONS?
305
+** Usage: %fossil extras ?OPTIONS? ?PATH1 ...?
306306
**
307307
** Print a list of all files in the source tree that are not part of
308
-** the current checkout. See also the "clean" command.
308
+** the current checkout. See also the "clean" command. If paths are
309
+** specified, only files in the given directories will be listed.
309310
**
310311
** Files and subdirectories whose names begin with "." are normally
311312
** ignored but can be included by adding the --dotfiles option.
312313
**
313314
** The GLOBPATTERN is a comma-separated list of GLOB expressions for
@@ -328,11 +329,11 @@
328329
** See also: changes, clean, status
329330
*/
330331
void extra_cmd(void){
331332
Blob path;
332333
Stmt q;
333
- int n;
334
+ int n, i;
334335
const char *zIgnoreFlag = find_option("ignore",0,1);
335336
unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
336337
int cwdRelative = 0;
337338
Glob *pIgnore;
338339
Blob rewrittenPathname;
@@ -348,11 +349,37 @@
348349
blob_init(&path, g.zLocalRoot, n-1);
349350
if( zIgnoreFlag==0 ){
350351
zIgnoreFlag = db_get("ignore-glob", 0);
351352
}
352353
pIgnore = glob_create(zIgnoreFlag);
353
- vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
354
+
355
+ /* Load the names of all files that are candidates to be listed into sfile temp table */
356
+ if( g.argc < 3 ){
357
+ vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
358
+ }
359
+ for( i=2; i<g.argc; i++ ){
360
+ char *zName;
361
+ int isDir;
362
+ Blob fullName;
363
+
364
+ file_canonical_name(g.argv[i], &fullName, 0);
365
+ zName = blob_str(&fullName);
366
+ isDir = file_wd_isdir(zName);
367
+ if( isDir==1 ){
368
+ vfile_scan(&fullName, n-1, scanFlags, pIgnore);
369
+ }else if( isDir==0 ){
370
+ fossil_warning("not found: %s", zName);
371
+ }else if( file_access(zName, R_OK) ){
372
+ fossil_fatal("cannot open %s", zName);
373
+ }else{
374
+ db_multi_exec(
375
+ "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
376
+ &zName[n]
377
+ );
378
+ }
379
+ blob_reset(&fullName);
380
+ }
354381
glob_free(pIgnore);
355382
db_prepare(&q,
356383
"SELECT x FROM sfile"
357384
" WHERE x NOT IN (%s)"
358385
" ORDER BY 1",
@@ -377,15 +404,16 @@
377404
db_finalize(&q);
378405
}
379406
380407
/*
381408
** COMMAND: clean
382
-** Usage: %fossil clean ?OPTIONS?
409
+** Usage: %fossil clean ?OPTIONS? ?PATH1 ...?
383410
**
384411
** Delete all "extra" files in the source tree. "Extra" files are
385412
** files that are not officially part of the checkout. This operation
386
-** cannot be undone.
413
+** cannot be undone. If paths are specified, only the directories or
414
+** files specified will be considered for cleaning.
387415
**
388416
** You will be prompted before removing each eligible file unless the
389417
** --force flag is in use or it matches the --clean option. The
390418
** GLOBPATTERN specified by the "ignore-glob" setting is used if the
391419
** --ignore option is omitted, the same with "clean-glob" and --clean
@@ -419,11 +447,11 @@
419447
int allFlag, dryRunFlag, verboseFlag;
420448
unsigned scanFlags = 0;
421449
const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
422450
Blob path, repo;
423451
Stmt q;
424
- int n;
452
+ int n, i;
425453
Glob *pIgnore, *pKeep, *pClean;
426454
427455
dryRunFlag = find_option("dry-run","n",0)!=0;
428456
if( !dryRunFlag ){
429457
dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
@@ -452,11 +480,37 @@
452480
n = strlen(g.zLocalRoot);
453481
blob_init(&path, g.zLocalRoot, n-1);
454482
pIgnore = glob_create(zIgnoreFlag);
455483
pKeep = glob_create(zKeepFlag);
456484
pClean = glob_create(zCleanFlag);
457
- vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep);
485
+
486
+ /* Load the names of all files that are candidates to be cleaned into sfile temp table */
487
+ if( g.argc < 3 ){
488
+ vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep);
489
+ }
490
+ for( i=2; i<g.argc; i++ ){
491
+ char *zName;
492
+ int isDir;
493
+ Blob fullName;
494
+
495
+ file_canonical_name(g.argv[i], &fullName, 0);
496
+ zName = blob_str(&fullName);
497
+ isDir = file_wd_isdir(zName);
498
+ if( isDir==1 ){
499
+ vfile_scan2(&fullName, n-1, scanFlags, pIgnore, pKeep);
500
+ }else if( isDir==0 ){
501
+ fossil_warning("not found: %s", zName);
502
+ }else if( file_access(zName, R_OK) ){
503
+ fossil_fatal("cannot open %s", zName);
504
+ }else{
505
+ db_multi_exec(
506
+ "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
507
+ &zName[n]
508
+ );
509
+ }
510
+ blob_reset(&fullName);
511
+ }
458512
glob_free(pKeep);
459513
glob_free(pIgnore);
460514
db_prepare(&q,
461515
"SELECT %Q || x FROM sfile"
462516
" WHERE x NOT IN (%s)"
463517
--- src/checkin.c
+++ src/checkin.c
@@ -300,14 +300,15 @@
300 db_finalize(&q);
301 }
302
303 /*
304 ** COMMAND: extras
305 ** Usage: %fossil extras ?OPTIONS?
306 **
307 ** Print a list of all files in the source tree that are not part of
308 ** the current checkout. See also the "clean" command.
 
309 **
310 ** Files and subdirectories whose names begin with "." are normally
311 ** ignored but can be included by adding the --dotfiles option.
312 **
313 ** The GLOBPATTERN is a comma-separated list of GLOB expressions for
@@ -328,11 +329,11 @@
328 ** See also: changes, clean, status
329 */
330 void extra_cmd(void){
331 Blob path;
332 Stmt q;
333 int n;
334 const char *zIgnoreFlag = find_option("ignore",0,1);
335 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
336 int cwdRelative = 0;
337 Glob *pIgnore;
338 Blob rewrittenPathname;
@@ -348,11 +349,37 @@
348 blob_init(&path, g.zLocalRoot, n-1);
349 if( zIgnoreFlag==0 ){
350 zIgnoreFlag = db_get("ignore-glob", 0);
351 }
352 pIgnore = glob_create(zIgnoreFlag);
353 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354 glob_free(pIgnore);
355 db_prepare(&q,
356 "SELECT x FROM sfile"
357 " WHERE x NOT IN (%s)"
358 " ORDER BY 1",
@@ -377,15 +404,16 @@
377 db_finalize(&q);
378 }
379
380 /*
381 ** COMMAND: clean
382 ** Usage: %fossil clean ?OPTIONS?
383 **
384 ** Delete all "extra" files in the source tree. "Extra" files are
385 ** files that are not officially part of the checkout. This operation
386 ** cannot be undone.
 
387 **
388 ** You will be prompted before removing each eligible file unless the
389 ** --force flag is in use or it matches the --clean option. The
390 ** GLOBPATTERN specified by the "ignore-glob" setting is used if the
391 ** --ignore option is omitted, the same with "clean-glob" and --clean
@@ -419,11 +447,11 @@
419 int allFlag, dryRunFlag, verboseFlag;
420 unsigned scanFlags = 0;
421 const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
422 Blob path, repo;
423 Stmt q;
424 int n;
425 Glob *pIgnore, *pKeep, *pClean;
426
427 dryRunFlag = find_option("dry-run","n",0)!=0;
428 if( !dryRunFlag ){
429 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
@@ -452,11 +480,37 @@
452 n = strlen(g.zLocalRoot);
453 blob_init(&path, g.zLocalRoot, n-1);
454 pIgnore = glob_create(zIgnoreFlag);
455 pKeep = glob_create(zKeepFlag);
456 pClean = glob_create(zCleanFlag);
457 vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458 glob_free(pKeep);
459 glob_free(pIgnore);
460 db_prepare(&q,
461 "SELECT %Q || x FROM sfile"
462 " WHERE x NOT IN (%s)"
463
--- src/checkin.c
+++ src/checkin.c
@@ -300,14 +300,15 @@
300 db_finalize(&q);
301 }
302
303 /*
304 ** COMMAND: extras
305 ** Usage: %fossil extras ?OPTIONS? ?PATH1 ...?
306 **
307 ** Print a list of all files in the source tree that are not part of
308 ** the current checkout. See also the "clean" command. If paths are
309 ** specified, only files in the given directories will be listed.
310 **
311 ** Files and subdirectories whose names begin with "." are normally
312 ** ignored but can be included by adding the --dotfiles option.
313 **
314 ** The GLOBPATTERN is a comma-separated list of GLOB expressions for
@@ -328,11 +329,11 @@
329 ** See also: changes, clean, status
330 */
331 void extra_cmd(void){
332 Blob path;
333 Stmt q;
334 int n, i;
335 const char *zIgnoreFlag = find_option("ignore",0,1);
336 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
337 int cwdRelative = 0;
338 Glob *pIgnore;
339 Blob rewrittenPathname;
@@ -348,11 +349,37 @@
349 blob_init(&path, g.zLocalRoot, n-1);
350 if( zIgnoreFlag==0 ){
351 zIgnoreFlag = db_get("ignore-glob", 0);
352 }
353 pIgnore = glob_create(zIgnoreFlag);
354
355 /* Load the names of all files that are candidates to be listed into sfile temp table */
356 if( g.argc < 3 ){
357 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
358 }
359 for( i=2; i<g.argc; i++ ){
360 char *zName;
361 int isDir;
362 Blob fullName;
363
364 file_canonical_name(g.argv[i], &fullName, 0);
365 zName = blob_str(&fullName);
366 isDir = file_wd_isdir(zName);
367 if( isDir==1 ){
368 vfile_scan(&fullName, n-1, scanFlags, pIgnore);
369 }else if( isDir==0 ){
370 fossil_warning("not found: %s", zName);
371 }else if( file_access(zName, R_OK) ){
372 fossil_fatal("cannot open %s", zName);
373 }else{
374 db_multi_exec(
375 "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
376 &zName[n]
377 );
378 }
379 blob_reset(&fullName);
380 }
381 glob_free(pIgnore);
382 db_prepare(&q,
383 "SELECT x FROM sfile"
384 " WHERE x NOT IN (%s)"
385 " ORDER BY 1",
@@ -377,15 +404,16 @@
404 db_finalize(&q);
405 }
406
407 /*
408 ** COMMAND: clean
409 ** Usage: %fossil clean ?OPTIONS? ?PATH1 ...?
410 **
411 ** Delete all "extra" files in the source tree. "Extra" files are
412 ** files that are not officially part of the checkout. This operation
413 ** cannot be undone. If paths are specified, only the directories or
414 ** files specified will be considered for cleaning.
415 **
416 ** You will be prompted before removing each eligible file unless the
417 ** --force flag is in use or it matches the --clean option. The
418 ** GLOBPATTERN specified by the "ignore-glob" setting is used if the
419 ** --ignore option is omitted, the same with "clean-glob" and --clean
@@ -419,11 +447,11 @@
447 int allFlag, dryRunFlag, verboseFlag;
448 unsigned scanFlags = 0;
449 const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
450 Blob path, repo;
451 Stmt q;
452 int n, i;
453 Glob *pIgnore, *pKeep, *pClean;
454
455 dryRunFlag = find_option("dry-run","n",0)!=0;
456 if( !dryRunFlag ){
457 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
@@ -452,11 +480,37 @@
480 n = strlen(g.zLocalRoot);
481 blob_init(&path, g.zLocalRoot, n-1);
482 pIgnore = glob_create(zIgnoreFlag);
483 pKeep = glob_create(zKeepFlag);
484 pClean = glob_create(zCleanFlag);
485
486 /* Load the names of all files that are candidates to be cleaned into sfile temp table */
487 if( g.argc < 3 ){
488 vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep);
489 }
490 for( i=2; i<g.argc; i++ ){
491 char *zName;
492 int isDir;
493 Blob fullName;
494
495 file_canonical_name(g.argv[i], &fullName, 0);
496 zName = blob_str(&fullName);
497 isDir = file_wd_isdir(zName);
498 if( isDir==1 ){
499 vfile_scan2(&fullName, n-1, scanFlags, pIgnore, pKeep);
500 }else if( isDir==0 ){
501 fossil_warning("not found: %s", zName);
502 }else if( file_access(zName, R_OK) ){
503 fossil_fatal("cannot open %s", zName);
504 }else{
505 db_multi_exec(
506 "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
507 &zName[n]
508 );
509 }
510 blob_reset(&fullName);
511 }
512 glob_free(pKeep);
513 glob_free(pIgnore);
514 db_prepare(&q,
515 "SELECT %Q || x FROM sfile"
516 " WHERE x NOT IN (%s)"
517

Keyboard Shortcuts

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