Fossil

Changes On Branch tkt-b6eea9446d
Login

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

Changes In Branch tkt-b6eea9446d Excluding Merge-Ins

This is equivalent to a diff from ac56af176b to 999de0b746

2015-04-03
04:08
Cleanup blobs used by the 'all' sub-command. check-in: 52d746ed1e user: mistachkin tags: trunk
03:56
Evidently, the changes on this branch are no longer required. The underlying database locking issue has already been resolved. Closed-Leaf check-in: 999de0b746 user: mistachkin tags: tkt-b6eea9446d
03:55
Update error messages and help text for the 'all' sub-command. check-in: ac56af176b user: mistachkin tags: trunk
03:07
Further simplifications. check-in: 52641f3032 user: mistachkin tags: tkt-b6eea9446d
02:05
Take extra precaution to not disturb single file server invocations even though they should already be open and not hit this code. check-in: d2f1df363e user: andybradford tags: trunk

Changes to src/allrepo.c.

165
166
167
168
169
170
171



172
173
174
175
176
177
178
  Blob extra;
  int useCheckouts = 0;
  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 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
180
181
  Blob extra;
  int useCheckouts = 0;
  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 */
  }
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
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"
    );
  }
  db_multi_exec("CREATE TEMP TABLE todel(x TEXT)");
  db_prepare(&q, "SELECT name, tag FROM repolist ORDER BY 1");



  while( db_step(&q)==SQLITE_ROW ){
    const char *zFilename = db_column_text(&q, 0);

    if( file_access(zFilename, F_OK)
     || !file_is_canonical(zFilename)
     || (useCheckouts && file_isdir(zFilename)!=1)
    ){
      db_multi_exec("INSERT INTO todel VALUES(%Q)", db_column_text(&q, 1));
      nToDel++;
      continue;
    }
    if( zCmd[0]=='l' ){
      fossil_print("%s\n", zFilename);
      continue;
    }else if( showFile ){
      fossil_print("%s: %s\n", useCheckouts ? "checkout" : "repository",
                   zFilename);
    }
    zQFilename = quoteFilename(zFilename);
    zSyscmd = mprintf("%s %s %s%s",
                      zFossil, zCmd, zQFilename, blob_str(&extra));







<

>
>
>
|
|
>




|

|



|







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
372
373
374
375
376
377
       "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 ){
      fossil_print("%s: %s\n", useCheckouts ? "checkout" : "repository",
                   zFilename);
    }
    zQFilename = quoteFilename(zFilename);
    zSyscmd = mprintf("%s %s %s%s",
                      zFossil, zCmd, zQFilename, blob_str(&extra));
381
382
383
384
385
386
387

388

389


390
391
392
393
394
395
396
397
398
399
400
401
402
    }
    rc = dryRunFlag ? 0 : fossil_system(zSyscmd);
    free(zSyscmd);
    free(zQFilename);
    if( stopOnError && rc ){
      break;
    }

  }

  db_finalize(&q);



  /* 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*/ );
    }
  }
}







>

>
|
>
>













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
    }
    rc = dryRunFlag ? 0 : fossil_system(zSyscmd);
    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.

342
343
344
345
346
347
348






























































349
350
351
352
353
354
355
*/
int db_step(Stmt *pStmt){
  int rc;
  rc = sqlite3_step(pStmt->pStmt);
  pStmt->nStep++;
  return rc;
}































































/*
** Print warnings if a query is inefficient.
*/
static void db_stats(Stmt *pStmt){
#ifdef FOSSIL_DEBUG
  int c1, c2, c3;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







342
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
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
*/
int db_step(Stmt *pStmt){
  int rc;
  rc = sqlite3_step(pStmt->pStmt);
  pStmt->nStep++;
  return rc;
}

/*
** 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;
    int i;
    for(i=0; i<count; i++){
      fossil_free(azValue[i]);
      azValue[i] = 0;
    }
    fossil_free(azValue);
    *pazValue = 0;
  }
}

/*
** Print warnings if a query is inefficient.
*/
static void db_stats(Stmt *pStmt){
#ifdef FOSSIL_DEBUG
  int c1, c2, c3;