Diff
Not logged in

Differences From Artifact [7887fd7c23]:

To Artifact [03cb443201]:


139
140
141
142
143
144
145
146

147
148
149
150
151
152
153
139
140
141
142
143
144
145

146
147
148
149
150
151
152
153







-
+







  char *zQFilename;
  Blob extra;
  int useCheckouts = 0;
  int quiet = 0;
  int dryRunFlag = 0;
  int stopOnError = find_option("dontstop",0,0)==0;
  int rc;
  Bag outOfDate;
  int nToDel = 0;
  
  dryRunFlag = find_option("dry-run","n",0)!=0;
  if( !dryRunFlag ){
    dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
  }

  if( g.argc<3 ){
241
242
243
244
245
246
247
248

249
250
251

252
253
254
255

256
257
258

259
260
261

262
263
264
265

266
267

268
269

270



271
272
273
274
275
276
277
241
242
243
244
245
246
247

248
249
250

251
252
253
254

255
256
257

258
259
260

261
262
263


264


265


266

267
268
269
270
271
272
273
274
275
276







-
+


-
+



-
+


-
+


-
+


-
-
+
-
-
+
-
-
+
-
+
+
+







    fossil_fatal("\"all\" subcommand should be one of: "
                 "changes clean extra ignore list ls push pull rebuild sync");
  }
  verify_all_options();
  zFossil = quoteFilename(g.nameOfExe);
  if( useCheckouts ){
    db_prepare(&q,
       "SELECT substr(name, 7) COLLATE nocase, max(rowid)"
       "SELECT DISTINCT substr(name, 7), name COLLATE nocase"
       "  FROM global_config"
       " WHERE substr(name, 1, 6)=='ckout:'"
       " GROUP BY 1 ORDER BY 1"
       " ORDER BY 1"
    );
  }else{
    db_prepare(&q,
       "SELECT substr(name, 6) COLLATE nocase, max(rowid)"
       "SELECT DISTINCT substr(name, 6), name COLLATE nocase"
       "  FROM global_config"
       " WHERE substr(name, 1, 5)=='repo:'"
       " GROUP BY 1 ORDER BY 1"
       " ORDER BY 1"
    );
  }
  bag_init(&outOfDate);
  db_multi_exec("CREATE TEMP TABLE todel(x TEXT)");
  while( db_step(&q)==SQLITE_ROW ){
    const char *zFilename = db_column_text(&q, 0);
    int rowid = db_column_int(&q, 1);
    if( file_access(zFilename, 0) || !file_is_canonical(zFilename) ){
    if( file_access(zFilename, 0)
      bag_insert(&outOfDate, rowid);
      continue;
     || !file_is_canonical(zFilename)
    }
    if( useCheckouts && file_isdir(zFilename)!=1 ){
     || (useCheckouts && file_isdir(zFilename)!=1)
      bag_insert(&outOfDate, rowid);
    ){
      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;
    }
    zQFilename = quoteFilename(zFilename);
289
290
291
292
293
294
295
296

297
298
299
300
301

302
303
304
305
306
307
308

309
310

311
312
313
314
288
289
290
291
292
293
294

295





296





297

298
299

300
301

302
303







-
+
-
-
-
-
-
+
-
-
-
-
-

-
+

-
+

-


    }
  }
  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( bag_count(&outOfDate)>0 ){
  if( nToDel>0 ){
    Blob sql;
    char *zSep = "(";
    int rowid;
    blob_zero(&sql);
    blob_appendf(&sql, "DELETE FROM global_config WHERE rowid IN ");
    const char *zSql = "DELETE FROM global_config WHERE name IN toDel";
    for(rowid=bag_first(&outOfDate); rowid>0; rowid=bag_next(&outOfDate,rowid)){
      blob_appendf(&sql, "%s%d", zSep, rowid);
      zSep = ",";
    }
    blob_appendf(&sql, ")");
    if( dryRunFlag ){
      fossil_print("%s\n", blob_str(&sql));
      fossil_print("%s\n", zSql);
    }else{
      db_multi_exec(blob_str(&sql));
      db_multi_exec(zSql);
    }
    blob_reset(&sql);
  }
}