Fossil SCM
Enhance the fossil_reserved_name() function to include the repository filename and its journals and auxiliary files. Ticket [7d790e7e5e0f701e01].
Commit
8b06be709f13c55bf06eaec9bd753afb1bf036fe
Parent
50c534ee530d0e5…
2 files changed
+36
-4
-4
+36
-4
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -60,22 +60,39 @@ | ||
| 60 | 60 | static const char *const azManifest[] = { |
| 61 | 61 | "manifest", |
| 62 | 62 | "manifest.uuid", |
| 63 | 63 | }; |
| 64 | 64 | |
| 65 | + /* | |
| 66 | + ** Names of repository files, if they exist in the checkout. | |
| 67 | + */ | |
| 68 | + static const char *azRepo[4] = { 0, 0, 0, 0 }; | |
| 69 | + | |
| 65 | 70 | /* Cached setting "manifest" */ |
| 66 | 71 | static int cachedManifest = -1; |
| 67 | 72 | |
| 68 | 73 | if( cachedManifest == -1 ){ |
| 74 | + Blob repo; | |
| 69 | 75 | cachedManifest = db_get_boolean("manifest",0); |
| 76 | + blob_zero(&repo); | |
| 77 | + if( file_tree_name(g.zRepositoryName, &repo, 0) ){ | |
| 78 | + const char *zRepo = blob_str(&repo); | |
| 79 | + azRepo[0] = zRepo; | |
| 80 | + azRepo[1] = mprintf("%s-journal", zRepo); | |
| 81 | + azRepo[2] = mprintf("%s-wal", zRepo); | |
| 82 | + azRepo[3] = mprintf("%s-shm", zRepo); | |
| 83 | + } | |
| 70 | 84 | } |
| 71 | 85 | |
| 72 | - if( N>=0 && N<count(azName) ) return azName[N]; | |
| 73 | - if( N>=count(azName) && N<count(azName)+count(azManifest) | |
| 74 | - && cachedManifest ){ | |
| 75 | - return azManifest[N-count(azName)]; | |
| 86 | + if( N<0 ) return 0; | |
| 87 | + if( N<count(azName) ) return azName[N]; | |
| 88 | + N -= count(azName); | |
| 89 | + if( cachedManifest ){ | |
| 90 | + if( N<count(azManifest) ) return azManifest[N]; | |
| 91 | + N -= count(azManifest); | |
| 76 | 92 | } |
| 93 | + if( N<count(azRepo) ) return azRepo[N]; | |
| 77 | 94 | return 0; |
| 78 | 95 | } |
| 79 | 96 | |
| 80 | 97 | /* |
| 81 | 98 | ** Return a list of all reserved filenames as an SQL list. |
| @@ -93,10 +110,25 @@ | ||
| 93 | 110 | } |
| 94 | 111 | zAll = blob_str(&x); |
| 95 | 112 | } |
| 96 | 113 | return zAll; |
| 97 | 114 | } |
| 115 | + | |
| 116 | +/* | |
| 117 | +** COMMAND: test-reserved-names | |
| 118 | +** | |
| 119 | +** Show all reserved filenames for the current check-out. | |
| 120 | +*/ | |
| 121 | +void test_reserved_names(void){ | |
| 122 | + int i; | |
| 123 | + const char *z; | |
| 124 | + db_must_be_within_tree(); | |
| 125 | + for(i=0; (z = fossil_reserved_name(i))!=0; i++){ | |
| 126 | + fossil_print("%3d: %s\n", i, z); | |
| 127 | + } | |
| 128 | + fossil_print("ALL: (%s)\n", fossil_all_reserved_names()); | |
| 129 | +} | |
| 98 | 130 | |
| 99 | 131 | /* |
| 100 | 132 | ** Add a single file named zName to the VFILE table with vid. |
| 101 | 133 | ** |
| 102 | 134 | ** Omit any file whose name is pOmit. |
| 103 | 135 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -60,22 +60,39 @@ | |
| 60 | static const char *const azManifest[] = { |
| 61 | "manifest", |
| 62 | "manifest.uuid", |
| 63 | }; |
| 64 | |
| 65 | /* Cached setting "manifest" */ |
| 66 | static int cachedManifest = -1; |
| 67 | |
| 68 | if( cachedManifest == -1 ){ |
| 69 | cachedManifest = db_get_boolean("manifest",0); |
| 70 | } |
| 71 | |
| 72 | if( N>=0 && N<count(azName) ) return azName[N]; |
| 73 | if( N>=count(azName) && N<count(azName)+count(azManifest) |
| 74 | && cachedManifest ){ |
| 75 | return azManifest[N-count(azName)]; |
| 76 | } |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | /* |
| 81 | ** Return a list of all reserved filenames as an SQL list. |
| @@ -93,10 +110,25 @@ | |
| 93 | } |
| 94 | zAll = blob_str(&x); |
| 95 | } |
| 96 | return zAll; |
| 97 | } |
| 98 | |
| 99 | /* |
| 100 | ** Add a single file named zName to the VFILE table with vid. |
| 101 | ** |
| 102 | ** Omit any file whose name is pOmit. |
| 103 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -60,22 +60,39 @@ | |
| 60 | static const char *const azManifest[] = { |
| 61 | "manifest", |
| 62 | "manifest.uuid", |
| 63 | }; |
| 64 | |
| 65 | /* |
| 66 | ** Names of repository files, if they exist in the checkout. |
| 67 | */ |
| 68 | static const char *azRepo[4] = { 0, 0, 0, 0 }; |
| 69 | |
| 70 | /* Cached setting "manifest" */ |
| 71 | static int cachedManifest = -1; |
| 72 | |
| 73 | if( cachedManifest == -1 ){ |
| 74 | Blob repo; |
| 75 | cachedManifest = db_get_boolean("manifest",0); |
| 76 | blob_zero(&repo); |
| 77 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 78 | const char *zRepo = blob_str(&repo); |
| 79 | azRepo[0] = zRepo; |
| 80 | azRepo[1] = mprintf("%s-journal", zRepo); |
| 81 | azRepo[2] = mprintf("%s-wal", zRepo); |
| 82 | azRepo[3] = mprintf("%s-shm", zRepo); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | if( N<0 ) return 0; |
| 87 | if( N<count(azName) ) return azName[N]; |
| 88 | N -= count(azName); |
| 89 | if( cachedManifest ){ |
| 90 | if( N<count(azManifest) ) return azManifest[N]; |
| 91 | N -= count(azManifest); |
| 92 | } |
| 93 | if( N<count(azRepo) ) return azRepo[N]; |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | /* |
| 98 | ** Return a list of all reserved filenames as an SQL list. |
| @@ -93,10 +110,25 @@ | |
| 110 | } |
| 111 | zAll = blob_str(&x); |
| 112 | } |
| 113 | return zAll; |
| 114 | } |
| 115 | |
| 116 | /* |
| 117 | ** COMMAND: test-reserved-names |
| 118 | ** |
| 119 | ** Show all reserved filenames for the current check-out. |
| 120 | */ |
| 121 | void test_reserved_names(void){ |
| 122 | int i; |
| 123 | const char *z; |
| 124 | db_must_be_within_tree(); |
| 125 | for(i=0; (z = fossil_reserved_name(i))!=0; i++){ |
| 126 | fossil_print("%3d: %s\n", i, z); |
| 127 | } |
| 128 | fossil_print("ALL: (%s)\n", fossil_all_reserved_names()); |
| 129 | } |
| 130 | |
| 131 | /* |
| 132 | ** Add a single file named zName to the VFILE table with vid. |
| 133 | ** |
| 134 | ** Omit any file whose name is pOmit. |
| 135 |
-4
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -324,11 +324,10 @@ | ||
| 324 | 324 | ** |
| 325 | 325 | ** See also: changes, clean, status |
| 326 | 326 | */ |
| 327 | 327 | void extra_cmd(void){ |
| 328 | 328 | Blob path; |
| 329 | - Blob repo; | |
| 330 | 329 | Stmt q; |
| 331 | 330 | int n; |
| 332 | 331 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 333 | 332 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 334 | 333 | int cwdRelative = 0; |
| @@ -353,13 +352,10 @@ | ||
| 353 | 352 | "SELECT x FROM sfile" |
| 354 | 353 | " WHERE x NOT IN (%s)" |
| 355 | 354 | " ORDER BY 1", |
| 356 | 355 | fossil_all_reserved_names() |
| 357 | 356 | ); |
| 358 | - if( file_tree_name(g.zRepositoryName, &repo, 0) ){ | |
| 359 | - db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); | |
| 360 | - } | |
| 361 | 357 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 362 | 358 | blob_zero(&rewrittenPathname); |
| 363 | 359 | while( db_step(&q)==SQLITE_ROW ){ |
| 364 | 360 | zDisplayName = zPathname = db_column_text(&q, 0); |
| 365 | 361 | if( cwdRelative ) { |
| 366 | 362 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -324,11 +324,10 @@ | |
| 324 | ** |
| 325 | ** See also: changes, clean, status |
| 326 | */ |
| 327 | void extra_cmd(void){ |
| 328 | Blob path; |
| 329 | Blob repo; |
| 330 | Stmt q; |
| 331 | int n; |
| 332 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 333 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 334 | int cwdRelative = 0; |
| @@ -353,13 +352,10 @@ | |
| 353 | "SELECT x FROM sfile" |
| 354 | " WHERE x NOT IN (%s)" |
| 355 | " ORDER BY 1", |
| 356 | fossil_all_reserved_names() |
| 357 | ); |
| 358 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 359 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 360 | } |
| 361 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 362 | blob_zero(&rewrittenPathname); |
| 363 | while( db_step(&q)==SQLITE_ROW ){ |
| 364 | zDisplayName = zPathname = db_column_text(&q, 0); |
| 365 | if( cwdRelative ) { |
| 366 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -324,11 +324,10 @@ | |
| 324 | ** |
| 325 | ** See also: changes, clean, status |
| 326 | */ |
| 327 | void extra_cmd(void){ |
| 328 | Blob path; |
| 329 | Stmt q; |
| 330 | int n; |
| 331 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 332 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 333 | int cwdRelative = 0; |
| @@ -353,13 +352,10 @@ | |
| 352 | "SELECT x FROM sfile" |
| 353 | " WHERE x NOT IN (%s)" |
| 354 | " ORDER BY 1", |
| 355 | fossil_all_reserved_names() |
| 356 | ); |
| 357 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 358 | blob_zero(&rewrittenPathname); |
| 359 | while( db_step(&q)==SQLITE_ROW ){ |
| 360 | zDisplayName = zPathname = db_column_text(&q, 0); |
| 361 | if( cwdRelative ) { |
| 362 |