Fossil SCM
rebase
Commit
4279e6465abb571e9159d042924d2a0645766155
Parent
c107d5059640b0e…
2 files changed
+62
-8
+62
-8
+62
-8
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -300,14 +300,15 @@ | ||
| 300 | 300 | db_finalize(&q); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /* |
| 304 | 304 | ** COMMAND: extras |
| 305 | -** Usage: %fossil extras ?OPTIONS? | |
| 305 | +** Usage: %fossil extras ?OPTIONS? ?PATH1 ...? | |
| 306 | 306 | ** |
| 307 | 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. | |
| 308 | +** the current checkout. See also the "clean" command. If paths are | |
| 309 | +** specified, only files in the given directories will be listed. | |
| 309 | 310 | ** |
| 310 | 311 | ** Files and subdirectories whose names begin with "." are normally |
| 311 | 312 | ** ignored but can be included by adding the --dotfiles option. |
| 312 | 313 | ** |
| 313 | 314 | ** The GLOBPATTERN is a comma-separated list of GLOB expressions for |
| @@ -328,11 +329,11 @@ | ||
| 328 | 329 | ** See also: changes, clean, status |
| 329 | 330 | */ |
| 330 | 331 | void extra_cmd(void){ |
| 331 | 332 | Blob path; |
| 332 | 333 | Stmt q; |
| 333 | - int n; | |
| 334 | + int n, i; | |
| 334 | 335 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 335 | 336 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 336 | 337 | int cwdRelative = 0; |
| 337 | 338 | Glob *pIgnore; |
| 338 | 339 | Blob rewrittenPathname; |
| @@ -348,11 +349,37 @@ | ||
| 348 | 349 | blob_init(&path, g.zLocalRoot, n-1); |
| 349 | 350 | if( zIgnoreFlag==0 ){ |
| 350 | 351 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 351 | 352 | } |
| 352 | 353 | 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 | + } | |
| 354 | 381 | glob_free(pIgnore); |
| 355 | 382 | db_prepare(&q, |
| 356 | 383 | "SELECT x FROM sfile" |
| 357 | 384 | " WHERE x NOT IN (%s)" |
| 358 | 385 | " ORDER BY 1", |
| @@ -377,15 +404,16 @@ | ||
| 377 | 404 | db_finalize(&q); |
| 378 | 405 | } |
| 379 | 406 | |
| 380 | 407 | /* |
| 381 | 408 | ** COMMAND: clean |
| 382 | -** Usage: %fossil clean ?OPTIONS? | |
| 409 | +** Usage: %fossil clean ?OPTIONS? ?PATH1 ...? | |
| 383 | 410 | ** |
| 384 | 411 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 385 | 412 | ** 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. | |
| 387 | 415 | ** |
| 388 | 416 | ** You will be prompted before removing each eligible file unless the |
| 389 | 417 | ** --force flag is in use or it matches the --clean option. The |
| 390 | 418 | ** GLOBPATTERN specified by the "ignore-glob" setting is used if the |
| 391 | 419 | ** --ignore option is omitted, the same with "clean-glob" and --clean |
| @@ -419,11 +447,11 @@ | ||
| 419 | 447 | int allFlag, dryRunFlag, verboseFlag; |
| 420 | 448 | unsigned scanFlags = 0; |
| 421 | 449 | const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag; |
| 422 | 450 | Blob path, repo; |
| 423 | 451 | Stmt q; |
| 424 | - int n; | |
| 452 | + int n, i; | |
| 425 | 453 | Glob *pIgnore, *pKeep, *pClean; |
| 426 | 454 | |
| 427 | 455 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 428 | 456 | if( !dryRunFlag ){ |
| 429 | 457 | dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ |
| @@ -452,11 +480,37 @@ | ||
| 452 | 480 | n = strlen(g.zLocalRoot); |
| 453 | 481 | blob_init(&path, g.zLocalRoot, n-1); |
| 454 | 482 | pIgnore = glob_create(zIgnoreFlag); |
| 455 | 483 | pKeep = glob_create(zKeepFlag); |
| 456 | 484 | 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 | + } | |
| 458 | 512 | glob_free(pKeep); |
| 459 | 513 | glob_free(pIgnore); |
| 460 | 514 | db_prepare(&q, |
| 461 | 515 | "SELECT %Q || x FROM sfile" |
| 462 | 516 | " WHERE x NOT IN (%s)" |
| 463 | 517 |
| --- 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 @@ | ||
| 300 | 300 | db_finalize(&q); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /* |
| 304 | 304 | ** COMMAND: extras |
| 305 | -** Usage: %fossil extras ?OPTIONS? | |
| 305 | +** Usage: %fossil extras ?OPTIONS? ?PATH1 ...? | |
| 306 | 306 | ** |
| 307 | 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. | |
| 308 | +** the current checkout. See also the "clean" command. If paths are | |
| 309 | +** specified, only files in the given directories will be listed. | |
| 309 | 310 | ** |
| 310 | 311 | ** Files and subdirectories whose names begin with "." are normally |
| 311 | 312 | ** ignored but can be included by adding the --dotfiles option. |
| 312 | 313 | ** |
| 313 | 314 | ** The GLOBPATTERN is a comma-separated list of GLOB expressions for |
| @@ -328,11 +329,11 @@ | ||
| 328 | 329 | ** See also: changes, clean, status |
| 329 | 330 | */ |
| 330 | 331 | void extra_cmd(void){ |
| 331 | 332 | Blob path; |
| 332 | 333 | Stmt q; |
| 333 | - int n; | |
| 334 | + int n, i; | |
| 334 | 335 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 335 | 336 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 336 | 337 | int cwdRelative = 0; |
| 337 | 338 | Glob *pIgnore; |
| 338 | 339 | Blob rewrittenPathname; |
| @@ -348,11 +349,37 @@ | ||
| 348 | 349 | blob_init(&path, g.zLocalRoot, n-1); |
| 349 | 350 | if( zIgnoreFlag==0 ){ |
| 350 | 351 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 351 | 352 | } |
| 352 | 353 | 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 | + } | |
| 354 | 381 | glob_free(pIgnore); |
| 355 | 382 | db_prepare(&q, |
| 356 | 383 | "SELECT x FROM sfile" |
| 357 | 384 | " WHERE x NOT IN (%s)" |
| 358 | 385 | " ORDER BY 1", |
| @@ -377,15 +404,16 @@ | ||
| 377 | 404 | db_finalize(&q); |
| 378 | 405 | } |
| 379 | 406 | |
| 380 | 407 | /* |
| 381 | 408 | ** COMMAND: clean |
| 382 | -** Usage: %fossil clean ?OPTIONS? | |
| 409 | +** Usage: %fossil clean ?OPTIONS? ?PATH1 ...? | |
| 383 | 410 | ** |
| 384 | 411 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 385 | 412 | ** 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. | |
| 387 | 415 | ** |
| 388 | 416 | ** You will be prompted before removing each eligible file unless the |
| 389 | 417 | ** --force flag is in use or it matches the --clean option. The |
| 390 | 418 | ** GLOBPATTERN specified by the "ignore-glob" setting is used if the |
| 391 | 419 | ** --ignore option is omitted, the same with "clean-glob" and --clean |
| @@ -419,11 +447,11 @@ | ||
| 419 | 447 | int allFlag, dryRunFlag, verboseFlag; |
| 420 | 448 | unsigned scanFlags = 0; |
| 421 | 449 | const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag; |
| 422 | 450 | Blob path, repo; |
| 423 | 451 | Stmt q; |
| 424 | - int n; | |
| 452 | + int n, i; | |
| 425 | 453 | Glob *pIgnore, *pKeep, *pClean; |
| 426 | 454 | |
| 427 | 455 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 428 | 456 | if( !dryRunFlag ){ |
| 429 | 457 | dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ |
| @@ -452,11 +480,37 @@ | ||
| 452 | 480 | n = strlen(g.zLocalRoot); |
| 453 | 481 | blob_init(&path, g.zLocalRoot, n-1); |
| 454 | 482 | pIgnore = glob_create(zIgnoreFlag); |
| 455 | 483 | pKeep = glob_create(zKeepFlag); |
| 456 | 484 | 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 | + } | |
| 458 | 512 | glob_free(pKeep); |
| 459 | 513 | glob_free(pIgnore); |
| 460 | 514 | db_prepare(&q, |
| 461 | 515 | "SELECT %Q || x FROM sfile" |
| 462 | 516 | " WHERE x NOT IN (%s)" |
| 463 | 517 |
| --- 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 |