Fossil SCM
Manually fix some merge issues and adapt the algorithm to the latest trunk code.
Commit
e6b160afe3d1c7831112acdad5cfe944d0314532
Parent
06ffd8009ff257d…
2 files changed
+8
-10
+27
-28
+8
-10
| --- src/allrepo.c | ||
| +++ src/allrepo.c | ||
| @@ -167,13 +167,11 @@ | ||
| 167 | 167 | int showFile = find_option("showfile",0,0)!=0; |
| 168 | 168 | int stopOnError = find_option("dontstop",0,0)==0; |
| 169 | 169 | int rc; |
| 170 | 170 | int rowCount, i = 0; |
| 171 | 171 | char **azFilename = 0; |
| 172 | - i64 *aiRowid = 0; | |
| 173 | - Bag outOfDate; | |
| 174 | - | |
| 172 | + char **azTag = 0; | |
| 175 | 173 | int nToDel = 0; |
| 176 | 174 | int showLabel = 0; |
| 177 | 175 | |
| 178 | 176 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 179 | 177 | if( !dryRunFlag ){ |
| @@ -347,23 +345,22 @@ | ||
| 347 | 345 | " FROM global_config" |
| 348 | 346 | " WHERE substr(name, 1, 5)=='repo:'" |
| 349 | 347 | " ORDER BY 1" |
| 350 | 348 | ); |
| 351 | 349 | } |
| 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); | |
| 353 | 352 | db_finalize(&q); |
| 354 | - bag_init(&outOfDate); | |
| 355 | 353 | db_multi_exec("CREATE TEMP TABLE todel(x TEXT)"); |
| 356 | - db_prepare(&q, "SELECT name, tag FROM repolist ORDER BY 1"); | |
| 357 | 354 | while( i<rowCount ){ |
| 358 | 355 | const char *zFilename = azFilename[i]; |
| 359 | - int rowid = (int)aiRowid[i]; | |
| 356 | + const char *zTag = azTag[i]; | |
| 360 | 357 | if( file_access(zFilename, F_OK) |
| 361 | 358 | || !file_is_canonical(zFilename) |
| 362 | 359 | || (useCheckouts && file_isdir(zFilename)!=1) |
| 363 | 360 | ){ |
| 364 | - db_multi_exec("INSERT INTO todel VALUES(%Q)", zFilename); | |
| 361 | + db_multi_exec("INSERT INTO todel VALUES(%Q)", zTag); | |
| 365 | 362 | nToDel++; |
| 366 | 363 | i++; continue; |
| 367 | 364 | } |
| 368 | 365 | if( zCmd[0]=='l' ){ |
| 369 | 366 | fossil_print("%s\n", zFilename); |
| @@ -391,13 +388,14 @@ | ||
| 391 | 388 | if( stopOnError && rc ){ |
| 392 | 389 | break; |
| 393 | 390 | } |
| 394 | 391 | i++; |
| 395 | 392 | } |
| 396 | - db_all_column_free(rowCount, &azFilename, &aiRowid); | |
| 393 | + db_all_column_free(rowCount, &azFilename); | |
| 394 | + db_all_column_free(rowCount, &azTag); | |
| 397 | 395 | assert( !azFilename ); |
| 398 | - assert( !aiRowid ); | |
| 396 | + assert( !azTag ); | |
| 399 | 397 | |
| 400 | 398 | /* If any repositories whose names appear in the ~/.fossil file could not |
| 401 | 399 | ** be found, remove those names from the ~/.fossil file. |
| 402 | 400 | */ |
| 403 | 401 | if( nToDel>0 ){ |
| 404 | 402 |
| --- 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 |
M
src/db.c
+27
-28
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -350,69 +350,68 @@ | ||
| 350 | 350 | /* |
| 351 | 351 | ** Steps the SQL statement until there are no more rows. Returns the |
| 352 | 352 | ** total number of rows processed by this function. If the pazValue1 |
| 353 | 353 | ** parameter is non-zero, captures the iCol1'th column value from each |
| 354 | 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 | |
| 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 | 357 | ** pointer into it. The caller of this function is responsible for |
| 358 | 358 | ** calling the db_all_column_free() function later, passing it the |
| 359 | 359 | ** result of this function along with the values for both the pazValue1 |
| 360 | -** and paiValue2 paramters. | |
| 360 | +** and pazValue2 paramters. | |
| 361 | 361 | */ |
| 362 | -int db_all_column_text_and_int64( | |
| 362 | +int db_all_column_text( | |
| 363 | 363 | Stmt *pStmt, /* The statement handle. */ |
| 364 | 364 | int iCol1, /* The first column number to fetch from the results. */ |
| 365 | 365 | char ***pazValue1, /* Array of iCol1'th column values from query. */ |
| 366 | 366 | 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. */ | |
| 368 | 368 | ){ |
| 369 | 369 | int count = 0; |
| 370 | - char **azValue = 0; | |
| 371 | - i64 *aiValue = 0; | |
| 370 | + char **azValue1 = 0; | |
| 371 | + char **azValue2 = 0; | |
| 372 | 372 | while( db_step(pStmt)==SQLITE_ROW ){ |
| 373 | 373 | count++; |
| 374 | 374 | 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)); | |
| 377 | 377 | } |
| 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)); | |
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | if( pazValue1 ){ |
| 384 | - *pazValue1 = azValue; | |
| 384 | + *pazValue1 = azValue1; | |
| 385 | 385 | } |
| 386 | - if( paiValue2 ){ | |
| 387 | - *paiValue2 = aiValue; | |
| 386 | + if( pazValue2 ){ | |
| 387 | + *pazValue2 = azValue2; | |
| 388 | 388 | } |
| 389 | 389 | return count; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | /* |
| 393 | 393 | ** 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. | |
| 395 | 395 | */ |
| 396 | 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. */ | |
| 397 | + int count, /* Number of string elements in the arrays. */ | |
| 398 | + char ***pazValue /* Array of column values from query. */ | |
| 400 | 399 | ){ |
| 401 | - if( pazValue1 ){ | |
| 402 | - char **azValue = *pazValue1; | |
| 400 | + if( pazValue ){ | |
| 401 | + char **azValue = pazValue ? *pazValue : 0; | |
| 403 | 402 | int i; |
| 404 | 403 | 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 | + } | |
| 407 | 408 | } |
| 408 | 409 | fossil_free(azValue); |
| 409 | - *pazValue1 = 0; | |
| 410 | - } | |
| 411 | - if( paiValue2 ){ | |
| 412 | - fossil_free(*paiValue2); | |
| 413 | - *paiValue2 = 0; | |
| 410 | + if( pazValue ){ | |
| 411 | + *pazValue = 0; | |
| 412 | + } | |
| 414 | 413 | } |
| 415 | 414 | } |
| 416 | 415 | |
| 417 | 416 | /* |
| 418 | 417 | ** Print warnings if a query is inefficient. |
| 419 | 418 |
| --- 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 |