Fossil SCM
Add the --dotfiles option to the "extra" and "clean" commands. Ticket [4de876322f066].
Commit
a2749215b71b297780c2b787a938eae82edf32b7
Parent
e0131b1a661b6b2…
2 files changed
+15
-5
+7
-3
+15
-5
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -164,25 +164,29 @@ | ||
| 164 | 164 | db_finalize(&q); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /* |
| 168 | 168 | ** COMMAND: extras |
| 169 | -** Usage: %fossil extras | |
| 169 | +** Usage: %fossil extras ?--dotfiles? | |
| 170 | 170 | ** |
| 171 | 171 | ** Print a list of all files in the source tree that are not part of |
| 172 | 172 | ** the current checkout. See also the "clean" command. |
| 173 | +** | |
| 174 | +** Files and subdirectories whose names begin with "." are normally | |
| 175 | +** ignored but can be included by adding the --dotfiles option. | |
| 173 | 176 | */ |
| 174 | 177 | void extra_cmd(void){ |
| 175 | 178 | Blob path; |
| 176 | 179 | Blob repo; |
| 177 | 180 | Stmt q; |
| 178 | 181 | int n; |
| 182 | + int allFlag = find_option("dotfiles",0,0)!=0; | |
| 179 | 183 | db_must_be_within_tree(); |
| 180 | 184 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 181 | 185 | n = strlen(g.zLocalRoot); |
| 182 | 186 | blob_init(&path, g.zLocalRoot, n-1); |
| 183 | - vfile_scan(0, &path, blob_size(&path)); | |
| 187 | + vfile_scan(0, &path, blob_size(&path), allFlag); | |
| 184 | 188 | db_prepare(&q, |
| 185 | 189 | "SELECT x FROM sfile" |
| 186 | 190 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 187 | 191 | " ORDER BY 1"); |
| 188 | 192 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| @@ -194,31 +198,37 @@ | ||
| 194 | 198 | db_finalize(&q); |
| 195 | 199 | } |
| 196 | 200 | |
| 197 | 201 | /* |
| 198 | 202 | ** COMMAND: clean |
| 199 | -** Usage: %fossil clean ?-all? | |
| 203 | +** Usage: %fossil clean ?--force? ?--dotfiles? | |
| 200 | 204 | ** |
| 201 | 205 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 202 | 206 | ** files that are not officially part of the checkout. See also |
| 203 | 207 | ** the "extra" command. This operation cannot be undone. |
| 204 | 208 | ** |
| 205 | 209 | ** You will be prompted before removing each file. If you are |
| 206 | 210 | ** sure you wish to remove all "extra" files you can specify the |
| 207 | -** optional -all flag. | |
| 211 | +** optional --force flag and no prmpts will be issued. | |
| 212 | +** | |
| 213 | +** Files and subdirectories whose names begin with "." are | |
| 214 | +** normally ignored. They are included if the "--dotfiles" option | |
| 215 | +** is used. | |
| 208 | 216 | */ |
| 209 | 217 | void clean_cmd(void){ |
| 210 | 218 | int allFlag; |
| 219 | + int dotfilesFlag; | |
| 211 | 220 | Blob path, repo; |
| 212 | 221 | Stmt q; |
| 213 | 222 | int n; |
| 214 | 223 | allFlag = find_option("all","a",0)!=0; |
| 224 | + dotfilesFlag = find_option("dotfiles",0,0)!=0; | |
| 215 | 225 | db_must_be_within_tree(); |
| 216 | 226 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 217 | 227 | n = strlen(g.zLocalRoot); |
| 218 | 228 | blob_init(&path, g.zLocalRoot, n-1); |
| 219 | - vfile_scan(0, &path, blob_size(&path)); | |
| 229 | + vfile_scan(0, &path, blob_size(&path), dotfilesFlag); | |
| 220 | 230 | db_prepare(&q, |
| 221 | 231 | "SELECT %Q || x FROM sfile" |
| 222 | 232 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 223 | 233 | " ORDER BY 1", g.zLocalRoot); |
| 224 | 234 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 225 | 235 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -164,25 +164,29 @@ | |
| 164 | db_finalize(&q); |
| 165 | } |
| 166 | |
| 167 | /* |
| 168 | ** COMMAND: extras |
| 169 | ** Usage: %fossil extras |
| 170 | ** |
| 171 | ** Print a list of all files in the source tree that are not part of |
| 172 | ** the current checkout. See also the "clean" command. |
| 173 | */ |
| 174 | void extra_cmd(void){ |
| 175 | Blob path; |
| 176 | Blob repo; |
| 177 | Stmt q; |
| 178 | int n; |
| 179 | db_must_be_within_tree(); |
| 180 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 181 | n = strlen(g.zLocalRoot); |
| 182 | blob_init(&path, g.zLocalRoot, n-1); |
| 183 | vfile_scan(0, &path, blob_size(&path)); |
| 184 | db_prepare(&q, |
| 185 | "SELECT x FROM sfile" |
| 186 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 187 | " ORDER BY 1"); |
| 188 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| @@ -194,31 +198,37 @@ | |
| 194 | db_finalize(&q); |
| 195 | } |
| 196 | |
| 197 | /* |
| 198 | ** COMMAND: clean |
| 199 | ** Usage: %fossil clean ?-all? |
| 200 | ** |
| 201 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 202 | ** files that are not officially part of the checkout. See also |
| 203 | ** the "extra" command. This operation cannot be undone. |
| 204 | ** |
| 205 | ** You will be prompted before removing each file. If you are |
| 206 | ** sure you wish to remove all "extra" files you can specify the |
| 207 | ** optional -all flag. |
| 208 | */ |
| 209 | void clean_cmd(void){ |
| 210 | int allFlag; |
| 211 | Blob path, repo; |
| 212 | Stmt q; |
| 213 | int n; |
| 214 | allFlag = find_option("all","a",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)); |
| 220 | db_prepare(&q, |
| 221 | "SELECT %Q || x FROM sfile" |
| 222 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 223 | " ORDER BY 1", g.zLocalRoot); |
| 224 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 225 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -164,25 +164,29 @@ | |
| 164 | db_finalize(&q); |
| 165 | } |
| 166 | |
| 167 | /* |
| 168 | ** COMMAND: extras |
| 169 | ** Usage: %fossil extras ?--dotfiles? |
| 170 | ** |
| 171 | ** Print a list of all files in the source tree that are not part of |
| 172 | ** the current checkout. See also the "clean" command. |
| 173 | ** |
| 174 | ** Files and subdirectories whose names begin with "." are normally |
| 175 | ** ignored but can be included by adding the --dotfiles option. |
| 176 | */ |
| 177 | void extra_cmd(void){ |
| 178 | Blob path; |
| 179 | Blob repo; |
| 180 | Stmt q; |
| 181 | int n; |
| 182 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 183 | db_must_be_within_tree(); |
| 184 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 185 | n = strlen(g.zLocalRoot); |
| 186 | blob_init(&path, g.zLocalRoot, n-1); |
| 187 | vfile_scan(0, &path, blob_size(&path), allFlag); |
| 188 | db_prepare(&q, |
| 189 | "SELECT x FROM sfile" |
| 190 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 191 | " ORDER BY 1"); |
| 192 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| @@ -194,31 +198,37 @@ | |
| 198 | db_finalize(&q); |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | ** COMMAND: clean |
| 203 | ** Usage: %fossil clean ?--force? ?--dotfiles? |
| 204 | ** |
| 205 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 206 | ** files that are not officially part of the checkout. See also |
| 207 | ** the "extra" command. This operation cannot be undone. |
| 208 | ** |
| 209 | ** You will be prompted before removing each file. If you are |
| 210 | ** sure you wish to remove all "extra" files you can specify the |
| 211 | ** optional --force flag and no prmpts will be issued. |
| 212 | ** |
| 213 | ** Files and subdirectories whose names begin with "." are |
| 214 | ** normally ignored. They are included if the "--dotfiles" option |
| 215 | ** is used. |
| 216 | */ |
| 217 | void clean_cmd(void){ |
| 218 | int allFlag; |
| 219 | int dotfilesFlag; |
| 220 | Blob path, repo; |
| 221 | Stmt q; |
| 222 | int n; |
| 223 | allFlag = find_option("all","a",0)!=0; |
| 224 | dotfilesFlag = find_option("dotfiles",0,0)!=0; |
| 225 | db_must_be_within_tree(); |
| 226 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 227 | n = strlen(g.zLocalRoot); |
| 228 | blob_init(&path, g.zLocalRoot, n-1); |
| 229 | vfile_scan(0, &path, blob_size(&path), dotfilesFlag); |
| 230 | db_prepare(&q, |
| 231 | "SELECT %Q || x FROM sfile" |
| 232 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 233 | " ORDER BY 1", g.zLocalRoot); |
| 234 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 235 |
+7
-3
| --- src/vfile.c | ||
| +++ src/vfile.c | ||
| @@ -259,11 +259,11 @@ | ||
| 259 | 259 | ** of pPath when inserting into the SFILE table. |
| 260 | 260 | ** |
| 261 | 261 | ** Subdirectories are scanned recursively. |
| 262 | 262 | ** Omit files named in VFILE.vid |
| 263 | 263 | */ |
| 264 | -void vfile_scan(int vid, Blob *pPath, int nPrefix){ | |
| 264 | +void vfile_scan(int vid, Blob *pPath, int nPrefix, int allFlag){ | |
| 265 | 265 | DIR *d; |
| 266 | 266 | int origSize; |
| 267 | 267 | const char *zDir; |
| 268 | 268 | struct dirent *pEntry; |
| 269 | 269 | static const char *zSql = "SELECT 1 FROM vfile " |
| @@ -273,15 +273,19 @@ | ||
| 273 | 273 | zDir = blob_str(pPath); |
| 274 | 274 | d = opendir(zDir); |
| 275 | 275 | if( d ){ |
| 276 | 276 | while( (pEntry=readdir(d))!=0 ){ |
| 277 | 277 | char *zPath; |
| 278 | - if( pEntry->d_name[0]=='.' ) continue; | |
| 278 | + if( pEntry->d_name[0]=='.' ){ | |
| 279 | + if( !allFlag ) continue; | |
| 280 | + if( pEntry->d_name[1]==0 ) continue; | |
| 281 | + if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; | |
| 282 | + } | |
| 279 | 283 | blob_appendf(pPath, "/%s", pEntry->d_name); |
| 280 | 284 | zPath = blob_str(pPath); |
| 281 | 285 | if( file_isdir(zPath)==1 ){ |
| 282 | - vfile_scan(vid, pPath, nPrefix); | |
| 286 | + vfile_scan(vid, pPath, nPrefix, allFlag); | |
| 283 | 287 | }else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){ |
| 284 | 288 | db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]); |
| 285 | 289 | } |
| 286 | 290 | blob_resize(pPath, origSize); |
| 287 | 291 | } |
| 288 | 292 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -259,11 +259,11 @@ | |
| 259 | ** of pPath when inserting into the SFILE table. |
| 260 | ** |
| 261 | ** Subdirectories are scanned recursively. |
| 262 | ** Omit files named in VFILE.vid |
| 263 | */ |
| 264 | void vfile_scan(int vid, Blob *pPath, int nPrefix){ |
| 265 | DIR *d; |
| 266 | int origSize; |
| 267 | const char *zDir; |
| 268 | struct dirent *pEntry; |
| 269 | static const char *zSql = "SELECT 1 FROM vfile " |
| @@ -273,15 +273,19 @@ | |
| 273 | zDir = blob_str(pPath); |
| 274 | d = opendir(zDir); |
| 275 | if( d ){ |
| 276 | while( (pEntry=readdir(d))!=0 ){ |
| 277 | char *zPath; |
| 278 | if( pEntry->d_name[0]=='.' ) continue; |
| 279 | blob_appendf(pPath, "/%s", pEntry->d_name); |
| 280 | zPath = blob_str(pPath); |
| 281 | if( file_isdir(zPath)==1 ){ |
| 282 | vfile_scan(vid, pPath, nPrefix); |
| 283 | }else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){ |
| 284 | db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]); |
| 285 | } |
| 286 | blob_resize(pPath, origSize); |
| 287 | } |
| 288 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -259,11 +259,11 @@ | |
| 259 | ** of pPath when inserting into the SFILE table. |
| 260 | ** |
| 261 | ** Subdirectories are scanned recursively. |
| 262 | ** Omit files named in VFILE.vid |
| 263 | */ |
| 264 | void vfile_scan(int vid, Blob *pPath, int nPrefix, int allFlag){ |
| 265 | DIR *d; |
| 266 | int origSize; |
| 267 | const char *zDir; |
| 268 | struct dirent *pEntry; |
| 269 | static const char *zSql = "SELECT 1 FROM vfile " |
| @@ -273,15 +273,19 @@ | |
| 273 | zDir = blob_str(pPath); |
| 274 | d = opendir(zDir); |
| 275 | if( d ){ |
| 276 | while( (pEntry=readdir(d))!=0 ){ |
| 277 | char *zPath; |
| 278 | if( pEntry->d_name[0]=='.' ){ |
| 279 | if( !allFlag ) continue; |
| 280 | if( pEntry->d_name[1]==0 ) continue; |
| 281 | if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; |
| 282 | } |
| 283 | blob_appendf(pPath, "/%s", pEntry->d_name); |
| 284 | zPath = blob_str(pPath); |
| 285 | if( file_isdir(zPath)==1 ){ |
| 286 | vfile_scan(vid, pPath, nPrefix, allFlag); |
| 287 | }else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){ |
| 288 | db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]); |
| 289 | } |
| 290 | blob_resize(pPath, origSize); |
| 291 | } |
| 292 |