Fossil

Check-in [e6b160afe3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Manually fix some merge issues and adapt the algorithm to the latest trunk code.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | tkt-b6eea9446d
Files: files | file ages | folders
SHA1: e6b160afe3d1c7831112acdad5cfe944d0314532
User & Date: mistachkin 2015-04-03 03:04:55.471
Context
2015-04-03
03:06
Remove superfluous conditional operator. check-in: 79b27a675f user: mistachkin tags: tkt-b6eea9446d
03:04
Manually fix some merge issues and adapt the algorithm to the latest trunk code. check-in: e6b160afe3 user: mistachkin tags: tkt-b6eea9446d
02:36
Merge updates from trunk. check-in: 06ffd8009f user: mistachkin tags: tkt-b6eea9446d
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/allrepo.c.
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
  int quiet = 0;
  int dryRunFlag = 0;
  int showFile = find_option("showfile",0,0)!=0;
  int stopOnError = find_option("dontstop",0,0)==0;
  int rc;
  int rowCount, i = 0;
  char **azFilename = 0;
  i64 *aiRowid = 0;
  Bag outOfDate;
  
  int nToDel = 0;
  int showLabel = 0;

  dryRunFlag = find_option("dry-run","n",0)!=0;
  if( !dryRunFlag ){
    dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
  }







<
<
|







165
166
167
168
169
170
171


172
173
174
175
176
177
178
179
  int quiet = 0;
  int dryRunFlag = 0;
  int showFile = find_option("showfile",0,0)!=0;
  int stopOnError = find_option("dontstop",0,0)==0;
  int rc;
  int rowCount, i = 0;
  char **azFilename = 0;


  char **azTag = 0;
  int nToDel = 0;
  int showLabel = 0;

  dryRunFlag = find_option("dry-run","n",0)!=0;
  if( !dryRunFlag ){
    dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
  }
345
346
347
348
349
350
351

352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
       "INSERT INTO repolist "
       "SELECT DISTINCT substr(name, 6), name COLLATE nocase"
       "  FROM global_config"
       " WHERE substr(name, 1, 5)=='repo:'"
       " ORDER BY 1"
    );
  }

  rowCount = db_all_column_text_and_int64(&q, 0, &azFilename, 1, &aiRowid);
  db_finalize(&q);
  bag_init(&outOfDate);
  db_multi_exec("CREATE TEMP TABLE todel(x TEXT)");
  db_prepare(&q, "SELECT name, tag FROM repolist ORDER BY 1");
  while( i<rowCount ){
    const char *zFilename = azFilename[i];
    int rowid = (int)aiRowid[i];
    if( file_access(zFilename, F_OK)
     || !file_is_canonical(zFilename)
     || (useCheckouts && file_isdir(zFilename)!=1)
    ){
      db_multi_exec("INSERT INTO todel VALUES(%Q)", zFilename);
      nToDel++;
      i++; continue;
    }
    if( zCmd[0]=='l' ){
      fossil_print("%s\n", zFilename);
      i++; continue;
    }else if( showFile ){







>
|

<

<


|




|







343
344
345
346
347
348
349
350
351
352

353

354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
       "INSERT INTO repolist "
       "SELECT DISTINCT substr(name, 6), name COLLATE nocase"
       "  FROM global_config"
       " WHERE substr(name, 1, 5)=='repo:'"
       " ORDER BY 1"
    );
  }
  db_prepare(&q, "SELECT name, tag FROM repolist ORDER BY 1");
  rowCount = db_all_column_text(&q, 0, &azFilename, 1, &azTag);
  db_finalize(&q);

  db_multi_exec("CREATE TEMP TABLE todel(x TEXT)");

  while( i<rowCount ){
    const char *zFilename = azFilename[i];
    const char *zTag = azTag[i];
    if( file_access(zFilename, F_OK)
     || !file_is_canonical(zFilename)
     || (useCheckouts && file_isdir(zFilename)!=1)
    ){
      db_multi_exec("INSERT INTO todel VALUES(%Q)", zTag);
      nToDel++;
      i++; continue;
    }
    if( zCmd[0]=='l' ){
      fossil_print("%s\n", zFilename);
      i++; continue;
    }else if( showFile ){
389
390
391
392
393
394
395
396

397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
    free(zSyscmd);
    free(zQFilename);
    if( stopOnError && rc ){
      break;
    }
    i++;
  }
  db_all_column_free(rowCount, &azFilename, &aiRowid);

  assert( !azFilename );
  assert( !aiRowid );

  /* If any repositories whose names appear in the ~/.fossil file could not
  ** be found, remove those names from the ~/.fossil file.
  */
  if( nToDel>0 ){
    const char *zSql = "DELETE FROM global_config WHERE name IN toDel";
    if( dryRunFlag ){
      fossil_print("%s\n", zSql);
    }else{
      db_multi_exec("%s", zSql /*safe-for-%s*/ );
    }
  }
}







|
>

|













386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
    free(zSyscmd);
    free(zQFilename);
    if( stopOnError && rc ){
      break;
    }
    i++;
  }
  db_all_column_free(rowCount, &azFilename);
  db_all_column_free(rowCount, &azTag);
  assert( !azFilename );
  assert( !azTag );

  /* If any repositories whose names appear in the ~/.fossil file could not
  ** be found, remove those names from the ~/.fossil file.
  */
  if( nToDel>0 ){
    const char *zSql = "DELETE FROM global_config WHERE name IN toDel";
    if( dryRunFlag ){
      fossil_print("%s\n", zSql);
    }else{
      db_multi_exec("%s", zSql /*safe-for-%s*/ );
    }
  }
}
Changes to src/db.c.
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404

405
406
407

408

409
410
411
412
413
414
415
416
417
418
419
420
}

/*
** Steps the SQL statement until there are no more rows.  Returns the
** total number of rows processed by this function.  If the pazValue1
** parameter is non-zero, captures the iCol1'th column value from each
** row (as text) and stores the resulting final array pointer into it.
** If the paiValue2 parameter is non-zero, captures the iCol2'th column
** value from each row (as int64) and stores the resulting final array
** pointer into it.  The caller of this function is responsible for
** calling the db_all_column_free() function later, passing it the
** result of this function along with the values for both the pazValue1
** and paiValue2 paramters.
*/
int db_all_column_text_and_int64(
  Stmt *pStmt,       /* The statement handle. */
  int iCol1,         /* The first column number to fetch from the results. */
  char ***pazValue1, /* Array of iCol1'th column values from query. */
  int iCol2,         /* The second column number to fetch from the results. */
  i64 **paiValue2    /* Array of iCol2'th column values from query. */
){
  int count = 0;
  char **azValue = 0;
  i64 *aiValue = 0;
  while( db_step(pStmt)==SQLITE_ROW ){
    count++;
    if( pazValue1 ){
      azValue = fossil_realloc(azValue, count * sizeof(char*));
      azValue[count - 1] = fossil_strdup(db_column_text(pStmt, iCol1));
    }
    if( paiValue2 ){
      aiValue = fossil_realloc(aiValue, count * sizeof(i64));
      aiValue[count - 1] = db_column_int64(pStmt, iCol2);
    }
  }
  if( pazValue1 ){
    *pazValue1 = azValue;
  }
  if( paiValue2 ){
    *paiValue2 = aiValue;
  }
  return count;
}

/*
** This function frees all the storage that was allocated by the
** db_all_column_text() function.
*/
void db_all_column_free(
  int count,         /* Number of string elements in the array. */
  char ***pazValue1, /* Array of iCol1'th column values from query. */
  i64 **paiValue2    /* Array of iCol2'th column values from query. */
){
  if( pazValue1 ){
    char **azValue = *pazValue1;
    int i;
    for(i=0; i<count; i++){

      fossil_free(azValue[i]);
      azValue[i] = 0;
    }

    fossil_free(azValue);

    *pazValue1 = 0;
  }
  if( paiValue2 ){
    fossil_free(*paiValue2);
    *paiValue2 = 0;
  }
}

/*
** Print warnings if a query is inefficient.
*/
static void db_stats(Stmt *pStmt){







|
|



|

|




|


|
|



|
|

|
|
|



|

|
|






|


|
|
<

|
|


>
|
|
|
>

>
|
|
<
<
<







348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398

399
400
401
402
403
404
405
406
407
408
409
410
411
412



413
414
415
416
417
418
419
}

/*
** Steps the SQL statement until there are no more rows.  Returns the
** total number of rows processed by this function.  If the pazValue1
** parameter is non-zero, captures the iCol1'th column value from each
** row (as text) and stores the resulting final array pointer into it.
** If the pazValue2 parameter is non-zero, captures the iCol2'th column
** value from each row (as text) and stores the resulting final array
** pointer into it.  The caller of this function is responsible for
** calling the db_all_column_free() function later, passing it the
** result of this function along with the values for both the pazValue1
** and pazValue2 paramters.
*/
int db_all_column_text(
  Stmt *pStmt,       /* The statement handle. */
  int iCol1,         /* The first column number to fetch from the results. */
  char ***pazValue1, /* Array of iCol1'th column values from query. */
  int iCol2,         /* The second column number to fetch from the results. */
  char ***pazValue2  /* Array of iCol2'th column values from query. */
){
  int count = 0;
  char **azValue1 = 0;
  char **azValue2 = 0;
  while( db_step(pStmt)==SQLITE_ROW ){
    count++;
    if( pazValue1 ){
      azValue1 = fossil_realloc(azValue1, count * sizeof(char*));
      azValue1[count - 1] = fossil_strdup(db_column_text(pStmt, iCol1));
    }
    if( pazValue2 ){
      azValue2 = fossil_realloc(azValue2, count * sizeof(char*));
      azValue2[count - 1] = fossil_strdup(db_column_text(pStmt, iCol2));
    }
  }
  if( pazValue1 ){
    *pazValue1 = azValue1;
  }
  if( pazValue2 ){
    *pazValue2 = azValue2;
  }
  return count;
}

/*
** This function frees all the storage that was allocated by the
** db_all_column_text() function for a particular column.
*/
void db_all_column_free(
  int count,        /* Number of string elements in the arrays. */
  char ***pazValue  /* Array of column values from query. */

){
  if( pazValue ){
    char **azValue = pazValue ? *pazValue : 0;
    int i;
    for(i=0; i<count; i++){
      if( azValue ){
        fossil_free(azValue[i]);
        azValue[i] = 0;
      }
    }
    fossil_free(azValue);
    if( pazValue ){
      *pazValue = 0;
    }



  }
}

/*
** Print warnings if a query is inefficient.
*/
static void db_stats(Stmt *pStmt){