Fossil SCM

Add the "fossil all add" command for efficiently adding new repositories to the repo list after they have been moved or renamed.

drh 2015-02-15 20:48 trunk
Commit c2f6fef80adeb3badc1aa7d011af6bc1c873f958
1 file changed +49 -13
+49 -13
--- src/allrepo.c
+++ src/allrepo.c
@@ -105,20 +105,12 @@
105105
**
106106
** extras Shows "extra" files from all local checkouts. The command
107107
** line options supported by the extra command itself, if any
108108
** are present, are passed along verbatim.
109109
**
110
-** ignore Arguments are repositories that should be ignored by
111
-** subsequent clean, extras, list, pull, push, rebuild, and
112
-** sync operations. The -c|--ckout option causes the listed
113
-** local checkouts to be ignored instead.
114
-**
115110
** info Run the "info" command on all repositories.
116111
**
117
-** list | ls Display the location of all repositories. The -c|--ckout
118
-** option causes all local checkouts to be listed instead.
119
-**
120112
** pull Run a "pull" operation on all repositories. Only the
121113
** --verbose option is supported.
122114
**
123115
** push Run a "push" on all repositories. Only the --verbose
124116
** option is supported.
@@ -134,10 +126,25 @@
134126
** setting Run the "setting", "set", or "unset" commands on all
135127
** set repositories. These command are particularly useful in
136128
** unset conjunction with the "max-loadavg" setting which cannot
137129
** otherwise be set globally.
138130
**
131
+** In addition, the following maintenance operations are supported:
132
+**
133
+** add Add all the repositories named to the set of repositories
134
+** tracked by Fossil. Normally Fossil is able to keep up with
135
+** this list by itself, but sometime it can benefit from this
136
+** hint if you rename repositories.
137
+**
138
+** ignore Arguments are repositories that should be ignored by
139
+** subsequent clean, extras, list, pull, push, rebuild, and
140
+** sync operations. The -c|--ckout option causes the listed
141
+** local checkouts to be ignored instead.
142
+**
143
+** list | ls Display the location of all repositories. The -c|--ckout
144
+** option causes all local checkouts to be listed instead.
145
+**
139146
** Repositories are automatically added to the set of known repositories
140147
** when one of the following commands are run against the repository:
141148
** clone, info, pull, push, or sync. Even previously ignored repositories
142149
** are added back to the list of repositories by these commands.
143150
**
@@ -259,26 +266,55 @@
259266
useCheckouts = 1;
260267
stopOnError = 0;
261268
quiet = 1;
262269
}else if( strncmp(zCmd, "ignore", n)==0 ){
263270
int j;
271
+ Blob fn = BLOB_INITIALIZER;
272
+ Blob sql = BLOB_INITIALIZER;
264273
useCheckouts = find_option("ckout","c",0)!=0;
265274
verify_all_options();
266275
db_begin_transaction();
267
- for(j=3; j<g.argc; j++){
268
- Blob sql;
269
- blob_zero(&sql);
276
+ for(j=3; j<g.argc; j++, blob_reset(&sql), blob_reset(&fn)){
277
+ file_canonical_name(g.argv[j], &fn, 0);
270278
blob_append_sql(&sql,
271279
"DELETE FROM global_config WHERE name GLOB '%s:%q'",
272
- useCheckouts?"ckout":"repo", g.argv[j]
280
+ useCheckouts?"ckout":"repo", blob_str(&fn)
273281
);
274282
if( dryRunFlag ){
275283
fossil_print("%s\n", blob_sql_text(&sql));
276284
}else{
277285
db_multi_exec("%s", blob_sql_text(&sql));
278286
}
279
- blob_reset(&sql);
287
+ }
288
+ db_end_transaction(0);
289
+ return;
290
+ }else if( strncmp(zCmd, "add", n)==0 ){
291
+ int j;
292
+ Blob fn = BLOB_INITIALIZER;
293
+ Blob sql = BLOB_INITIALIZER;
294
+ verify_all_options();
295
+ db_begin_transaction();
296
+ for(j=3; j<g.argc; j++, blob_reset(&fn), blob_reset(&sql)){
297
+ sqlite3 *db;
298
+ int rc;
299
+ const char *z;
300
+ file_canonical_name(g.argv[j], &fn, 0);
301
+ z = blob_str(&fn);
302
+ if( !file_isfile(z) ) continue;
303
+ rc = sqlite3_open(z, &db);
304
+ if( rc!=SQLITE_OK ){ sqlite3_close(db); continue; }
305
+ rc = sqlite3_exec(db, "SELECT rcvid FROM blob, delta LIMIT 1", 0, 0, 0);
306
+ sqlite3_close(db);
307
+ if( rc!=SQLITE_OK ) continue;
308
+ blob_append_sql(&sql,
309
+ "INSERT INTO global_config(name,value)VALUES('repo:%q',1)", z
310
+ );
311
+ if( dryRunFlag ){
312
+ fossil_print("%s\n", blob_sql_text(&sql));
313
+ }else{
314
+ db_multi_exec("%s", blob_sql_text(&sql));
315
+ }
280316
}
281317
db_end_transaction(0);
282318
return;
283319
}else if( strncmp(zCmd, "info", n)==0 ){
284320
zCmd = "info";
285321
--- src/allrepo.c
+++ src/allrepo.c
@@ -105,20 +105,12 @@
105 **
106 ** extras Shows "extra" files from all local checkouts. The command
107 ** line options supported by the extra command itself, if any
108 ** are present, are passed along verbatim.
109 **
110 ** ignore Arguments are repositories that should be ignored by
111 ** subsequent clean, extras, list, pull, push, rebuild, and
112 ** sync operations. The -c|--ckout option causes the listed
113 ** local checkouts to be ignored instead.
114 **
115 ** info Run the "info" command on all repositories.
116 **
117 ** list | ls Display the location of all repositories. The -c|--ckout
118 ** option causes all local checkouts to be listed instead.
119 **
120 ** pull Run a "pull" operation on all repositories. Only the
121 ** --verbose option is supported.
122 **
123 ** push Run a "push" on all repositories. Only the --verbose
124 ** option is supported.
@@ -134,10 +126,25 @@
134 ** setting Run the "setting", "set", or "unset" commands on all
135 ** set repositories. These command are particularly useful in
136 ** unset conjunction with the "max-loadavg" setting which cannot
137 ** otherwise be set globally.
138 **
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139 ** Repositories are automatically added to the set of known repositories
140 ** when one of the following commands are run against the repository:
141 ** clone, info, pull, push, or sync. Even previously ignored repositories
142 ** are added back to the list of repositories by these commands.
143 **
@@ -259,26 +266,55 @@
259 useCheckouts = 1;
260 stopOnError = 0;
261 quiet = 1;
262 }else if( strncmp(zCmd, "ignore", n)==0 ){
263 int j;
 
 
264 useCheckouts = find_option("ckout","c",0)!=0;
265 verify_all_options();
266 db_begin_transaction();
267 for(j=3; j<g.argc; j++){
268 Blob sql;
269 blob_zero(&sql);
270 blob_append_sql(&sql,
271 "DELETE FROM global_config WHERE name GLOB '%s:%q'",
272 useCheckouts?"ckout":"repo", g.argv[j]
273 );
274 if( dryRunFlag ){
275 fossil_print("%s\n", blob_sql_text(&sql));
276 }else{
277 db_multi_exec("%s", blob_sql_text(&sql));
278 }
279 blob_reset(&sql);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280 }
281 db_end_transaction(0);
282 return;
283 }else if( strncmp(zCmd, "info", n)==0 ){
284 zCmd = "info";
285
--- src/allrepo.c
+++ src/allrepo.c
@@ -105,20 +105,12 @@
105 **
106 ** extras Shows "extra" files from all local checkouts. The command
107 ** line options supported by the extra command itself, if any
108 ** are present, are passed along verbatim.
109 **
 
 
 
 
 
110 ** info Run the "info" command on all repositories.
111 **
 
 
 
112 ** pull Run a "pull" operation on all repositories. Only the
113 ** --verbose option is supported.
114 **
115 ** push Run a "push" on all repositories. Only the --verbose
116 ** option is supported.
@@ -134,10 +126,25 @@
126 ** setting Run the "setting", "set", or "unset" commands on all
127 ** set repositories. These command are particularly useful in
128 ** unset conjunction with the "max-loadavg" setting which cannot
129 ** otherwise be set globally.
130 **
131 ** In addition, the following maintenance operations are supported:
132 **
133 ** add Add all the repositories named to the set of repositories
134 ** tracked by Fossil. Normally Fossil is able to keep up with
135 ** this list by itself, but sometime it can benefit from this
136 ** hint if you rename repositories.
137 **
138 ** ignore Arguments are repositories that should be ignored by
139 ** subsequent clean, extras, list, pull, push, rebuild, and
140 ** sync operations. The -c|--ckout option causes the listed
141 ** local checkouts to be ignored instead.
142 **
143 ** list | ls Display the location of all repositories. The -c|--ckout
144 ** option causes all local checkouts to be listed instead.
145 **
146 ** Repositories are automatically added to the set of known repositories
147 ** when one of the following commands are run against the repository:
148 ** clone, info, pull, push, or sync. Even previously ignored repositories
149 ** are added back to the list of repositories by these commands.
150 **
@@ -259,26 +266,55 @@
266 useCheckouts = 1;
267 stopOnError = 0;
268 quiet = 1;
269 }else if( strncmp(zCmd, "ignore", n)==0 ){
270 int j;
271 Blob fn = BLOB_INITIALIZER;
272 Blob sql = BLOB_INITIALIZER;
273 useCheckouts = find_option("ckout","c",0)!=0;
274 verify_all_options();
275 db_begin_transaction();
276 for(j=3; j<g.argc; j++, blob_reset(&sql), blob_reset(&fn)){
277 file_canonical_name(g.argv[j], &fn, 0);
 
278 blob_append_sql(&sql,
279 "DELETE FROM global_config WHERE name GLOB '%s:%q'",
280 useCheckouts?"ckout":"repo", blob_str(&fn)
281 );
282 if( dryRunFlag ){
283 fossil_print("%s\n", blob_sql_text(&sql));
284 }else{
285 db_multi_exec("%s", blob_sql_text(&sql));
286 }
287 }
288 db_end_transaction(0);
289 return;
290 }else if( strncmp(zCmd, "add", n)==0 ){
291 int j;
292 Blob fn = BLOB_INITIALIZER;
293 Blob sql = BLOB_INITIALIZER;
294 verify_all_options();
295 db_begin_transaction();
296 for(j=3; j<g.argc; j++, blob_reset(&fn), blob_reset(&sql)){
297 sqlite3 *db;
298 int rc;
299 const char *z;
300 file_canonical_name(g.argv[j], &fn, 0);
301 z = blob_str(&fn);
302 if( !file_isfile(z) ) continue;
303 rc = sqlite3_open(z, &db);
304 if( rc!=SQLITE_OK ){ sqlite3_close(db); continue; }
305 rc = sqlite3_exec(db, "SELECT rcvid FROM blob, delta LIMIT 1", 0, 0, 0);
306 sqlite3_close(db);
307 if( rc!=SQLITE_OK ) continue;
308 blob_append_sql(&sql,
309 "INSERT INTO global_config(name,value)VALUES('repo:%q',1)", z
310 );
311 if( dryRunFlag ){
312 fossil_print("%s\n", blob_sql_text(&sql));
313 }else{
314 db_multi_exec("%s", blob_sql_text(&sql));
315 }
316 }
317 db_end_transaction(0);
318 return;
319 }else if( strncmp(zCmd, "info", n)==0 ){
320 zCmd = "info";
321

Keyboard Shortcuts

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