Fossil SCM

Enhance the fossil_reserved_name() function to include the repository filename and its journals and auxiliary files. Ticket [7d790e7e5e0f701e01].

drh 2012-11-10 00:26 trunk
Commit 8b06be709f13c55bf06eaec9bd753afb1bf036fe
2 files changed +36 -4 -4
+36 -4
--- src/add.c
+++ src/add.c
@@ -60,22 +60,39 @@
6060
static const char *const azManifest[] = {
6161
"manifest",
6262
"manifest.uuid",
6363
};
6464
65
+ /*
66
+ ** Names of repository files, if they exist in the checkout.
67
+ */
68
+ static const char *azRepo[4] = { 0, 0, 0, 0 };
69
+
6570
/* Cached setting "manifest" */
6671
static int cachedManifest = -1;
6772
6873
if( cachedManifest == -1 ){
74
+ Blob repo;
6975
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
+ }
7084
}
7185
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);
7692
}
93
+ if( N<count(azRepo) ) return azRepo[N];
7794
return 0;
7895
}
7996
8097
/*
8198
** Return a list of all reserved filenames as an SQL list.
@@ -93,10 +110,25 @@
93110
}
94111
zAll = blob_str(&x);
95112
}
96113
return zAll;
97114
}
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
+}
98130
99131
/*
100132
** Add a single file named zName to the VFILE table with vid.
101133
**
102134
** Omit any file whose name is pOmit.
103135
--- 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
--- src/checkin.c
+++ src/checkin.c
@@ -324,11 +324,10 @@
324324
**
325325
** See also: changes, clean, status
326326
*/
327327
void extra_cmd(void){
328328
Blob path;
329
- Blob repo;
330329
Stmt q;
331330
int n;
332331
const char *zIgnoreFlag = find_option("ignore",0,1);
333332
unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
334333
int cwdRelative = 0;
@@ -353,13 +352,10 @@
353352
"SELECT x FROM sfile"
354353
" WHERE x NOT IN (%s)"
355354
" ORDER BY 1",
356355
fossil_all_reserved_names()
357356
);
358
- if( file_tree_name(g.zRepositoryName, &repo, 0) ){
359
- db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
360
- }
361357
db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
362358
blob_zero(&rewrittenPathname);
363359
while( db_step(&q)==SQLITE_ROW ){
364360
zDisplayName = zPathname = db_column_text(&q, 0);
365361
if( cwdRelative ) {
366362
--- 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

Keyboard Shortcuts

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