Fossil SCM
Avoid the use of chdir() since this seems to cause problems on windows.
Commit
849b94c6317f855aed30ed371f75229c13cfe038
Parent
b3ee50c94632149…
2 files changed
+8
-6
+10
-14
+8
-6
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -155,15 +155,16 @@ | ||
| 155 | 155 | ** the current checkout. See also the "clean" command. |
| 156 | 156 | */ |
| 157 | 157 | void extra_cmd(void){ |
| 158 | 158 | Blob path; |
| 159 | 159 | Stmt q; |
| 160 | + int n; | |
| 160 | 161 | db_must_be_within_tree(); |
| 161 | 162 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 162 | - chdir(g.zLocalRoot); | |
| 163 | - blob_zero(&path); | |
| 164 | - vfile_scan(0, &path); | |
| 163 | + n = strlen(g.zLocalRoot); | |
| 164 | + blob_init(&path, g.zLocalRoot, n-1); | |
| 165 | + vfile_scan(0, &path, blob_size(&path)); | |
| 165 | 166 | db_prepare(&q, |
| 166 | 167 | "SELECT x FROM sfile" |
| 167 | 168 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 168 | 169 | " ORDER BY 1"); |
| 169 | 170 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -186,16 +187,17 @@ | ||
| 186 | 187 | */ |
| 187 | 188 | void clean_cmd(void){ |
| 188 | 189 | int allFlag; |
| 189 | 190 | Blob path; |
| 190 | 191 | Stmt q; |
| 192 | + int n; | |
| 191 | 193 | allFlag = find_option("all","a",0)!=0; |
| 192 | 194 | db_must_be_within_tree(); |
| 193 | 195 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 194 | - chdir(g.zLocalRoot); | |
| 195 | - blob_zero(&path); | |
| 196 | - vfile_scan(0, &path); | |
| 196 | + n = strlen(g.zLocalRoot); | |
| 197 | + blob_init(&path, g.zLocalRoot, n-1); | |
| 198 | + vfile_scan(0, &path, blob_size(&path)); | |
| 197 | 199 | db_prepare(&q, |
| 198 | 200 | "SELECT %Q || x FROM sfile" |
| 199 | 201 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 200 | 202 | " ORDER BY 1", g.zLocalRoot); |
| 201 | 203 | while( db_step(&q)==SQLITE_ROW ){ |
| 202 | 204 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -155,15 +155,16 @@ | |
| 155 | ** the current checkout. See also the "clean" command. |
| 156 | */ |
| 157 | void extra_cmd(void){ |
| 158 | Blob path; |
| 159 | Stmt q; |
| 160 | db_must_be_within_tree(); |
| 161 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 162 | chdir(g.zLocalRoot); |
| 163 | blob_zero(&path); |
| 164 | vfile_scan(0, &path); |
| 165 | db_prepare(&q, |
| 166 | "SELECT x FROM sfile" |
| 167 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 168 | " ORDER BY 1"); |
| 169 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -186,16 +187,17 @@ | |
| 186 | */ |
| 187 | void clean_cmd(void){ |
| 188 | int allFlag; |
| 189 | Blob path; |
| 190 | Stmt q; |
| 191 | allFlag = find_option("all","a",0)!=0; |
| 192 | db_must_be_within_tree(); |
| 193 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 194 | chdir(g.zLocalRoot); |
| 195 | blob_zero(&path); |
| 196 | vfile_scan(0, &path); |
| 197 | db_prepare(&q, |
| 198 | "SELECT %Q || x FROM sfile" |
| 199 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 200 | " ORDER BY 1", g.zLocalRoot); |
| 201 | while( db_step(&q)==SQLITE_ROW ){ |
| 202 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -155,15 +155,16 @@ | |
| 155 | ** the current checkout. See also the "clean" command. |
| 156 | */ |
| 157 | void extra_cmd(void){ |
| 158 | Blob path; |
| 159 | Stmt q; |
| 160 | int n; |
| 161 | db_must_be_within_tree(); |
| 162 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 163 | n = strlen(g.zLocalRoot); |
| 164 | blob_init(&path, g.zLocalRoot, n-1); |
| 165 | vfile_scan(0, &path, blob_size(&path)); |
| 166 | db_prepare(&q, |
| 167 | "SELECT x FROM sfile" |
| 168 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 169 | " ORDER BY 1"); |
| 170 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -186,16 +187,17 @@ | |
| 187 | */ |
| 188 | void clean_cmd(void){ |
| 189 | int allFlag; |
| 190 | Blob path; |
| 191 | Stmt q; |
| 192 | int n; |
| 193 | allFlag = find_option("all","a",0)!=0; |
| 194 | db_must_be_within_tree(); |
| 195 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 196 | n = strlen(g.zLocalRoot); |
| 197 | blob_init(&path, g.zLocalRoot, n-1); |
| 198 | vfile_scan(0, &path, blob_size(&path)); |
| 199 | db_prepare(&q, |
| 200 | "SELECT %Q || x FROM sfile" |
| 201 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 202 | " ORDER BY 1", g.zLocalRoot); |
| 203 | while( db_step(&q)==SQLITE_ROW ){ |
| 204 |
+10
-14
| --- src/vfile.c | ||
| +++ src/vfile.c | ||
| @@ -240,41 +240,37 @@ | ||
| 240 | 240 | db_finalize(&q); |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /* |
| 244 | 244 | ** Load into table SFILE the name of every ordinary file in |
| 245 | -** the directory pPath. Subdirectories are scanned recursively. | |
| 245 | +** the directory pPath. Omit the first nPrefix characters of | |
| 246 | +** of pPath when inserting into the SFILE table. | |
| 247 | +** | |
| 248 | +** Subdirectories are scanned recursively. | |
| 246 | 249 | ** Omit files named in VFILE.vid |
| 247 | 250 | */ |
| 248 | -void vfile_scan(int vid, Blob *pPath){ | |
| 251 | +void vfile_scan(int vid, Blob *pPath, int nPrefix){ | |
| 249 | 252 | DIR *d; |
| 250 | 253 | int origSize; |
| 251 | 254 | const char *zDir; |
| 252 | - const char *zFormat; | |
| 253 | 255 | struct dirent *pEntry; |
| 254 | 256 | static const char *zSql = "SELECT 1 FROM vfile " |
| 255 | - " WHERE pathname=%B AND NOT deleted"; | |
| 257 | + " WHERE pathname=%Q AND NOT deleted"; | |
| 256 | 258 | |
| 257 | 259 | origSize = blob_size(pPath); |
| 258 | 260 | zDir = blob_str(pPath); |
| 259 | - if( zDir[0]==0 ){ | |
| 260 | - zDir = "."; | |
| 261 | - zFormat = "%s"; | |
| 262 | - }else{ | |
| 263 | - zFormat = "/%s"; | |
| 264 | - } | |
| 265 | 261 | d = opendir(zDir); |
| 266 | 262 | if( d ){ |
| 267 | 263 | while( (pEntry=readdir(d))!=0 ){ |
| 268 | 264 | char *zPath; |
| 269 | 265 | if( pEntry->d_name[0]=='.' ) continue; |
| 270 | - blob_appendf(pPath, zFormat, pEntry->d_name); | |
| 266 | + blob_appendf(pPath, "/%s", pEntry->d_name); | |
| 271 | 267 | zPath = blob_str(pPath); |
| 272 | 268 | if( file_isdir(zPath)==1 ){ |
| 273 | - vfile_scan(vid, pPath); | |
| 274 | - }else if( file_isfile(zPath) && !db_exists(zSql,pPath) ){ | |
| 275 | - db_multi_exec("INSERT INTO sfile VALUES(%B)", pPath); | |
| 269 | + vfile_scan(vid, pPath, nPrefix); | |
| 270 | + }else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){ | |
| 271 | + db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]); | |
| 276 | 272 | } |
| 277 | 273 | blob_resize(pPath, origSize); |
| 278 | 274 | } |
| 279 | 275 | } |
| 280 | 276 | closedir(d); |
| 281 | 277 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -240,41 +240,37 @@ | |
| 240 | db_finalize(&q); |
| 241 | } |
| 242 | |
| 243 | /* |
| 244 | ** Load into table SFILE the name of every ordinary file in |
| 245 | ** the directory pPath. Subdirectories are scanned recursively. |
| 246 | ** Omit files named in VFILE.vid |
| 247 | */ |
| 248 | void vfile_scan(int vid, Blob *pPath){ |
| 249 | DIR *d; |
| 250 | int origSize; |
| 251 | const char *zDir; |
| 252 | const char *zFormat; |
| 253 | struct dirent *pEntry; |
| 254 | static const char *zSql = "SELECT 1 FROM vfile " |
| 255 | " WHERE pathname=%B AND NOT deleted"; |
| 256 | |
| 257 | origSize = blob_size(pPath); |
| 258 | zDir = blob_str(pPath); |
| 259 | if( zDir[0]==0 ){ |
| 260 | zDir = "."; |
| 261 | zFormat = "%s"; |
| 262 | }else{ |
| 263 | zFormat = "/%s"; |
| 264 | } |
| 265 | d = opendir(zDir); |
| 266 | if( d ){ |
| 267 | while( (pEntry=readdir(d))!=0 ){ |
| 268 | char *zPath; |
| 269 | if( pEntry->d_name[0]=='.' ) continue; |
| 270 | blob_appendf(pPath, zFormat, pEntry->d_name); |
| 271 | zPath = blob_str(pPath); |
| 272 | if( file_isdir(zPath)==1 ){ |
| 273 | vfile_scan(vid, pPath); |
| 274 | }else if( file_isfile(zPath) && !db_exists(zSql,pPath) ){ |
| 275 | db_multi_exec("INSERT INTO sfile VALUES(%B)", pPath); |
| 276 | } |
| 277 | blob_resize(pPath, origSize); |
| 278 | } |
| 279 | } |
| 280 | closedir(d); |
| 281 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -240,41 +240,37 @@ | |
| 240 | db_finalize(&q); |
| 241 | } |
| 242 | |
| 243 | /* |
| 244 | ** Load into table SFILE the name of every ordinary file in |
| 245 | ** the directory pPath. Omit the first nPrefix characters of |
| 246 | ** of pPath when inserting into the SFILE table. |
| 247 | ** |
| 248 | ** Subdirectories are scanned recursively. |
| 249 | ** Omit files named in VFILE.vid |
| 250 | */ |
| 251 | void vfile_scan(int vid, Blob *pPath, int nPrefix){ |
| 252 | DIR *d; |
| 253 | int origSize; |
| 254 | const char *zDir; |
| 255 | struct dirent *pEntry; |
| 256 | static const char *zSql = "SELECT 1 FROM vfile " |
| 257 | " WHERE pathname=%Q AND NOT deleted"; |
| 258 | |
| 259 | origSize = blob_size(pPath); |
| 260 | zDir = blob_str(pPath); |
| 261 | d = opendir(zDir); |
| 262 | if( d ){ |
| 263 | while( (pEntry=readdir(d))!=0 ){ |
| 264 | char *zPath; |
| 265 | if( pEntry->d_name[0]=='.' ) continue; |
| 266 | blob_appendf(pPath, "/%s", pEntry->d_name); |
| 267 | zPath = blob_str(pPath); |
| 268 | if( file_isdir(zPath)==1 ){ |
| 269 | vfile_scan(vid, pPath, nPrefix); |
| 270 | }else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){ |
| 271 | db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]); |
| 272 | } |
| 273 | blob_resize(pPath, origSize); |
| 274 | } |
| 275 | } |
| 276 | closedir(d); |
| 277 |