Fossil SCM

Add a --ignore option to the "extra" command, and an "ignore-glob" setting which causes files with given patterns to be ignored. Tickets [705181a992c] and [5125de2e624]. See also ticket [4e8410bfd69].

drh 2010-03-15 17:41 trunk
Commit 3555c0fc6fd0d1684422c729ac6a571ec3762715
2 files changed +64 -2 +5
+64 -2
--- src/checkin.c
+++ src/checkin.c
@@ -193,14 +193,68 @@
193193
}
194194
free(zFullName);
195195
}
196196
db_finalize(&q);
197197
}
198
+
199
+/*
200
+** Construct and return a string which is an SQL expression that will
201
+** be TRUE if value zVal matches any of the GLOB expressions in the list
202
+** zGlobList. For example:
203
+**
204
+** zVal: "x"
205
+** zGlobList: "*.o,*.obj"
206
+**
207
+** Result: "(x GLOB '*.o' OR x GLOB '*.obj')"
208
+**
209
+** Each element of the GLOB list may optionally be enclosed in either '...'
210
+** or "...". This allows commas in the expression. Whitespace at the
211
+** beginning and end of each GLOB pattern is ignored, except when enclosed
212
+** within '...' or "...".
213
+**
214
+** This routine makes no effort to free the memory space it uses.
215
+*/
216
+char *glob_expr(const char *zVal, const char *zGlobList){
217
+ Blob expr;
218
+ char *zSep = "(";
219
+ int nTerm = 0;
220
+ int i;
221
+ int cTerm;
222
+
223
+ if( zGlobList==0 || zGlobList[0]==0 ) return "0";
224
+ blob_zero(&expr);
225
+ while( zGlobList[0] ){
226
+ while( isspace(zGlobList[0]) || zGlobList[0]==',' ) zGlobList++;
227
+ if( zGlobList[0]==0 ) break;
228
+ if( zGlobList[0]=='\'' || zGlobList[0]=='"' ){
229
+ cTerm = zGlobList[0];
230
+ zGlobList++;
231
+ }else{
232
+ cTerm = ',';
233
+ }
234
+ for(i=0; zGlobList[i] && zGlobList[i]!=cTerm; i++){}
235
+ if( cTerm==',' ){
236
+ while( i>0 && isspace(zGlobList[i-1]) ){ i--; }
237
+ }
238
+ blob_appendf(&expr, "%s%s GLOB '%.*q'", zSep, zVal, i, zGlobList);
239
+ zSep = " OR ";
240
+ if( cTerm!=',' && zGlobList[i] ) i++;
241
+ zGlobList += i;
242
+ if( zGlobList[0] ) zGlobList++;
243
+ nTerm++;
244
+ }
245
+ if( nTerm ){
246
+ blob_appendf(&expr, ")");
247
+ return blob_str(&expr);
248
+ }else{
249
+ return "0";
250
+ }
251
+}
198252
199253
/*
200254
** COMMAND: extras
201
-** Usage: %fossil extras ?--dotfiles?
255
+** Usage: %fossil extras ?--dotfiles? ?--ignore GLOBPATTERN?
202256
**
203257
** Print a list of all files in the source tree that are not part of
204258
** the current checkout. See also the "clean" command.
205259
**
206260
** Files and subdirectories whose names begin with "." are normally
@@ -209,20 +263,28 @@
209263
void extra_cmd(void){
210264
Blob path;
211265
Blob repo;
212266
Stmt q;
213267
int n;
268
+ const char *zIgnoreFlag = find_option("ignore",0,1);
214269
int allFlag = find_option("dotfiles",0,0)!=0;
270
+
215271
db_must_be_within_tree();
216272
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
217273
n = strlen(g.zLocalRoot);
218274
blob_init(&path, g.zLocalRoot, n-1);
275
+ if( zIgnoreFlag==0 ){
276
+ zIgnoreFlag = db_get("ignore-glob", 0);
277
+ }
219278
vfile_scan(0, &path, blob_size(&path), allFlag);
220279
db_prepare(&q,
221280
"SELECT x FROM sfile"
222281
" WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')"
223
- " ORDER BY 1");
282
+ " AND NOT %s"
283
+ " ORDER BY 1",
284
+ glob_expr("x", zIgnoreFlag)
285
+ );
224286
if( file_tree_name(g.zRepositoryName, &repo, 0) ){
225287
db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
226288
}
227289
while( db_step(&q)==SQLITE_ROW ){
228290
printf("%s\n", db_column_text(&q, 0));
229291
--- src/checkin.c
+++ src/checkin.c
@@ -193,14 +193,68 @@
193 }
194 free(zFullName);
195 }
196 db_finalize(&q);
197 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
199 /*
200 ** COMMAND: extras
201 ** Usage: %fossil extras ?--dotfiles?
202 **
203 ** Print a list of all files in the source tree that are not part of
204 ** the current checkout. See also the "clean" command.
205 **
206 ** Files and subdirectories whose names begin with "." are normally
@@ -209,20 +263,28 @@
209 void extra_cmd(void){
210 Blob path;
211 Blob repo;
212 Stmt q;
213 int n;
 
214 int allFlag = find_option("dotfiles",0,0)!=0;
 
215 db_must_be_within_tree();
216 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
217 n = strlen(g.zLocalRoot);
218 blob_init(&path, g.zLocalRoot, n-1);
 
 
 
219 vfile_scan(0, &path, blob_size(&path), allFlag);
220 db_prepare(&q,
221 "SELECT x FROM sfile"
222 " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')"
223 " ORDER BY 1");
 
 
 
224 if( file_tree_name(g.zRepositoryName, &repo, 0) ){
225 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
226 }
227 while( db_step(&q)==SQLITE_ROW ){
228 printf("%s\n", db_column_text(&q, 0));
229
--- src/checkin.c
+++ src/checkin.c
@@ -193,14 +193,68 @@
193 }
194 free(zFullName);
195 }
196 db_finalize(&q);
197 }
198
199 /*
200 ** Construct and return a string which is an SQL expression that will
201 ** be TRUE if value zVal matches any of the GLOB expressions in the list
202 ** zGlobList. For example:
203 **
204 ** zVal: "x"
205 ** zGlobList: "*.o,*.obj"
206 **
207 ** Result: "(x GLOB '*.o' OR x GLOB '*.obj')"
208 **
209 ** Each element of the GLOB list may optionally be enclosed in either '...'
210 ** or "...". This allows commas in the expression. Whitespace at the
211 ** beginning and end of each GLOB pattern is ignored, except when enclosed
212 ** within '...' or "...".
213 **
214 ** This routine makes no effort to free the memory space it uses.
215 */
216 char *glob_expr(const char *zVal, const char *zGlobList){
217 Blob expr;
218 char *zSep = "(";
219 int nTerm = 0;
220 int i;
221 int cTerm;
222
223 if( zGlobList==0 || zGlobList[0]==0 ) return "0";
224 blob_zero(&expr);
225 while( zGlobList[0] ){
226 while( isspace(zGlobList[0]) || zGlobList[0]==',' ) zGlobList++;
227 if( zGlobList[0]==0 ) break;
228 if( zGlobList[0]=='\'' || zGlobList[0]=='"' ){
229 cTerm = zGlobList[0];
230 zGlobList++;
231 }else{
232 cTerm = ',';
233 }
234 for(i=0; zGlobList[i] && zGlobList[i]!=cTerm; i++){}
235 if( cTerm==',' ){
236 while( i>0 && isspace(zGlobList[i-1]) ){ i--; }
237 }
238 blob_appendf(&expr, "%s%s GLOB '%.*q'", zSep, zVal, i, zGlobList);
239 zSep = " OR ";
240 if( cTerm!=',' && zGlobList[i] ) i++;
241 zGlobList += i;
242 if( zGlobList[0] ) zGlobList++;
243 nTerm++;
244 }
245 if( nTerm ){
246 blob_appendf(&expr, ")");
247 return blob_str(&expr);
248 }else{
249 return "0";
250 }
251 }
252
253 /*
254 ** COMMAND: extras
255 ** Usage: %fossil extras ?--dotfiles? ?--ignore GLOBPATTERN?
256 **
257 ** Print a list of all files in the source tree that are not part of
258 ** the current checkout. See also the "clean" command.
259 **
260 ** Files and subdirectories whose names begin with "." are normally
@@ -209,20 +263,28 @@
263 void extra_cmd(void){
264 Blob path;
265 Blob repo;
266 Stmt q;
267 int n;
268 const char *zIgnoreFlag = find_option("ignore",0,1);
269 int allFlag = find_option("dotfiles",0,0)!=0;
270
271 db_must_be_within_tree();
272 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
273 n = strlen(g.zLocalRoot);
274 blob_init(&path, g.zLocalRoot, n-1);
275 if( zIgnoreFlag==0 ){
276 zIgnoreFlag = db_get("ignore-glob", 0);
277 }
278 vfile_scan(0, &path, blob_size(&path), allFlag);
279 db_prepare(&q,
280 "SELECT x FROM sfile"
281 " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')"
282 " AND NOT %s"
283 " ORDER BY 1",
284 glob_expr("x", zIgnoreFlag)
285 );
286 if( file_tree_name(g.zRepositoryName, &repo, 0) ){
287 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
288 }
289 while( db_step(&q)==SQLITE_ROW ){
290 printf("%s\n", db_column_text(&q, 0));
291
+5
--- src/db.c
+++ src/db.c
@@ -1456,10 +1456,14 @@
14561456
** gdiff-command External command to run when performing a graphical
14571457
** diff. If undefined, text diff will be used.
14581458
**
14591459
** http-port The TCP/IP port number to use by the "server"
14601460
** and "ui" commands. Default: 8080
1461
+**
1462
+** ignore-glob The VALUE is a comma-separated list of GLOB patterns
1463
+** specifying files that the "extra" command will ignore.
1464
+** Example: *.o,*.obj,*.exe
14611465
**
14621466
** localauth If enabled, require that HTTP connections from
14631467
** 127.0.0.1 be authenticated by password. If
14641468
** false, all HTTP requests from localhost have
14651469
** unrestricted access to the repository.
@@ -1487,10 +1491,11 @@
14871491
"clearsign",
14881492
"diff-command",
14891493
"dont-push",
14901494
"editor",
14911495
"gdiff-command",
1496
+ "ignore-glob",
14921497
"http-port",
14931498
"localauth",
14941499
"mtime-changes",
14951500
"pgp-command",
14961501
"proxy",
14971502
--- src/db.c
+++ src/db.c
@@ -1456,10 +1456,14 @@
1456 ** gdiff-command External command to run when performing a graphical
1457 ** diff. If undefined, text diff will be used.
1458 **
1459 ** http-port The TCP/IP port number to use by the "server"
1460 ** and "ui" commands. Default: 8080
 
 
 
 
1461 **
1462 ** localauth If enabled, require that HTTP connections from
1463 ** 127.0.0.1 be authenticated by password. If
1464 ** false, all HTTP requests from localhost have
1465 ** unrestricted access to the repository.
@@ -1487,10 +1491,11 @@
1487 "clearsign",
1488 "diff-command",
1489 "dont-push",
1490 "editor",
1491 "gdiff-command",
 
1492 "http-port",
1493 "localauth",
1494 "mtime-changes",
1495 "pgp-command",
1496 "proxy",
1497
--- src/db.c
+++ src/db.c
@@ -1456,10 +1456,14 @@
1456 ** gdiff-command External command to run when performing a graphical
1457 ** diff. If undefined, text diff will be used.
1458 **
1459 ** http-port The TCP/IP port number to use by the "server"
1460 ** and "ui" commands. Default: 8080
1461 **
1462 ** ignore-glob The VALUE is a comma-separated list of GLOB patterns
1463 ** specifying files that the "extra" command will ignore.
1464 ** Example: *.o,*.obj,*.exe
1465 **
1466 ** localauth If enabled, require that HTTP connections from
1467 ** 127.0.0.1 be authenticated by password. If
1468 ** false, all HTTP requests from localhost have
1469 ** unrestricted access to the repository.
@@ -1487,10 +1491,11 @@
1491 "clearsign",
1492 "diff-command",
1493 "dont-push",
1494 "editor",
1495 "gdiff-command",
1496 "ignore-glob",
1497 "http-port",
1498 "localauth",
1499 "mtime-changes",
1500 "pgp-command",
1501 "proxy",
1502

Keyboard Shortcuts

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