Fossil SCM

Serious bug fix: Avoid deleting the respository if the repository is in the checkout and you do a "fossil close".

drh 2012-11-28 23:05 trunk
Commit fcdeaa29098ade4fc245392a2eeef261d17bd593
3 files changed +10 -7 +2 -2 +1 -1
+10 -7
--- src/add.c
+++ src/add.c
@@ -29,11 +29,11 @@
2929
** or merge, and should be omitted from "clean" and "extra" lists.
3030
**
3131
** Return the N-th name. The first name has N==0. When all names have
3232
** been used, return 0.
3333
*/
34
-const char *fossil_reserved_name(int N){
34
+const char *fossil_reserved_name(int N, int omitRepo){
3535
/* Possible names of the local per-checkout database file and
3636
** its associated journals
3737
*/
3838
static const char *const azName[] = {
3939
"_FOSSIL_",
@@ -88,25 +88,25 @@
8888
N -= count(azName);
8989
if( cachedManifest ){
9090
if( N<count(azManifest) ) return azManifest[N];
9191
N -= count(azManifest);
9292
}
93
- if( N<count(azRepo) ) return azRepo[N];
93
+ if( !omitRepo && N<count(azRepo) ) return azRepo[N];
9494
return 0;
9595
}
9696
9797
/*
9898
** Return a list of all reserved filenames as an SQL list.
9999
*/
100
-const char *fossil_all_reserved_names(void){
100
+const char *fossil_all_reserved_names(int omitRepo){
101101
static char *zAll = 0;
102102
if( zAll==0 ){
103103
Blob x;
104104
int i;
105105
const char *z;
106106
blob_zero(&x);
107
- for(i=0; (z = fossil_reserved_name(i))!=0; i++){
107
+ for(i=0; (z = fossil_reserved_name(i, omitRepo))!=0; i++){
108108
if( i>0 ) blob_append(&x, ",", 1);
109109
blob_appendf(&x, "'%q'", z);
110110
}
111111
zAll = blob_str(&x);
112112
}
@@ -113,21 +113,24 @@
113113
return zAll;
114114
}
115115
116116
/*
117117
** COMMAND: test-reserved-names
118
+**
119
+** Usage: %fossil test-reserved-names [-omitrepo]
118120
**
119121
** Show all reserved filenames for the current check-out.
120122
*/
121123
void test_reserved_names(void){
122124
int i;
123125
const char *z;
126
+ int omitRepo = find_option("omitrepo",0,0)!=0;
124127
db_must_be_within_tree();
125
- for(i=0; (z = fossil_reserved_name(i))!=0; i++){
128
+ for(i=0; (z = fossil_reserved_name(i, omitRepo))!=0; i++){
126129
fossil_print("%3d: %s\n", i, z);
127130
}
128
- fossil_print("ALL: (%s)\n", fossil_all_reserved_names());
131
+ fossil_print("ALL: (%s)\n", fossil_all_reserved_names(omitRepo));
129132
}
130133
131134
/*
132135
** Add a single file named zName to the VFILE table with vid.
133136
**
@@ -195,11 +198,11 @@
195198
}
196199
db_prepare(&loop, "SELECT x FROM sfile ORDER BY x");
197200
while( db_step(&loop)==SQLITE_ROW ){
198201
const char *zToAdd = db_column_text(&loop, 0);
199202
if( fossil_strcmp(zToAdd, zRepo)==0 ) continue;
200
- for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){
203
+ for(i=0; (zReserved = fossil_reserved_name(i, 0))!=0; i++){
201204
if( xCmp(zToAdd, zReserved)==0 ) break;
202205
}
203206
if( zReserved ) continue;
204207
nAdd += add_one_file(zToAdd, vid, caseSensitive);
205208
}
206209
--- src/add.c
+++ src/add.c
@@ -29,11 +29,11 @@
29 ** or merge, and should be omitted from "clean" and "extra" lists.
30 **
31 ** Return the N-th name. The first name has N==0. When all names have
32 ** been used, return 0.
33 */
34 const char *fossil_reserved_name(int N){
35 /* Possible names of the local per-checkout database file and
36 ** its associated journals
37 */
38 static const char *const azName[] = {
39 "_FOSSIL_",
@@ -88,25 +88,25 @@
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.
99 */
100 const char *fossil_all_reserved_names(void){
101 static char *zAll = 0;
102 if( zAll==0 ){
103 Blob x;
104 int i;
105 const char *z;
106 blob_zero(&x);
107 for(i=0; (z = fossil_reserved_name(i))!=0; i++){
108 if( i>0 ) blob_append(&x, ",", 1);
109 blob_appendf(&x, "'%q'", z);
110 }
111 zAll = blob_str(&x);
112 }
@@ -113,21 +113,24 @@
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 **
@@ -195,11 +198,11 @@
195 }
196 db_prepare(&loop, "SELECT x FROM sfile ORDER BY x");
197 while( db_step(&loop)==SQLITE_ROW ){
198 const char *zToAdd = db_column_text(&loop, 0);
199 if( fossil_strcmp(zToAdd, zRepo)==0 ) continue;
200 for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){
201 if( xCmp(zToAdd, zReserved)==0 ) break;
202 }
203 if( zReserved ) continue;
204 nAdd += add_one_file(zToAdd, vid, caseSensitive);
205 }
206
--- src/add.c
+++ src/add.c
@@ -29,11 +29,11 @@
29 ** or merge, and should be omitted from "clean" and "extra" lists.
30 **
31 ** Return the N-th name. The first name has N==0. When all names have
32 ** been used, return 0.
33 */
34 const char *fossil_reserved_name(int N, int omitRepo){
35 /* Possible names of the local per-checkout database file and
36 ** its associated journals
37 */
38 static const char *const azName[] = {
39 "_FOSSIL_",
@@ -88,25 +88,25 @@
88 N -= count(azName);
89 if( cachedManifest ){
90 if( N<count(azManifest) ) return azManifest[N];
91 N -= count(azManifest);
92 }
93 if( !omitRepo && N<count(azRepo) ) return azRepo[N];
94 return 0;
95 }
96
97 /*
98 ** Return a list of all reserved filenames as an SQL list.
99 */
100 const char *fossil_all_reserved_names(int omitRepo){
101 static char *zAll = 0;
102 if( zAll==0 ){
103 Blob x;
104 int i;
105 const char *z;
106 blob_zero(&x);
107 for(i=0; (z = fossil_reserved_name(i, omitRepo))!=0; i++){
108 if( i>0 ) blob_append(&x, ",", 1);
109 blob_appendf(&x, "'%q'", z);
110 }
111 zAll = blob_str(&x);
112 }
@@ -113,21 +113,24 @@
113 return zAll;
114 }
115
116 /*
117 ** COMMAND: test-reserved-names
118 **
119 ** Usage: %fossil test-reserved-names [-omitrepo]
120 **
121 ** Show all reserved filenames for the current check-out.
122 */
123 void test_reserved_names(void){
124 int i;
125 const char *z;
126 int omitRepo = find_option("omitrepo",0,0)!=0;
127 db_must_be_within_tree();
128 for(i=0; (z = fossil_reserved_name(i, omitRepo))!=0; i++){
129 fossil_print("%3d: %s\n", i, z);
130 }
131 fossil_print("ALL: (%s)\n", fossil_all_reserved_names(omitRepo));
132 }
133
134 /*
135 ** Add a single file named zName to the VFILE table with vid.
136 **
@@ -195,11 +198,11 @@
198 }
199 db_prepare(&loop, "SELECT x FROM sfile ORDER BY x");
200 while( db_step(&loop)==SQLITE_ROW ){
201 const char *zToAdd = db_column_text(&loop, 0);
202 if( fossil_strcmp(zToAdd, zRepo)==0 ) continue;
203 for(i=0; (zReserved = fossil_reserved_name(i, 0))!=0; i++){
204 if( xCmp(zToAdd, zReserved)==0 ) break;
205 }
206 if( zReserved ) continue;
207 nAdd += add_one_file(zToAdd, vid, caseSensitive);
208 }
209
+2 -2
--- src/checkin.c
+++ src/checkin.c
@@ -350,11 +350,11 @@
350350
glob_free(pIgnore);
351351
db_prepare(&q,
352352
"SELECT x FROM sfile"
353353
" WHERE x NOT IN (%s)"
354354
" ORDER BY 1",
355
- fossil_all_reserved_names()
355
+ fossil_all_reserved_names(0)
356356
);
357357
db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
358358
blob_zero(&rewrittenPathname);
359359
while( db_step(&q)==SQLITE_ROW ){
360360
zDisplayName = zPathname = db_column_text(&q, 0);
@@ -430,11 +430,11 @@
430430
glob_free(pIgnore);
431431
db_prepare(&q,
432432
"SELECT %Q || x FROM sfile"
433433
" WHERE x NOT IN (%s)"
434434
" ORDER BY 1",
435
- g.zLocalRoot, fossil_all_reserved_names()
435
+ g.zLocalRoot, fossil_all_reserved_names(0)
436436
);
437437
if( file_tree_name(g.zRepositoryName, &repo, 0) ){
438438
db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
439439
}
440440
db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
441441
--- src/checkin.c
+++ src/checkin.c
@@ -350,11 +350,11 @@
350 glob_free(pIgnore);
351 db_prepare(&q,
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);
@@ -430,11 +430,11 @@
430 glob_free(pIgnore);
431 db_prepare(&q,
432 "SELECT %Q || x FROM sfile"
433 " WHERE x NOT IN (%s)"
434 " ORDER BY 1",
435 g.zLocalRoot, fossil_all_reserved_names()
436 );
437 if( file_tree_name(g.zRepositoryName, &repo, 0) ){
438 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
439 }
440 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
441
--- src/checkin.c
+++ src/checkin.c
@@ -350,11 +350,11 @@
350 glob_free(pIgnore);
351 db_prepare(&q,
352 "SELECT x FROM sfile"
353 " WHERE x NOT IN (%s)"
354 " ORDER BY 1",
355 fossil_all_reserved_names(0)
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);
@@ -430,11 +430,11 @@
430 glob_free(pIgnore);
431 db_prepare(&q,
432 "SELECT %Q || x FROM sfile"
433 " WHERE x NOT IN (%s)"
434 " ORDER BY 1",
435 g.zLocalRoot, fossil_all_reserved_names(0)
436 );
437 if( file_tree_name(g.zRepositoryName, &repo, 0) ){
438 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
439 }
440 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
441
+1 -1
--- src/checkout.c
+++ src/checkout.c
@@ -261,11 +261,11 @@
261261
** Unlink the local database file
262262
*/
263263
static void unlink_local_database(int manifestOnly){
264264
const char *zReserved;
265265
int i;
266
- for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){
266
+ for(i=0; (zReserved = fossil_reserved_name(i, 1))!=0; i++){
267267
if( manifestOnly==0 || zReserved[0]=='m' ){
268268
char *z;
269269
z = mprintf("%s%s", g.zLocalRoot, zReserved);
270270
file_delete(z);
271271
free(z);
272272
--- src/checkout.c
+++ src/checkout.c
@@ -261,11 +261,11 @@
261 ** Unlink the local database file
262 */
263 static void unlink_local_database(int manifestOnly){
264 const char *zReserved;
265 int i;
266 for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){
267 if( manifestOnly==0 || zReserved[0]=='m' ){
268 char *z;
269 z = mprintf("%s%s", g.zLocalRoot, zReserved);
270 file_delete(z);
271 free(z);
272
--- src/checkout.c
+++ src/checkout.c
@@ -261,11 +261,11 @@
261 ** Unlink the local database file
262 */
263 static void unlink_local_database(int manifestOnly){
264 const char *zReserved;
265 int i;
266 for(i=0; (zReserved = fossil_reserved_name(i, 1))!=0; i++){
267 if( manifestOnly==0 || zReserved[0]=='m' ){
268 char *z;
269 z = mprintf("%s%s", g.zLocalRoot, zReserved);
270 file_delete(z);
271 free(z);
272

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button