Fossil SCM

Get the "fossil all ui" command working on windows systems where the global_config table has "repo:" entries that omit the drive letter.

drh 2016-12-01 21:56 trunk
Commit 25758c7b1c8319a91a520e9afe3849e0cee18ca8
1 file changed +18 -19
+18 -19
--- src/main.c
+++ src/main.c
@@ -1201,35 +1201,29 @@
12011201
** return 0.
12021202
*/
12031203
static int repo_list_page(void){
12041204
Blob base;
12051205
int n = 0;
1206
+ int allRepo;
12061207
12071208
assert( g.db==0 );
12081209
if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){
12091210
/* For the special case of the "repository directory" being "/",
12101211
** show all of the repositories named in the ~/.fossil database.
12111212
**
12121213
** On unix systems, then entries are of the form "repo:/home/..."
1213
- ** and on Windows systems they are like "repo:C:/Users/...". We want
1214
- ** to skip the first 6 characters on unix and the first 5 characters
1215
- ** on Windows.
1216
- */
1217
- db_open_config(1, 0);
1218
-#ifdef _WIN32
1219
- db_multi_exec(
1220
- "CREATE TEMP VIEW sfile AS"
1221
- " SELECT substr(name,6) AS 'pathname' FROM global_config"
1222
- " WHERE name GLOB 'repo:*'"
1223
- );
1224
-#else
1225
- db_multi_exec(
1226
- "CREATE TEMP VIEW sfile AS"
1227
- " SELECT substr(name,7) AS 'pathname' FROM global_config"
1228
- " WHERE name GLOB 'repo:*'"
1229
- );
1230
-#endif
1214
+ ** and on Windows systems they are like on unix, starting with a "/"
1215
+ ** or they can begin with a drive letter: "repo:C:/Users/...". In either
1216
+ ** case, we want returned path to omit any initial "/".
1217
+ */
1218
+ db_open_config(1, 0);
1219
+ db_multi_exec(
1220
+ "CREATE TEMP VIEW sfile AS"
1221
+ " SELECT ltrim(substr(name,6),'/') AS 'pathname' FROM global_config"
1222
+ " WHERE name GLOB 'repo:*'"
1223
+ );
1224
+ allRepo = 1;
12311225
}else{
12321226
/* The default case: All repositories under the g.zRepositoryName
12331227
** directory.
12341228
*/
12351229
blob_init(&base, g.zRepositoryName, -1);
@@ -1236,10 +1230,11 @@
12361230
sqlite3_open(":memory:", &g.db);
12371231
db_multi_exec("CREATE TABLE sfile(pathname TEXT);");
12381232
db_multi_exec("CREATE TABLE vfile(pathname);");
12391233
vfile_scan(&base, blob_size(&base), 0, 0, 0);
12401234
db_multi_exec("DELETE FROM sfile WHERE pathname NOT GLOB '*[^/].fossil'");
1235
+ allRepo = 0;
12411236
}
12421237
@ <html>
12431238
@ <head>
12441239
@ <base href="%s(g.zBaseURL)/" />
12451240
@ <title>Repository List</title>
@@ -1253,11 +1248,15 @@
12531248
db_prepare(&q, "SELECT pathname, substr(pathname,-7,-100000)||'/home'"
12541249
" FROM sfile ORDER BY pathname COLLATE nocase;");
12551250
while( db_step(&q)==SQLITE_ROW ){
12561251
const char *zName = db_column_text(&q, 0);
12571252
const char *zUrl = db_column_text(&q, 1);
1258
- @ <li><a href="%R/%T(zUrl)" target="_blank">%h(zName)</a></li>
1253
+ if( allRepo && sqlite3_strglob("[a-zA-Z]:/?*", zName)!=0 ){
1254
+ @ <li><a href="%R/%T(zUrl)" target="_blank">/%h(zName)</a></li>
1255
+ }else{
1256
+ @ <li><a href="%R/%T(zUrl)" target="_blank">%h(zName)</a></li>
1257
+ }
12591258
}
12601259
@ </ol>
12611260
}else{
12621261
@ <h1>No Repositories Found</h1>
12631262
}
12641263
--- src/main.c
+++ src/main.c
@@ -1201,35 +1201,29 @@
1201 ** return 0.
1202 */
1203 static int repo_list_page(void){
1204 Blob base;
1205 int n = 0;
 
1206
1207 assert( g.db==0 );
1208 if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){
1209 /* For the special case of the "repository directory" being "/",
1210 ** show all of the repositories named in the ~/.fossil database.
1211 **
1212 ** On unix systems, then entries are of the form "repo:/home/..."
1213 ** and on Windows systems they are like "repo:C:/Users/...". We want
1214 ** to skip the first 6 characters on unix and the first 5 characters
1215 ** on Windows.
1216 */
1217 db_open_config(1, 0);
1218 #ifdef _WIN32
1219 db_multi_exec(
1220 "CREATE TEMP VIEW sfile AS"
1221 " SELECT substr(name,6) AS 'pathname' FROM global_config"
1222 " WHERE name GLOB 'repo:*'"
1223 );
1224 #else
1225 db_multi_exec(
1226 "CREATE TEMP VIEW sfile AS"
1227 " SELECT substr(name,7) AS 'pathname' FROM global_config"
1228 " WHERE name GLOB 'repo:*'"
1229 );
1230 #endif
1231 }else{
1232 /* The default case: All repositories under the g.zRepositoryName
1233 ** directory.
1234 */
1235 blob_init(&base, g.zRepositoryName, -1);
@@ -1236,10 +1230,11 @@
1236 sqlite3_open(":memory:", &g.db);
1237 db_multi_exec("CREATE TABLE sfile(pathname TEXT);");
1238 db_multi_exec("CREATE TABLE vfile(pathname);");
1239 vfile_scan(&base, blob_size(&base), 0, 0, 0);
1240 db_multi_exec("DELETE FROM sfile WHERE pathname NOT GLOB '*[^/].fossil'");
 
1241 }
1242 @ <html>
1243 @ <head>
1244 @ <base href="%s(g.zBaseURL)/" />
1245 @ <title>Repository List</title>
@@ -1253,11 +1248,15 @@
1253 db_prepare(&q, "SELECT pathname, substr(pathname,-7,-100000)||'/home'"
1254 " FROM sfile ORDER BY pathname COLLATE nocase;");
1255 while( db_step(&q)==SQLITE_ROW ){
1256 const char *zName = db_column_text(&q, 0);
1257 const char *zUrl = db_column_text(&q, 1);
1258 @ <li><a href="%R/%T(zUrl)" target="_blank">%h(zName)</a></li>
 
 
 
 
1259 }
1260 @ </ol>
1261 }else{
1262 @ <h1>No Repositories Found</h1>
1263 }
1264
--- src/main.c
+++ src/main.c
@@ -1201,35 +1201,29 @@
1201 ** return 0.
1202 */
1203 static int repo_list_page(void){
1204 Blob base;
1205 int n = 0;
1206 int allRepo;
1207
1208 assert( g.db==0 );
1209 if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){
1210 /* For the special case of the "repository directory" being "/",
1211 ** show all of the repositories named in the ~/.fossil database.
1212 **
1213 ** On unix systems, then entries are of the form "repo:/home/..."
1214 ** and on Windows systems they are like on unix, starting with a "/"
1215 ** or they can begin with a drive letter: "repo:C:/Users/...". In either
1216 ** case, we want returned path to omit any initial "/".
1217 */
1218 db_open_config(1, 0);
1219 db_multi_exec(
1220 "CREATE TEMP VIEW sfile AS"
1221 " SELECT ltrim(substr(name,6),'/') AS 'pathname' FROM global_config"
1222 " WHERE name GLOB 'repo:*'"
1223 );
1224 allRepo = 1;
 
 
 
 
 
 
 
1225 }else{
1226 /* The default case: All repositories under the g.zRepositoryName
1227 ** directory.
1228 */
1229 blob_init(&base, g.zRepositoryName, -1);
@@ -1236,10 +1230,11 @@
1230 sqlite3_open(":memory:", &g.db);
1231 db_multi_exec("CREATE TABLE sfile(pathname TEXT);");
1232 db_multi_exec("CREATE TABLE vfile(pathname);");
1233 vfile_scan(&base, blob_size(&base), 0, 0, 0);
1234 db_multi_exec("DELETE FROM sfile WHERE pathname NOT GLOB '*[^/].fossil'");
1235 allRepo = 0;
1236 }
1237 @ <html>
1238 @ <head>
1239 @ <base href="%s(g.zBaseURL)/" />
1240 @ <title>Repository List</title>
@@ -1253,11 +1248,15 @@
1248 db_prepare(&q, "SELECT pathname, substr(pathname,-7,-100000)||'/home'"
1249 " FROM sfile ORDER BY pathname COLLATE nocase;");
1250 while( db_step(&q)==SQLITE_ROW ){
1251 const char *zName = db_column_text(&q, 0);
1252 const char *zUrl = db_column_text(&q, 1);
1253 if( allRepo && sqlite3_strglob("[a-zA-Z]:/?*", zName)!=0 ){
1254 @ <li><a href="%R/%T(zUrl)" target="_blank">/%h(zName)</a></li>
1255 }else{
1256 @ <li><a href="%R/%T(zUrl)" target="_blank">%h(zName)</a></li>
1257 }
1258 }
1259 @ </ol>
1260 }else{
1261 @ <h1>No Repositories Found</h1>
1262 }
1263

Keyboard Shortcuts

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