Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch enhancedUndo Through [1a4bcadde0] Excluding Merge-Ins
This is equivalent to a diff from 2c741dec46 to 1a4bcadde0
|
2015-07-08
| ||
| 16:25 | Update the built-in SQLite to the 3.8.11 alpha that includes the pcache1 preallocation enhancement. check-in: 8fb4269a31 user: drh tags: trunk | |
|
2015-07-06
| ||
| 21:56 | Small grammar fix in comment. check-in: 45c7dbb81e user: mistachkin tags: enhancedUndo | |
|
2015-07-04
| ||
| 06:05 | Merge updates from trunk. check-in: 1a4bcadde0 user: mistachkin tags: enhancedUndo | |
| 06:03 | Update 'all clean' command with the --disable-undo and --no-prompt options. check-in: 3e22d93b68 user: mistachkin tags: enhancedUndo | |
| 06:01 | Update and tweak help text. check-in: 2c741dec46 user: mistachkin tags: trunk | |
| 05:47 | added missing "all cache" docs. check-in: 2f0533fe4a user: stephan tags: trunk | |
Changes to src/allrepo.c.
| ︙ | ︙ | |||
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
useCheckouts = find_option("ckout","c",0)!=0;
}else if( strncmp(zCmd, "clean", n)==0 ){
zCmd = "clean --chdir";
collect_argument(&extra, "allckouts",0);
collect_argument_value(&extra, "case-sensitive");
collect_argument_value(&extra, "clean");
collect_argument(&extra, "dirsonly",0);
collect_argument(&extra, "dotfiles",0);
collect_argument(&extra, "emptydirs",0);
collect_argument(&extra, "force","f");
collect_argument_value(&extra, "ignore");
collect_argument_value(&extra, "keep");
collect_argument(&extra, "temp",0);
collect_argument(&extra, "verbose","v");
collect_argument(&extra, "whatif",0);
useCheckouts = 1;
}else if( strncmp(zCmd, "dbstat", n)==0 ){
zCmd = "dbstat --omit-version-info -R";
showLabel = 1;
| > > | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
useCheckouts = find_option("ckout","c",0)!=0;
}else if( strncmp(zCmd, "clean", n)==0 ){
zCmd = "clean --chdir";
collect_argument(&extra, "allckouts",0);
collect_argument_value(&extra, "case-sensitive");
collect_argument_value(&extra, "clean");
collect_argument(&extra, "dirsonly",0);
collect_argument(&extra, "disable-undo",0);
collect_argument(&extra, "dotfiles",0);
collect_argument(&extra, "emptydirs",0);
collect_argument(&extra, "force","f");
collect_argument_value(&extra, "ignore");
collect_argument_value(&extra, "keep");
collect_argument(&extra, "no-prompt",0);
collect_argument(&extra, "temp",0);
collect_argument(&extra, "verbose","v");
collect_argument(&extra, "whatif",0);
useCheckouts = 1;
}else if( strncmp(zCmd, "dbstat", n)==0 ){
zCmd = "dbstat --omit-version-info -R";
showLabel = 1;
|
| ︙ | ︙ |
Changes to src/checkin.c.
| ︙ | ︙ | |||
642 643 644 645 646 647 648 | ** values for --clean, --ignore, and --keep are determined by the ** (versionable) clean-glob, ignore-glob, and keep-glob settings. ** Files and subdirectories whose names begin with "." are automatically ** ignored unless the --dotfiles option is used. ** ** The --verily option ignores the keep-glob and ignore-glob settings ** and turns on --force, --dotfiles, and --emptydirs. Use the --verily | | > > > > | | > > > > | | > > | > > > > > > > > > > > | 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 |
** values for --clean, --ignore, and --keep are determined by the
** (versionable) clean-glob, ignore-glob, and keep-glob settings.
** Files and subdirectories whose names begin with "." are automatically
** ignored unless the --dotfiles option is used.
**
** The --verily option ignores the keep-glob and ignore-glob settings
** and turns on --force, --dotfiles, and --emptydirs. Use the --verily
** option when you really want to clean up everything. Extreme care
** should be exercised when using the --verily option.
**
** Options:
** --allckouts Check for empty directories within any checkouts
** that may be nested within the current one. This
** option should be used with great care because the
** empty-dirs setting (and other applicable settings)
** belonging to the other repositories, if any, will
** not be checked.
** --case-sensitive <BOOL> override case-sensitive setting
** --dirsonly Only remove empty directories. No files will
** be removed. Using this option will automatically
** enable the --emptydirs option as well.
** --disable-undo WARNING: This option disables use of the undo
** mechanism for this clean operation and should be
** used with extreme caution.
** --dotfiles Include files beginning with a dot (".").
** --emptydirs Remove any empty directories that are not
** explicitly exempted via the empty-dirs setting
** or another applicable setting or command line
** argument. Matching files, if any, are removed
** prior to checking for any empty directories;
** therefore, directories that contain only files
** that were removed will be removed as well.
** -f|--force Remove files without prompting.
** -x|--verily WARNING: Remove everything that is not a managed
** file or the repository itself. This option
** implies the --force, --emptydirs, --dotfiles, and
** --disable-undo options. Furthermore, it completely
** disregards the keep-glob and ignore-glob settings.
** However, it does honor the --ignore and --keep
** options.
** --clean <CSG> WARNING: Never prompt to delete any files matching
** this comma separated list of glob patterns. Also,
** deletions of any files matching this pattern list
** cannot be undone.
** --ignore <CSG> Ignore files matching patterns from the
** comma separated list of glob patterns.
** --keep <CSG> Keep files matching this comma separated
** list of glob patterns.
** -n|--dry-run Delete nothing, but display what would have been
** deleted.
** --no-prompt This option disables prompting the user for input
** and assumes an answer of 'No' for every question.
** --temp Remove only Fossil-generated temporary files.
** -v|--verbose Show all files as they are removed.
**
** See also: addremove, extras, status
*/
void clean_cmd(void){
int allFileFlag, allDirFlag, dryRunFlag, verboseFlag;
int emptyDirsFlag, dirsOnlyFlag;
int disableUndo, noPrompt;
unsigned scanFlags = 0;
int verilyFlag = 0;
const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
Glob *pIgnore, *pKeep, *pClean;
int nRoot;
#ifndef UNDO_SIZE_LIMIT /* TODO: Setting? */
#define UNDO_SIZE_LIMIT (10*1024*1024) /* 10MiB */
#endif
undo_capture_command_line();
dryRunFlag = find_option("dry-run","n",0)!=0;
if( !dryRunFlag ){
dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
}
if( !dryRunFlag ){
dryRunFlag = find_option("whatif",0,0)!=0;
}
disableUndo = find_option("disable-undo",0,0)!=0;
noPrompt = find_option("no-prompt",0,0)!=0;
allFileFlag = allDirFlag = find_option("force","f",0)!=0;
dirsOnlyFlag = find_option("dirsonly",0,0)!=0;
emptyDirsFlag = find_option("emptydirs","d",0)!=0 || dirsOnlyFlag;
if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
if( find_option("allckouts",0,0)!=0 ) scanFlags |= SCAN_NESTED;
zIgnoreFlag = find_option("ignore",0,1);
verboseFlag = find_option("verbose","v",0)!=0;
zKeepFlag = find_option("keep",0,1);
zCleanFlag = find_option("clean",0,1);
db_must_be_within_tree();
if( find_option("verily","x",0)!=0 ){
verilyFlag = allFileFlag = allDirFlag = 1;
emptyDirsFlag = 1;
disableUndo = 1;
scanFlags |= SCAN_ALL;
zCleanFlag = 0;
}
if( zIgnoreFlag==0 && !verilyFlag ){
zIgnoreFlag = db_get("ignore-glob", 0);
}
if( zKeepFlag==0 && !verilyFlag ){
|
| ︙ | ︙ | |||
732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 |
pKeep = glob_create(zKeepFlag);
pClean = glob_create(zCleanFlag);
nRoot = (int)strlen(g.zLocalRoot);
g.allowSymlinks = 1; /* Find symlinks too */
if( !dirsOnlyFlag ){
Stmt q;
Blob repo;
locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore, 0);
db_prepare(&q,
"SELECT %Q || x FROM sfile"
" WHERE x NOT IN (%s)"
" ORDER BY 1",
g.zLocalRoot, fossil_all_reserved_names(0)
);
if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){
db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
}
db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
if( glob_match(pKeep, zName+nRoot) ){
if( verboseFlag ){
fossil_print("KEPT file \"%s\" not removed (due to --keep"
" or \"keep-glob\")\n", zName+nRoot);
}
continue;
}
| > | > > > > > > > > > | | > > | | | | > > > > | | | < | | < > > | 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 |
pKeep = glob_create(zKeepFlag);
pClean = glob_create(zCleanFlag);
nRoot = (int)strlen(g.zLocalRoot);
g.allowSymlinks = 1; /* Find symlinks too */
if( !dirsOnlyFlag ){
Stmt q;
Blob repo;
if( !dryRunFlag && !disableUndo ) undo_begin();
locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore, 0);
db_prepare(&q,
"SELECT %Q || x FROM sfile"
" WHERE x NOT IN (%s)"
" ORDER BY 1",
g.zLocalRoot, fossil_all_reserved_names(0)
);
if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){
db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
}
db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
if( glob_match(pKeep, zName+nRoot) ){
if( verboseFlag ){
fossil_print("KEPT file \"%s\" not removed (due to --keep"
" or \"keep-glob\")\n", zName+nRoot);
}
continue;
}
if( !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
int undoRc = UNDO_NONE;
if( !disableUndo ){
undoRc = undo_maybe_save(zName+nRoot, UNDO_SIZE_LIMIT);
}
if( undoRc!=UNDO_SAVED_OK ){
char cReply;
if( allFileFlag ){
cReply = 'Y';
}else if( !noPrompt ){
Blob ans;
char *prompt = mprintf("\nWARNING: Deletion of this file will "
"not be undoable via the 'undo'\n"
" command because %s.\n\n"
"Remove unmanaged file \"%s\" (a=all/y/N)? ",
undo_save_message(undoRc), zName+nRoot);
prompt_user(prompt, &ans);
cReply = blob_str(&ans)[0];
blob_reset(&ans);
}else{
cReply = 'N';
}
if( cReply=='a' || cReply=='A' ){
allFileFlag = 1;
}else if( cReply!='y' && cReply!='Y' ){
continue;
}
}
}
if( dryRunFlag || file_delete(zName)==0 ){
if( verboseFlag || dryRunFlag ){
fossil_print("Removed unmanaged file: %s\n", zName+nRoot);
}
}else if( verboseFlag ){
fossil_print("Could not remove file: %s\n", zName+nRoot);
}
}
db_finalize(&q);
if( !dryRunFlag && !disableUndo ) undo_finish();
}
if( emptyDirsFlag ){
Glob *pEmptyDirs = glob_create(db_get("empty-dirs", 0));
Stmt q;
Blob root;
blob_init(&root, g.zLocalRoot, nRoot - 1);
vfile_dir_scan(&root, blob_size(&root), scanFlags, pIgnore,
|
| ︙ | ︙ | |||
801 802 803 804 805 806 807 |
if( verboseFlag ){
fossil_print("KEPT directory \"%s\" not removed (due to --keep"
" or \"keep-glob\")\n", zName+nRoot);
}
continue;
}
if( !allDirFlag && !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
| < > > | | | | > > > > < < | 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 |
if( verboseFlag ){
fossil_print("KEPT directory \"%s\" not removed (due to --keep"
" or \"keep-glob\")\n", zName+nRoot);
}
continue;
}
if( !allDirFlag && !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
char cReply;
if( !noPrompt ){
Blob ans;
char *prompt = mprintf("Remove empty directory \"%s\" (a=all/y/N)? ",
zName+nRoot);
prompt_user(prompt, &ans);
cReply = blob_str(&ans)[0];
blob_reset(&ans);
}else{
cReply = 'N';
}
if( cReply=='a' || cReply=='A' ){
allDirFlag = 1;
}else if( cReply!='y' && cReply!='Y' ){
continue;
}
}
if( dryRunFlag || file_rmdir(zName)==0 ){
if( verboseFlag || dryRunFlag ){
fossil_print("Removed unmanaged directory: %s\n", zName+nRoot);
}
}else if( verboseFlag ){
fossil_print("Could not remove directory: %s\n", zName+nRoot);
|
| ︙ | ︙ |
Changes to src/undo.c.
| ︙ | ︙ | |||
16 17 18 19 20 21 22 | ******************************************************************************* ** ** This file implements the undo/redo functionality. */ #include "config.h" #include "undo.h" | | > > > > > > > > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ******************************************************************************* ** ** This file implements the undo/redo functionality. */ #include "config.h" #include "undo.h" #if INTERFACE /* ** Possible return values from the undo_maybe_save() routine. */ #define UNDO_NONE (0) /* Placeholder only used to initialize vars. */ #define UNDO_SAVED_OK (1) /* The specified file was saved succesfully. */ #define UNDO_INACTIVE (2) /* File not saved, subsystem is not active. */ #define UNDO_TOOBIG (3) /* File not saved, it exceeded a size limit. */ #endif /* ** Undo the change to the file zPathname. zPathname is the pathname ** of the file relative to the root of the repository. If redoFlag is ** true the redo a change. If there is nothing to undo (or redo) then ** this routine is a noop. */ |
| ︙ | ︙ | |||
259 260 261 262 263 264 265 266 |
/*
** Save the current content of the file zPathname so that it
** will be undoable. The name is relative to the root of the
** tree.
*/
void undo_save(const char *zPathname){
char *zFullname;
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < > | < | | > > | > > | | | | | | | | | | | | | | < | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
/*
** Save the current content of the file zPathname so that it
** will be undoable. The name is relative to the root of the
** tree.
*/
void undo_save(const char *zPathname){
if( undo_maybe_save(zPathname, -1)!=UNDO_SAVED_OK ){
fossil_panic("failed to save undo information for path: %s",
zPathname);
}
}
/*
** Possibly save the current content of the file zPathname so
** that it will be undoable. The name is relative to the root
** of the tree. The limit argument may be used to specify the
** maximum size for the file to be saved. If the size of the
** specified file exceeds this size limit (in bytes), it will
** not be saved and an appropriate code will be returned.
**
** WARNING: Please do NOT call this function with a limit
** value less than zero, call the undo_save()
** function instead.
**
** The return value of this function will always be one of the
** following codes:
**
** UNDO_SAVED_OK: The specified file was saved succesfully.
**
** UNDO_INACTIVE: The specified file was NOT saved, because the
** "undo subsystem" is not active. This error
** may indicate that a call to undo_begin() is
** missing.
**
** UNDO_TOOBIG: The specified file was NOT saved, because it
** exceeded the specified size limit. It is
** impossible for this value to be returned if
** the specified size limit is less than zero
** (i.e. unlimited).
*/
int undo_maybe_save(const char *zPathname, i64 limit){
char *zFullname;
i64 size;
int result;
if( !undoActive ) return UNDO_INACTIVE;
zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
size = file_wd_size(zFullname);
if( limit<0 || size<=limit ){
int existsFlag = (size>=0);
int isLink = file_wd_islink(zFullname);
Stmt q;
Blob content;
db_prepare(&q,
"INSERT OR IGNORE INTO"
" undo(pathname,redoflag,existsflag,isExe,isLink,content)"
" VALUES(%Q,0,%d,%d,%d,:c)",
zPathname, existsFlag, file_wd_isexe(zFullname), isLink
);
if( existsFlag ){
if( isLink ){
blob_read_link(&content, zFullname);
}else{
blob_read_from_file(&content, zFullname);
}
db_bind_blob(&q, ":c", &content);
}
db_step(&q);
db_finalize(&q);
if( existsFlag ){
blob_reset(&content);
}
undoNeedRollback = 1;
result = UNDO_SAVED_OK;
}else{
result = UNDO_TOOBIG;
}
free(zFullname);
return result;
}
/*
** Returns an error message for the undo_maybe_save() return code.
** Currently, this function assumes that the caller is using the
** returned error message in a context prefixed with "because".
*/
const char *undo_save_message(int rc){
static char zRc[32];
switch( rc ){
case UNDO_NONE: return "undo is disabled for this operation";
case UNDO_SAVED_OK: return "the save operation was successful";
case UNDO_INACTIVE: return "the undo subsystem is inactive";
case UNDO_TOOBIG: return "the file is too big";
default: {
sqlite3_snprintf(sizeof(zRc), zRc, "of error code %d", rc);
}
}
return zRc;
}
/*
** Make the current state of stashid undoable.
*/
void undo_save_stash(int stashid){
const char *zDb = db_name("localdb");
|
| ︙ | ︙ | |||
359 360 361 362 363 364 365 366 367 368 369 370 371 372 | ** Undo the changes to the working checkout caused by the most recent ** of the following operations: ** ** (1) fossil update (5) fossil stash apply ** (2) fossil merge (6) fossil stash drop ** (3) fossil revert (7) fossil stash goto ** (4) fossil stash pop ** ** If FILENAME is specified then restore the content of the named ** file(s) but otherwise leave the update or merge or revert in effect. ** The redo command undoes the effect of the most recent undo. ** ** If the -n|--dry-run option is present, no changes are made and instead ** the undo or redo command explains what actions the undo or redo would | > > > | 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | ** Undo the changes to the working checkout caused by the most recent ** of the following operations: ** ** (1) fossil update (5) fossil stash apply ** (2) fossil merge (6) fossil stash drop ** (3) fossil revert (7) fossil stash goto ** (4) fossil stash pop ** ** The "fossil clean" operation can also be undone; however, this is ** currently limited to files that are less than 10MiB in size. ** ** If FILENAME is specified then restore the content of the named ** file(s) but otherwise leave the update or merge or revert in effect. ** The redo command undoes the effect of the most recent undo. ** ** If the -n|--dry-run option is present, no changes are made and instead ** the undo or redo command explains what actions the undo or redo would |
| ︙ | ︙ |
Added test/clean.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
#
# Copyright (c) 2015 D. Richard Hipp
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the Simplified BSD License (also
# known as the "2-Clause License" or "FreeBSD License".)
#
# This program is distributed in the hope that it will be useful,
# but without any warranty; without even the implied warranty of
# merchantability or fitness for a particular purpose.
#
# Author contact information:
# drh@hwaci.com
# http://www.hwaci.com/drh/
#
############################################################################
#
# Tests of the "clean" command, including the ability to undo it.
#
repo_init
###############################################################################
fossil extra
test clean-0 {[normalize_result] eq {}}
###############################################################################
write_file f1 "f1 line"
fossil add f1
fossil commit -m "base file"
fossil ls
test clean-1 {[normalize_result] eq {f1}}
###############################################################################
fossil extra
test clean-2 {[normalize_result] eq {}}
###############################################################################
write_file f2 "f2 line"
fossil extra
test clean-3 {[normalize_result] eq {f2}}
###############################################################################
# clean w/undo enabled, should not prompt, 1 file < 10MiB
fossil clean
test clean-4 {[normalize_result] eq \
{"fossil undo" is available to undo changes to the working checkout.}}
###############################################################################
fossil extra
test clean-5 {[normalize_result] eq {}}
###############################################################################
fossil undo
test clean-6 {[normalize_result] eq {NEW f2}}
test clean-7 {[read_file f2] eq "f2 line"}
###############################################################################
fossil extra
test clean-8 {[normalize_result] eq {f2}}
###############################################################################
write_file f3 [string repeat ABCDEFGHIJK 1048576]
fossil extra
test clean-9 {[normalize_result] eq {f2
f3}}
###############################################################################
# clean w/undo enabled, no prompt, 1 file < 10MiB, 1 file > 10MiB
fossil clean --no-prompt
test clean-10 {[normalize_result] eq \
{"fossil undo" is available to undo changes to the working checkout.}}
###############################################################################
fossil extra
test clean-11 {[normalize_result] eq {f3}}
###############################################################################
fossil undo
test clean-12 {[normalize_result] eq {NEW f2}}
test clean-13 {[read_file f2] eq "f2 line"}
test clean-14 {[read_file f3] eq [string repeat ABCDEFGHIJK 1048576]}
###############################################################################
fossil extra
test clean-15 {[normalize_result] eq {f2
f3}}
###############################################################################
# clean w/undo enabled, force, 1 file < 10MiB, 1 file > 10MiB
fossil clean --force
test clean-16 {[normalize_result] eq \
{"fossil undo" is available to undo changes to the working checkout.}}
###############################################################################
fossil extra
test clean-17 {[normalize_result] eq {}}
###############################################################################
fossil undo
test clean-18 {[normalize_result] eq {NEW f2}}
test clean-19 {[read_file f2] eq "f2 line"}
###############################################################################
write_file f4 [string repeat KJIHGFEDCBA 1048576]
fossil extra
test clean-20 {[normalize_result] eq {f2
f4}}
###############################################################################
# clean w/undo disabled, no prompt, 1 file < 10MiB, 1 file > 10MiB
fossil clean --disable-undo --no-prompt
test clean-21 {[normalize_result] eq {}}
###############################################################################
fossil extra
test clean-22 {[normalize_result] eq {f2
f4}}
###############################################################################
fossil undo
test clean-23 {[normalize_result] eq {nothing to undo}}
###############################################################################
# clean w/undo disabled, force, 1 file < 10MiB, 1 file > 10MiB
fossil clean --disable-undo --force
test clean-24 {[normalize_result] eq {}}
###############################################################################
fossil extra
test clean-25 {[normalize_result] eq {}}
###############################################################################
fossil undo
test clean-26 {[normalize_result] eq {nothing to undo}}
###############################################################################
write_file f5 "f5 line"
fossil extra
test clean-27 {[normalize_result] eq {f5}}
###############################################################################
# clean w/undo disabled, should prompt, 1 file < 10MiB
fossil_maybe_answer Y clean --disable-undo
test clean-28 {[normalize_result] eq \
{WARNING: Deletion of this file will not be undoable via the 'undo'
command because undo is disabled for this operation.
Remove unmanaged file "f5" (a=all/y/N)?}}
###############################################################################
fossil extra
test clean-29 {[normalize_result] eq {}}
###############################################################################
fossil undo
test clean-30 {[normalize_result] eq {nothing to undo}}
###############################################################################
fossil extra
test clean-31 {[normalize_result] eq {}}
|
Changes to test/tester.tcl.
| ︙ | ︙ | |||
85 86 87 88 89 90 91 |
set out [open [file join $::testrundir prot] a]
fconfigure $out -translation platform
puts $out $msg
close $out
}
}
| | > > > > > > > > > > > > > > > > > > > > > > > | > | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
set out [open [file join $::testrundir prot] a]
fconfigure $out -translation platform
puts $out $msg
close $out
}
}
# Run the Fossil program with the specified arguments.
#
# Consults the VERBOSE global variable to determine if
# diagnostics should be emitted when no error is seen.
# Sets the CODE and RESULT global variables for use in
# test expressions.
#
proc fossil {args} {
return [uplevel 1 fossil_maybe_answer [list ""] $args]
}
# Run the Fossil program with the specified arguments
# and possibly answer the first prompt, if any.
#
# Consults the VERBOSE global variable to determine if
# diagnostics should be emitted when no error is seen.
# Sets the CODE and RESULT global variables for use in
# test expressions.
#
proc fossil_maybe_answer {answer args} {
global fossilexe
set cmd $fossilexe
foreach a $args {
lappend cmd $a
}
protOut $cmd
flush stdout
if {[string length $answer] > 0} {
set prompt_file [file join $::tempPath fossil_prompt_answer]
write_file $prompt_file $answer\n
set rc [catch {eval exec $cmd <$prompt_file} result]
file delete $prompt_file
} else {
set rc [catch {eval exec $cmd} result]
}
global RESULT CODE
set CODE $rc
if {$rc} {
protOut "ERROR: $result"
} elseif {$::VERBOSE} {
protOut "RESULT: $result"
}
|
| ︙ | ︙ |