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].
Commit
3555c0fc6fd0d1684422c729ac6a571ec3762715
Parent
611b3b206bdfea6…
2 files changed
+64
-2
+5
+64
-2
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -193,14 +193,68 @@ | ||
| 193 | 193 | } |
| 194 | 194 | free(zFullName); |
| 195 | 195 | } |
| 196 | 196 | db_finalize(&q); |
| 197 | 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 | +} | |
| 198 | 252 | |
| 199 | 253 | /* |
| 200 | 254 | ** COMMAND: extras |
| 201 | -** Usage: %fossil extras ?--dotfiles? | |
| 255 | +** Usage: %fossil extras ?--dotfiles? ?--ignore GLOBPATTERN? | |
| 202 | 256 | ** |
| 203 | 257 | ** Print a list of all files in the source tree that are not part of |
| 204 | 258 | ** the current checkout. See also the "clean" command. |
| 205 | 259 | ** |
| 206 | 260 | ** Files and subdirectories whose names begin with "." are normally |
| @@ -209,20 +263,28 @@ | ||
| 209 | 263 | void extra_cmd(void){ |
| 210 | 264 | Blob path; |
| 211 | 265 | Blob repo; |
| 212 | 266 | Stmt q; |
| 213 | 267 | int n; |
| 268 | + const char *zIgnoreFlag = find_option("ignore",0,1); | |
| 214 | 269 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 270 | + | |
| 215 | 271 | db_must_be_within_tree(); |
| 216 | 272 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 217 | 273 | n = strlen(g.zLocalRoot); |
| 218 | 274 | blob_init(&path, g.zLocalRoot, n-1); |
| 275 | + if( zIgnoreFlag==0 ){ | |
| 276 | + zIgnoreFlag = db_get("ignore-glob", 0); | |
| 277 | + } | |
| 219 | 278 | vfile_scan(0, &path, blob_size(&path), allFlag); |
| 220 | 279 | db_prepare(&q, |
| 221 | 280 | "SELECT x FROM sfile" |
| 222 | 281 | " 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 | + ); | |
| 224 | 286 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 225 | 287 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 226 | 288 | } |
| 227 | 289 | while( db_step(&q)==SQLITE_ROW ){ |
| 228 | 290 | printf("%s\n", db_column_text(&q, 0)); |
| 229 | 291 |
| --- 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 |
M
src/db.c
+5
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1456,10 +1456,14 @@ | ||
| 1456 | 1456 | ** gdiff-command External command to run when performing a graphical |
| 1457 | 1457 | ** diff. If undefined, text diff will be used. |
| 1458 | 1458 | ** |
| 1459 | 1459 | ** http-port The TCP/IP port number to use by the "server" |
| 1460 | 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 | |
| 1461 | 1465 | ** |
| 1462 | 1466 | ** localauth If enabled, require that HTTP connections from |
| 1463 | 1467 | ** 127.0.0.1 be authenticated by password. If |
| 1464 | 1468 | ** false, all HTTP requests from localhost have |
| 1465 | 1469 | ** unrestricted access to the repository. |
| @@ -1487,10 +1491,11 @@ | ||
| 1487 | 1491 | "clearsign", |
| 1488 | 1492 | "diff-command", |
| 1489 | 1493 | "dont-push", |
| 1490 | 1494 | "editor", |
| 1491 | 1495 | "gdiff-command", |
| 1496 | + "ignore-glob", | |
| 1492 | 1497 | "http-port", |
| 1493 | 1498 | "localauth", |
| 1494 | 1499 | "mtime-changes", |
| 1495 | 1500 | "pgp-command", |
| 1496 | 1501 | "proxy", |
| 1497 | 1502 |
| --- 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 |