Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add comments and simplify use of temporary tables. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | mvAndRmFiles |
| Files: | files | file ages | folders |
| SHA1: |
90ee7bcb765375ea3ab955e8fd04e79f |
| User & Date: | mistachkin 2015-04-10 00:02:23.098 |
Context
|
2015-04-10
| ||
| 00:18 | Use one setting instead of two. Using one default fallback constant instead of two. Remove the '--metadata-only' option entirely. ... (Closed-Leaf check-in: d981fe2c5e user: mistachkin tags: mvAndRmFiles) | |
| 00:02 | Add comments and simplify use of temporary tables. ... (check-in: 90ee7bcb76 user: mistachkin tags: mvAndRmFiles) | |
|
2015-04-09
| ||
| 23:21 | Style and comment fixes. ... (check-in: 99c57b3eb3 user: mistachkin tags: mvAndRmFiles) | |
Changes
Changes to src/add.c.
| ︙ | ︙ | |||
364 365 366 367 368 369 370 | glob_free(pIgnore); glob_free(pClean); add_files_in_sfile(vid); db_end_transaction(0); } | < > > > > | | < | > > > > > > > > > > > > > > > > | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
glob_free(pIgnore);
glob_free(pClean);
add_files_in_sfile(vid);
db_end_transaction(0);
}
/*
** This function adds a file to list of files to delete from disk after
** the other actions required for the parent operation have completed
** successfully. The first time it is called for the current process,
** it creates a temporary table named "fremove", to keep track of these
** files.
*/
static void add_file_to_remove(
const char *zOldName /* The old name of the file on disk. */
){
static int tableCreated = 0;
Blob fullOldName;
if( !tableCreated ){
db_multi_exec("CREATE TEMP TABLE fremove(x TEXT PRIMARY KEY %s)",
filename_collation());
tableCreated = 1;
}
file_canonical_name(zOldName, &fullOldName, 0);
db_multi_exec("INSERT INTO fremove VALUES('%q');", blob_str(&fullOldName));
blob_reset(&fullOldName);
}
/*
** This function deletes files from the checkout, using the file names
** contained in the temporary table "fremove". The temporary table is
** created on demand by the add_file_to_remove() function.
**
** If dryRunFlag is non-zero, no files will be removed; however, their
** names will still be output.
**
** The temporary table "fremove" is dropped after being processed.
*/
static void process_files_to_remove(
int dryRunFlag /* Zero to actually operate on the file-system. */
){
Stmt remove;
db_prepare(&remove, "SELECT x FROM fremove ORDER BY x;");
while( db_step(&remove)==SQLITE_ROW ){
const char *zOldName = db_column_text(&remove, 0);
|
| ︙ | ︙ | |||
472 473 474 475 476 477 478 |
}else{
#if FOSSIL_ENABLE_LEGACY_MV_RM
removeFiles = db_get_boolean("remove-files",0);
#else
removeFiles = FOSSIL_RM_CHECKOUT_FILE_ON_RM;
#endif
}
| < | 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
}else{
#if FOSSIL_ENABLE_LEGACY_MV_RM
removeFiles = db_get_boolean("remove-files",0);
#else
removeFiles = FOSSIL_RM_CHECKOUT_FILE_ON_RM;
#endif
}
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
filename_collation());
for(i=2; i<g.argc; i++){
Blob treeName;
char *zTreeName;
file_tree_name(g.argv[i], &treeName, 1);
|
| ︙ | ︙ | |||
734 735 736 737 738 739 740 |
db_multi_exec(
"UPDATE vfile SET pathname='%q' WHERE pathname='%q' %s AND vid=%d",
zNew, zOrig, filename_collation(), vid
);
}
}
| < > | > > > | < | > > > > > > > > > > > > > > > > | 751 752 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 |
db_multi_exec(
"UPDATE vfile SET pathname='%q' WHERE pathname='%q' %s AND vid=%d",
zNew, zOrig, filename_collation(), vid
);
}
}
/*
** This function adds a file to list of files to move on disk after the
** other actions required for the parent operation have completed
** successfully. The first time it is called for the current process,
** it creates a temporary table named "fmove", to keep track of these
** files.
*/
static void add_file_to_move(
const char *zOldName, /* The old name of the file on disk. */
const char *zNewName /* The new name of the file on disk. */
){
static int tableCreated = 0;
Blob fullOldName;
Blob fullNewName;
if( !tableCreated ){
db_multi_exec("CREATE TEMP TABLE fmove(x TEXT PRIMARY KEY %s, y TEXT %s)",
filename_collation(), filename_collation());
tableCreated = 1;
}
file_canonical_name(zOldName, &fullOldName, 0);
file_canonical_name(zNewName, &fullNewName, 0);
db_multi_exec("INSERT INTO fmove VALUES('%q','%q');",
blob_str(&fullOldName), blob_str(&fullNewName));
blob_reset(&fullNewName);
blob_reset(&fullOldName);
}
/*
** This function moves files within the checkout, using the file names
** contained in the temporary table "fmove". The temporary table is
** created on demand by the add_file_to_move() function.
**
** If dryRunFlag is non-zero, no files will be moved; however, their
** names will still be output.
**
** The temporary table "fmove" is dropped after being processed.
*/
static void process_files_to_move(
int dryRunFlag /* Zero to actually operate on the file-system. */
){
Stmt move;
db_prepare(&move, "SELECT x, y FROM fmove ORDER BY x;");
while( db_step(&move)==SQLITE_ROW ){
const char *zOldName = db_column_text(&move, 0);
|
| ︙ | ︙ | |||
849 850 851 852 853 854 855 |
}else{
#if FOSSIL_ENABLE_LEGACY_MV_RM
moveFiles = db_get_boolean("move-files",0);
#else
moveFiles = FOSSIL_MV_CHECKOUT_FILE_ON_MV;
#endif
}
| < | 884 885 886 887 888 889 890 891 892 893 894 895 896 897 |
}else{
#if FOSSIL_ENABLE_LEGACY_MV_RM
moveFiles = db_get_boolean("move-files",0);
#else
moveFiles = FOSSIL_MV_CHECKOUT_FILE_ON_MV;
#endif
}
file_tree_name(zDest, &dest, 1);
db_multi_exec(
"UPDATE vfile SET origname=pathname WHERE origname IS NULL;"
);
db_multi_exec(
"CREATE TEMP TABLE mv(f TEXT UNIQUE ON CONFLICT IGNORE, t TEXT);"
);
|
| ︙ | ︙ |