Fossil SCM

Manually fix some merge issues and adapt the algorithm to the latest trunk code.

mistachkin 2015-04-03 03:04 UTC tkt-b6eea9446d
Commit e6b160afe3d1c7831112acdad5cfe944d0314532
2 files changed +8 -10 +27 -28
+8 -10
--- src/allrepo.c
+++ src/allrepo.c
@@ -167,13 +167,11 @@
167167
int showFile = find_option("showfile",0,0)!=0;
168168
int stopOnError = find_option("dontstop",0,0)==0;
169169
int rc;
170170
int rowCount, i = 0;
171171
char **azFilename = 0;
172
- i64 *aiRowid = 0;
173
- Bag outOfDate;
174
-
172
+ char **azTag = 0;
175173
int nToDel = 0;
176174
int showLabel = 0;
177175
178176
dryRunFlag = find_option("dry-run","n",0)!=0;
179177
if( !dryRunFlag ){
@@ -347,23 +345,22 @@
347345
" FROM global_config"
348346
" WHERE substr(name, 1, 5)=='repo:'"
349347
" ORDER BY 1"
350348
);
351349
}
352
- rowCount = db_all_column_text_and_int64(&q, 0, &azFilename, 1, &aiRowid);
350
+ db_prepare(&q, "SELECT name, tag FROM repolist ORDER BY 1");
351
+ rowCount = db_all_column_text(&q, 0, &azFilename, 1, &azTag);
353352
db_finalize(&q);
354
- bag_init(&outOfDate);
355353
db_multi_exec("CREATE TEMP TABLE todel(x TEXT)");
356
- db_prepare(&q, "SELECT name, tag FROM repolist ORDER BY 1");
357354
while( i<rowCount ){
358355
const char *zFilename = azFilename[i];
359
- int rowid = (int)aiRowid[i];
356
+ const char *zTag = azTag[i];
360357
if( file_access(zFilename, F_OK)
361358
|| !file_is_canonical(zFilename)
362359
|| (useCheckouts && file_isdir(zFilename)!=1)
363360
){
364
- db_multi_exec("INSERT INTO todel VALUES(%Q)", zFilename);
361
+ db_multi_exec("INSERT INTO todel VALUES(%Q)", zTag);
365362
nToDel++;
366363
i++; continue;
367364
}
368365
if( zCmd[0]=='l' ){
369366
fossil_print("%s\n", zFilename);
@@ -391,13 +388,14 @@
391388
if( stopOnError && rc ){
392389
break;
393390
}
394391
i++;
395392
}
396
- db_all_column_free(rowCount, &azFilename, &aiRowid);
393
+ db_all_column_free(rowCount, &azFilename);
394
+ db_all_column_free(rowCount, &azTag);
397395
assert( !azFilename );
398
- assert( !aiRowid );
396
+ assert( !azTag );
399397
400398
/* If any repositories whose names appear in the ~/.fossil file could not
401399
** be found, remove those names from the ~/.fossil file.
402400
*/
403401
if( nToDel>0 ){
404402
--- src/allrepo.c
+++ src/allrepo.c
@@ -167,13 +167,11 @@
167 int showFile = find_option("showfile",0,0)!=0;
168 int stopOnError = find_option("dontstop",0,0)==0;
169 int rc;
170 int rowCount, i = 0;
171 char **azFilename = 0;
172 i64 *aiRowid = 0;
173 Bag outOfDate;
174
175 int nToDel = 0;
176 int showLabel = 0;
177
178 dryRunFlag = find_option("dry-run","n",0)!=0;
179 if( !dryRunFlag ){
@@ -347,23 +345,22 @@
347 " FROM global_config"
348 " WHERE substr(name, 1, 5)=='repo:'"
349 " ORDER BY 1"
350 );
351 }
352 rowCount = db_all_column_text_and_int64(&q, 0, &azFilename, 1, &aiRowid);
 
353 db_finalize(&q);
354 bag_init(&outOfDate);
355 db_multi_exec("CREATE TEMP TABLE todel(x TEXT)");
356 db_prepare(&q, "SELECT name, tag FROM repolist ORDER BY 1");
357 while( i<rowCount ){
358 const char *zFilename = azFilename[i];
359 int rowid = (int)aiRowid[i];
360 if( file_access(zFilename, F_OK)
361 || !file_is_canonical(zFilename)
362 || (useCheckouts && file_isdir(zFilename)!=1)
363 ){
364 db_multi_exec("INSERT INTO todel VALUES(%Q)", zFilename);
365 nToDel++;
366 i++; continue;
367 }
368 if( zCmd[0]=='l' ){
369 fossil_print("%s\n", zFilename);
@@ -391,13 +388,14 @@
391 if( stopOnError && rc ){
392 break;
393 }
394 i++;
395 }
396 db_all_column_free(rowCount, &azFilename, &aiRowid);
 
397 assert( !azFilename );
398 assert( !aiRowid );
399
400 /* If any repositories whose names appear in the ~/.fossil file could not
401 ** be found, remove those names from the ~/.fossil file.
402 */
403 if( nToDel>0 ){
404
--- src/allrepo.c
+++ src/allrepo.c
@@ -167,13 +167,11 @@
167 int showFile = find_option("showfile",0,0)!=0;
168 int stopOnError = find_option("dontstop",0,0)==0;
169 int rc;
170 int rowCount, i = 0;
171 char **azFilename = 0;
172 char **azTag = 0;
 
 
173 int nToDel = 0;
174 int showLabel = 0;
175
176 dryRunFlag = find_option("dry-run","n",0)!=0;
177 if( !dryRunFlag ){
@@ -347,23 +345,22 @@
345 " FROM global_config"
346 " WHERE substr(name, 1, 5)=='repo:'"
347 " ORDER BY 1"
348 );
349 }
350 db_prepare(&q, "SELECT name, tag FROM repolist ORDER BY 1");
351 rowCount = db_all_column_text(&q, 0, &azFilename, 1, &azTag);
352 db_finalize(&q);
 
353 db_multi_exec("CREATE TEMP TABLE todel(x TEXT)");
 
354 while( i<rowCount ){
355 const char *zFilename = azFilename[i];
356 const char *zTag = azTag[i];
357 if( file_access(zFilename, F_OK)
358 || !file_is_canonical(zFilename)
359 || (useCheckouts && file_isdir(zFilename)!=1)
360 ){
361 db_multi_exec("INSERT INTO todel VALUES(%Q)", zTag);
362 nToDel++;
363 i++; continue;
364 }
365 if( zCmd[0]=='l' ){
366 fossil_print("%s\n", zFilename);
@@ -391,13 +388,14 @@
388 if( stopOnError && rc ){
389 break;
390 }
391 i++;
392 }
393 db_all_column_free(rowCount, &azFilename);
394 db_all_column_free(rowCount, &azTag);
395 assert( !azFilename );
396 assert( !azTag );
397
398 /* If any repositories whose names appear in the ~/.fossil file could not
399 ** be found, remove those names from the ~/.fossil file.
400 */
401 if( nToDel>0 ){
402
+27 -28
--- src/db.c
+++ src/db.c
@@ -350,69 +350,68 @@
350350
/*
351351
** Steps the SQL statement until there are no more rows. Returns the
352352
** total number of rows processed by this function. If the pazValue1
353353
** parameter is non-zero, captures the iCol1'th column value from each
354354
** row (as text) and stores the resulting final array pointer into it.
355
-** If the paiValue2 parameter is non-zero, captures the iCol2'th column
356
-** value from each row (as int64) and stores the resulting final array
355
+** If the pazValue2 parameter is non-zero, captures the iCol2'th column
356
+** value from each row (as text) and stores the resulting final array
357357
** pointer into it. The caller of this function is responsible for
358358
** calling the db_all_column_free() function later, passing it the
359359
** result of this function along with the values for both the pazValue1
360
-** and paiValue2 paramters.
360
+** and pazValue2 paramters.
361361
*/
362
-int db_all_column_text_and_int64(
362
+int db_all_column_text(
363363
Stmt *pStmt, /* The statement handle. */
364364
int iCol1, /* The first column number to fetch from the results. */
365365
char ***pazValue1, /* Array of iCol1'th column values from query. */
366366
int iCol2, /* The second column number to fetch from the results. */
367
- i64 **paiValue2 /* Array of iCol2'th column values from query. */
367
+ char ***pazValue2 /* Array of iCol2'th column values from query. */
368368
){
369369
int count = 0;
370
- char **azValue = 0;
371
- i64 *aiValue = 0;
370
+ char **azValue1 = 0;
371
+ char **azValue2 = 0;
372372
while( db_step(pStmt)==SQLITE_ROW ){
373373
count++;
374374
if( pazValue1 ){
375
- azValue = fossil_realloc(azValue, count * sizeof(char*));
376
- azValue[count - 1] = fossil_strdup(db_column_text(pStmt, iCol1));
375
+ azValue1 = fossil_realloc(azValue1, count * sizeof(char*));
376
+ azValue1[count - 1] = fossil_strdup(db_column_text(pStmt, iCol1));
377377
}
378
- if( paiValue2 ){
379
- aiValue = fossil_realloc(aiValue, count * sizeof(i64));
380
- aiValue[count - 1] = db_column_int64(pStmt, iCol2);
378
+ if( pazValue2 ){
379
+ azValue2 = fossil_realloc(azValue2, count * sizeof(char*));
380
+ azValue2[count - 1] = fossil_strdup(db_column_text(pStmt, iCol2));
381381
}
382382
}
383383
if( pazValue1 ){
384
- *pazValue1 = azValue;
384
+ *pazValue1 = azValue1;
385385
}
386
- if( paiValue2 ){
387
- *paiValue2 = aiValue;
386
+ if( pazValue2 ){
387
+ *pazValue2 = azValue2;
388388
}
389389
return count;
390390
}
391391
392392
/*
393393
** This function frees all the storage that was allocated by the
394
-** db_all_column_text() function.
394
+** db_all_column_text() function for a particular column.
395395
*/
396396
void db_all_column_free(
397
- int count, /* Number of string elements in the array. */
398
- char ***pazValue1, /* Array of iCol1'th column values from query. */
399
- i64 **paiValue2 /* Array of iCol2'th column values from query. */
397
+ int count, /* Number of string elements in the arrays. */
398
+ char ***pazValue /* Array of column values from query. */
400399
){
401
- if( pazValue1 ){
402
- char **azValue = *pazValue1;
400
+ if( pazValue ){
401
+ char **azValue = pazValue ? *pazValue : 0;
403402
int i;
404403
for(i=0; i<count; i++){
405
- fossil_free(azValue[i]);
406
- azValue[i] = 0;
404
+ if( azValue ){
405
+ fossil_free(azValue[i]);
406
+ azValue[i] = 0;
407
+ }
407408
}
408409
fossil_free(azValue);
409
- *pazValue1 = 0;
410
- }
411
- if( paiValue2 ){
412
- fossil_free(*paiValue2);
413
- *paiValue2 = 0;
410
+ if( pazValue ){
411
+ *pazValue = 0;
412
+ }
414413
}
415414
}
416415
417416
/*
418417
** Print warnings if a query is inefficient.
419418
--- src/db.c
+++ src/db.c
@@ -350,69 +350,68 @@
350 /*
351 ** Steps the SQL statement until there are no more rows. Returns the
352 ** total number of rows processed by this function. If the pazValue1
353 ** parameter is non-zero, captures the iCol1'th column value from each
354 ** row (as text) and stores the resulting final array pointer into it.
355 ** If the paiValue2 parameter is non-zero, captures the iCol2'th column
356 ** value from each row (as int64) and stores the resulting final array
357 ** pointer into it. The caller of this function is responsible for
358 ** calling the db_all_column_free() function later, passing it the
359 ** result of this function along with the values for both the pazValue1
360 ** and paiValue2 paramters.
361 */
362 int db_all_column_text_and_int64(
363 Stmt *pStmt, /* The statement handle. */
364 int iCol1, /* The first column number to fetch from the results. */
365 char ***pazValue1, /* Array of iCol1'th column values from query. */
366 int iCol2, /* The second column number to fetch from the results. */
367 i64 **paiValue2 /* Array of iCol2'th column values from query. */
368 ){
369 int count = 0;
370 char **azValue = 0;
371 i64 *aiValue = 0;
372 while( db_step(pStmt)==SQLITE_ROW ){
373 count++;
374 if( pazValue1 ){
375 azValue = fossil_realloc(azValue, count * sizeof(char*));
376 azValue[count - 1] = fossil_strdup(db_column_text(pStmt, iCol1));
377 }
378 if( paiValue2 ){
379 aiValue = fossil_realloc(aiValue, count * sizeof(i64));
380 aiValue[count - 1] = db_column_int64(pStmt, iCol2);
381 }
382 }
383 if( pazValue1 ){
384 *pazValue1 = azValue;
385 }
386 if( paiValue2 ){
387 *paiValue2 = aiValue;
388 }
389 return count;
390 }
391
392 /*
393 ** This function frees all the storage that was allocated by the
394 ** db_all_column_text() function.
395 */
396 void db_all_column_free(
397 int count, /* Number of string elements in the array. */
398 char ***pazValue1, /* Array of iCol1'th column values from query. */
399 i64 **paiValue2 /* Array of iCol2'th column values from query. */
400 ){
401 if( pazValue1 ){
402 char **azValue = *pazValue1;
403 int i;
404 for(i=0; i<count; i++){
405 fossil_free(azValue[i]);
406 azValue[i] = 0;
 
 
407 }
408 fossil_free(azValue);
409 *pazValue1 = 0;
410 }
411 if( paiValue2 ){
412 fossil_free(*paiValue2);
413 *paiValue2 = 0;
414 }
415 }
416
417 /*
418 ** Print warnings if a query is inefficient.
419
--- src/db.c
+++ src/db.c
@@ -350,69 +350,68 @@
350 /*
351 ** Steps the SQL statement until there are no more rows. Returns the
352 ** total number of rows processed by this function. If the pazValue1
353 ** parameter is non-zero, captures the iCol1'th column value from each
354 ** row (as text) and stores the resulting final array pointer into it.
355 ** If the pazValue2 parameter is non-zero, captures the iCol2'th column
356 ** value from each row (as text) and stores the resulting final array
357 ** pointer into it. The caller of this function is responsible for
358 ** calling the db_all_column_free() function later, passing it the
359 ** result of this function along with the values for both the pazValue1
360 ** and pazValue2 paramters.
361 */
362 int db_all_column_text(
363 Stmt *pStmt, /* The statement handle. */
364 int iCol1, /* The first column number to fetch from the results. */
365 char ***pazValue1, /* Array of iCol1'th column values from query. */
366 int iCol2, /* The second column number to fetch from the results. */
367 char ***pazValue2 /* Array of iCol2'th column values from query. */
368 ){
369 int count = 0;
370 char **azValue1 = 0;
371 char **azValue2 = 0;
372 while( db_step(pStmt)==SQLITE_ROW ){
373 count++;
374 if( pazValue1 ){
375 azValue1 = fossil_realloc(azValue1, count * sizeof(char*));
376 azValue1[count - 1] = fossil_strdup(db_column_text(pStmt, iCol1));
377 }
378 if( pazValue2 ){
379 azValue2 = fossil_realloc(azValue2, count * sizeof(char*));
380 azValue2[count - 1] = fossil_strdup(db_column_text(pStmt, iCol2));
381 }
382 }
383 if( pazValue1 ){
384 *pazValue1 = azValue1;
385 }
386 if( pazValue2 ){
387 *pazValue2 = azValue2;
388 }
389 return count;
390 }
391
392 /*
393 ** This function frees all the storage that was allocated by the
394 ** db_all_column_text() function for a particular column.
395 */
396 void db_all_column_free(
397 int count, /* Number of string elements in the arrays. */
398 char ***pazValue /* Array of column values from query. */
 
399 ){
400 if( pazValue ){
401 char **azValue = pazValue ? *pazValue : 0;
402 int i;
403 for(i=0; i<count; i++){
404 if( azValue ){
405 fossil_free(azValue[i]);
406 azValue[i] = 0;
407 }
408 }
409 fossil_free(azValue);
410 if( pazValue ){
411 *pazValue = 0;
412 }
 
 
413 }
414 }
415
416 /*
417 ** Print warnings if a query is inefficient.
418

Keyboard Shortcuts

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