Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch rmdir-on-update Excluding Merge-Ins
This is equivalent to a diff from 70f30922 to 50995ed1
2019-02-27
| ||
19:12 | (cherry-pick): Fix a mysterious bug in is_ticket() that was preventing me from updating the TCL repository. ... (check-in: c460f943 user: jan.nijtmans tags: branch-2.8) | |
14:23 | For the "fossil update" and "fossil checkout" commands, if a managed file is removed because it is no longer part of the target check-in and the directory containing the file is empty after the file is removed and the directory is not the current working directory and is not on the empty-dirs list, then also remove the directory. ... (check-in: f132f86b user: drh tags: trunk) | |
12:57 | Merge the bug fix from trunk. ... (Closed-Leaf check-in: 50995ed1 user: drh tags: rmdir-on-update) | |
12:08 | Fix a mysterious bug in is_ticket() that was preventing me from updating the TCL repository. ... (check-in: 70f30922 user: drh tags: trunk) | |
2019-02-26
| ||
20:35 | Enhance the "fossil checkout" command to that it too cleans up directories that it makes empty. ... (check-in: 95b700c2 user: drh tags: rmdir-on-update) | |
2019-02-25
| ||
17:01 | Update the built-in SQLite to the latest trunk version that includes all of the fixes that were in the 3.27.2 release. ... (check-in: 4d608670 user: drh tags: trunk) | |
Changes to src/checkout.c.
︙ | ︙ | |||
37 38 39 40 41 42 43 44 45 | return db_exists("SELECT 1 FROM vfile WHERE chnged" " OR coalesce(origname!=pathname,0)"); } /* ** Undo the current check-out. Unlink all files from the disk. ** Clear the VFILE table. */ void uncheckout(int vid){ | > > > > > | > > > > > > > > > > > > > > | < > > > > > > > > > > > > > > > > > > > > | 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 | return db_exists("SELECT 1 FROM vfile WHERE chnged" " OR coalesce(origname!=pathname,0)"); } /* ** Undo the current check-out. Unlink all files from the disk. ** Clear the VFILE table. ** ** Also delete any directory that becomes empty as a result of deleting ** files due to this operation, as long as that directory is not the ** current working directory and is not on the empty-dirs list. */ void uncheckout(int vid){ char *zPwd; if( vid<=0 ) return; sqlite3_create_function(g.db, "dirname",1,SQLITE_UTF8,0, file_dirname_sql_function, 0, 0); sqlite3_create_function(g.db, "unlink",1,SQLITE_UTF8,0, file_delete_sql_function, 0, 0); sqlite3_create_function(g.db, "rmdir", 1, SQLITE_UTF8, 0, file_rmdir_sql_function, 0, 0); db_multi_exec( "CREATE TEMP TABLE dir_to_delete(name TEXT %s PRIMARY KEY)WITHOUT ROWID", filename_collation() ); db_multi_exec( "INSERT OR IGNORE INTO dir_to_delete(name)" " SELECT dirname(pathname) FROM vfile" " WHERE vid=%d AND mrid>0", vid ); do{ db_multi_exec( "INSERT OR IGNORE INTO dir_to_delete(name)" " SELECT dirname(name) FROM dir_to_delete;" ); }while( db_changes() ); db_multi_exec( "SELECT unlink(%Q||pathname) FROM vfile" " WHERE vid=%d AND mrid>0;", g.zLocalRoot, vid ); ensure_empty_dirs_created(1); zPwd = file_getcwd(0,0); db_multi_exec( "SELECT rmdir(%Q||name) FROM dir_to_delete" " WHERE (%Q||name)<>%Q ORDER BY name DESC", g.zLocalRoot, g.zLocalRoot, zPwd ); fossil_free(zPwd); db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid); } /* ** Given the abbreviated UUID name of a version, load the content of that ** version in the VFILE table. Return the VID for the version. |
︙ | ︙ | |||
301 302 303 304 305 306 307 | } db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid); if( !keepFlag ){ vfile_to_disk(vid, 0, !g.fQuiet, promptFlag); } checkout_set_all_exe(vid); manifest_to_disk(vid); | | | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | } db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid); if( !keepFlag ){ vfile_to_disk(vid, 0, !g.fQuiet, promptFlag); } checkout_set_all_exe(vid); manifest_to_disk(vid); ensure_empty_dirs_created(0); db_set_checkout(vid); undo_reset(); db_multi_exec("DELETE FROM vmerge"); if( !keepFlag && db_get_boolean("repo-cksum",1) ){ vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b); vfile_aggregate_checksum_disk(vid, &cksum2); if( blob_compare(&cksum1, &cksum2) ){ |
︙ | ︙ |
Changes to src/file.c.
︙ | ︙ | |||
435 436 437 438 439 440 441 442 443 444 445 446 447 448 | const char *zTail = file_tail(z); if( zTail && zTail!=z ){ return mprintf("%.*s", (int)(zTail-z-1), z); }else{ return 0; } } /* ** Rename a file or directory. ** Returns zero upon success. */ int file_rename( const char *zFrom, | > > > > > > > > > > > > > > > > > > > | 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | const char *zTail = file_tail(z); if( zTail && zTail!=z ){ return mprintf("%.*s", (int)(zTail-z-1), z); }else{ return 0; } } /* SQL Function: file_dirname(NAME) ** ** Return the directory for NAME */ void file_dirname_sql_function( sqlite3_context *context, int argc, sqlite3_value **argv ){ const char *zName = (const char*)sqlite3_value_text(argv[0]); char *zDir; if( zName==0 ) return; zDir = file_dirname(zName); if( zDir ){ sqlite3_result_text(context,zDir,-1,fossil_free); } } /* ** Rename a file or directory. ** Returns zero upon success. */ int file_rename( const char *zFrom, |
︙ | ︙ | |||
592 593 594 595 596 597 598 599 600 601 602 603 604 605 | #else char *z = fossil_utf8_to_path(zFilename, 0); rc = unlink(zFilename); #endif fossil_path_free(z); return rc; } /* ** Create a directory called zName, if it does not already exist. ** If forceFlag is 1, delete any prior non-directory object ** with the same name. ** ** Return the number of errors. | > > > > > > > > > > > > > > > > > > > > | 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | #else char *z = fossil_utf8_to_path(zFilename, 0); rc = unlink(zFilename); #endif fossil_path_free(z); return rc; } /* SQL Function: file_delete(NAME) ** ** Remove file NAME. Return zero on success and non-zero if anything goes ** wrong. */ void file_delete_sql_function( sqlite3_context *context, int argc, sqlite3_value **argv ){ const char *zName = (const char*)sqlite3_value_text(argv[0]); int rc; if( zName==0 ){ rc = 1; }else{ rc = file_delete(zName); } sqlite3_result_int(context, rc); } /* ** Create a directory called zName, if it does not already exist. ** If forceFlag is 1, delete any prior non-directory object ** with the same name. ** ** Return the number of errors. |
︙ | ︙ | |||
682 683 684 685 686 687 688 689 690 691 692 693 694 695 | rc = rmdir(zName); #endif fossil_path_free(zMbcs); return rc; } return 0; } /* ** Return true if the filename given is a valid filename for ** a file in a repository. Valid filenames follow all of the ** following rules: ** ** * Does not begin with "/" | > > > > > > > > > > > > > > > > > > > > | 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | rc = rmdir(zName); #endif fossil_path_free(zMbcs); return rc; } return 0; } /* SQL Function: rmdir(NAME) ** ** Try to remove the directory NAME. Return zero on success and non-zero ** for failure. */ void file_rmdir_sql_function( sqlite3_context *context, int argc, sqlite3_value **argv ){ const char *zName = (const char*)sqlite3_value_text(argv[0]); int rc; if( zName==0 ){ rc = 1; }else{ rc = file_rmdir(zName); } sqlite3_result_int(context, rc); } /* ** Return true if the filename given is a valid filename for ** a file in a repository. Valid filenames follow all of the ** following rules: ** ** * Does not begin with "/" |
︙ | ︙ | |||
888 889 890 891 892 893 894 895 | /* ** Get the current working directory. ** ** On windows, the name is converted from unicode to UTF8 and all '\\' ** characters are converted to '/'. No conversions are needed on ** unix. */ | > > > | > > > > > > | 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 | /* ** Get the current working directory. ** ** On windows, the name is converted from unicode to UTF8 and all '\\' ** characters are converted to '/'. No conversions are needed on ** unix. ** ** Store the value of the CWD in zBuf which is nBuf bytes in size. ** or if zBuf==0, allocate space to hold the result using fossil_malloc(). */ char *file_getcwd(char *zBuf, int nBuf){ char zTemp[2000]; if( zBuf==0 ){ zBuf = zTemp; nBuf = sizeof(zTemp); } #ifdef _WIN32 win32_getcwd(zBuf, nBuf); #else if( getcwd(zBuf, nBuf-1)==0 ){ if( errno==ERANGE ){ fossil_panic("pwd too big: max %d", nBuf-1); }else{ fossil_panic("cannot find current working directory; %s", strerror(errno)); } } #endif return zBuf==zTemp ? fossil_strdup(zBuf) : zBuf; } /* ** Return true if zPath is an absolute pathname. Return false ** if it is relative. */ int file_is_absolute_path(const char *zPath){ |
︙ | ︙ |
Changes to src/update.c.
︙ | ︙ | |||
158 159 160 161 162 163 164 | db_get_int("autosync-tries", 1), 1) ){ fossil_fatal("update abandoned due to sync failure"); } } /* Create any empty directories now, as well as after the update, ** so changes in settings are reflected now */ | | | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | db_get_int("autosync-tries", 1), 1) ){ fossil_fatal("update abandoned due to sync failure"); } } /* Create any empty directories now, as well as after the update, ** so changes in settings are reflected now */ if( !dryRunFlag ) ensure_empty_dirs_created(0); if( internalUpdate ){ tid = internalUpdate; }else if( g.argc>=3 ){ if( fossil_strcmp(g.argv[2], "current")==0 ){ /* If VERSION is "current", then use the same algorithm to find the ** target as if VERSION were omitted. */ |
︙ | ︙ | |||
225 226 227 228 229 230 231 232 233 234 235 236 237 238 | } if( tid==0 ){ return; } db_begin_transaction(); vfile_check_signature(vid, CKSIG_ENOTFILE); if( !dryRunFlag && !internalUpdate ) undo_begin(); if( load_vfile_from_rid(tid) && !forceMissingFlag ){ fossil_fatal("missing content, unable to update"); }; /* | > > > > | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | } if( tid==0 ){ return; } db_begin_transaction(); db_multi_exec( "CREATE TEMP TABLE dir_to_delete(name TEXT %s PRIMARY KEY)WITHOUT ROWID", filename_collation() ); vfile_check_signature(vid, CKSIG_ENOTFILE); if( !dryRunFlag && !internalUpdate ) undo_begin(); if( load_vfile_from_rid(tid) && !forceMissingFlag ){ fossil_fatal("missing content, unable to update"); }; /* |
︙ | ︙ | |||
453 454 455 456 457 458 459 | ** file but keep the edited version around. */ fossil_print("CONFLICT %s - edited locally but deleted by update\n", zName); nConflict++; }else{ fossil_print("REMOVE %s\n", zName); if( !dryRunFlag && !internalUpdate ) undo_save(zName); | | > > > > > > > > > > > > | 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | ** file but keep the edited version around. */ fossil_print("CONFLICT %s - edited locally but deleted by update\n", zName); nConflict++; }else{ fossil_print("REMOVE %s\n", zName); if( !dryRunFlag && !internalUpdate ) undo_save(zName); if( !dryRunFlag ){ char *zDir; file_delete(zFullPath); zDir = file_dirname(zName); while( zDir!=0 ){ char *zNext; db_multi_exec("INSERT OR IGNORE INTO dir_to_delete(name)" "VALUES(%Q)", zDir); zNext = db_changes() ? file_dirname(zDir) : 0; fossil_free(zDir); zDir = zNext; } } } }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){ /* Merge the changes in the current tree into the target version */ Blob r, t, v; int rc; if( nameChng ){ fossil_print("MERGE %s -> %s\n", zName, zNewName); |
︙ | ︙ | |||
564 565 566 567 568 569 570 | /* ** Clean up the mid and pid VFILE entries. Then commit the changes. */ if( dryRunFlag ){ db_end_transaction(1); /* With --dry-run, rollback changes */ }else{ | > | > > > > > > > > > | | 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | /* ** Clean up the mid and pid VFILE entries. Then commit the changes. */ if( dryRunFlag ){ db_end_transaction(1); /* With --dry-run, rollback changes */ }else{ char *zPwd; ensure_empty_dirs_created(1); sqlite3_create_function(g.db, "rmdir", 1, SQLITE_UTF8, 0, file_rmdir_sql_function, 0, 0); zPwd = file_getcwd(0,0); db_multi_exec( "SELECT rmdir(%Q||name) FROM dir_to_delete" " WHERE (%Q||name)<>%Q ORDER BY name DESC", g.zLocalRoot, g.zLocalRoot, zPwd ); fossil_free(zPwd); if( g.argc<=3 ){ /* All files updated. Shift the current checkout to the target. */ db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid); checkout_set_all_exe(tid); manifest_to_disk(tid); db_set_checkout(tid); }else{ /* A subset of files have been checked out. Keep the current ** checkout unchanged. */ db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid); } if( !internalUpdate ) undo_finish(); if( setmtimeFlag ) vfile_check_signature(tid, CKSIG_SETMTIME); db_end_transaction(0); } } /* ** Create empty directories specified by the empty-dirs setting. */ void ensure_empty_dirs_created(int clearDirTable){ char *zEmptyDirs = db_get("empty-dirs", 0); if( zEmptyDirs!=0 ){ int i; Blob dirName; Blob dirsList; zEmptyDirs = fossil_strdup(zEmptyDirs); |
︙ | ︙ | |||
611 612 613 614 615 616 617 | if( file_mkfolder(zPath, RepoFILE, 0, 1)!=0 ) { fossil_warning("couldn't create directory %s as " "required by empty-dirs setting", zDir); } break; } case 1: { /* exists, and is a directory */ | | > > > > > | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 | if( file_mkfolder(zPath, RepoFILE, 0, 1)!=0 ) { fossil_warning("couldn't create directory %s as " "required by empty-dirs setting", zDir); } break; } case 1: { /* exists, and is a directory */ /* make sure this directory is not on the delete list */ if( clearDirTable ){ db_multi_exec( "DELETE FROM dir_to_delete WHERE name=%Q", zDir ); } break; } case 2: { /* exists, but isn't a directory */ fossil_warning("file %s found, but a directory is required " "by empty-dirs setting", zDir); } } |
︙ | ︙ |
Changes to src/vfile.c.
︙ | ︙ | |||
357 358 359 360 361 362 363 | blob_reset(&content); db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", file_mtime(zName, RepoFILE), id); } db_finalize(&q); } | < < < < < < < < < < < < < < < < < < | 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | blob_reset(&content); db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", file_mtime(zName, RepoFILE), id); } db_finalize(&q); } /* ** Check to see if the directory named in zPath is the top of a checkout. ** In other words, check to see if directory pPath contains a file named ** "_FOSSIL_" or ".fslckout". Return true or false. */ int vfile_top_of_checkout(const char *zPath){ char *zFile; |
︙ | ︙ |