Fossil

Diff
Login

Differences From Artifact [9c20c37adf]:

To Artifact [f1bbb299d4]:


210
211
212
213
214
215
216
217

218
219
220


221
222
223
224



225

226
227







228
229
230
231
232
233
234
210
211
212
213
214
215
216

217
218


219
220
221



222
223
224
225
226


227
228
229
230
231
232
233
234
235
236
237
238
239
240







-
+

-
-
+
+

-
-
-
+
+
+

+
-
-
+
+
+
+
+
+
+







  db_finalize(&q);
  db_multi_exec("DELETE FROM sfile");
}

/*
** COMMAND: add
**
** Usage: %fossil add FILE...
** Usage: %fossil add ?OPTIONS? FILE1 ?FILE2 ...?
**
** Make arrangements to add one or more files to the current checkout
** at the next commit.
** Make arrangements to add one or more files or directories to the
** current checkout at the next commit.
**
** When adding files recursively, filenames that begin with "." are
** excluded by default.  To include such files, add the "--dotfiles"
** option to the command-line.
** When adding files or directories recursively, filenames that begin
** with "." are excluded by default.  To include such files, add
** the "--dotfiles" option to the command-line.
**
** The --ignore option specifies the patterns for files to be excluded,
** The --ignore option overrides the "ignore-glob" setting.  See
** documentation on the "setting" command for further information.
** like *.o,*.obj,*.exe. If not specified, the "ignore-glob" setting is
** used.  See ** documentation on the "settings" command for further
** information.
**
**
** SUMMARY: fossil add ?OPTIONS? FILE1 ?FILE2 ...?
** Options: --dotfiles, --ignore
*/
void add_cmd(void){
  int i;
  int vid;
  const char *zIgnoreFlag;
  Blob repo;
  Stmt ignoreTest;     /* Test to see if a name should be ignored */
338
339
340
341
342
343
344
345
346


347
348

349
350

351
352



353
354
355
356
357
358
359
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







-
-
+
+

-
+

-
+


+
+
+







  blob_reset(&path);
}

/*
** COMMAND: rm
** COMMAND: delete
**
** Usage: %fossil rm FILE...
**    or: %fossil delete FILE...
** Usage: %fossil rm FILE1 ?FILE2 ...?
**    or: %fossil delete FILE1 ?FILE2 ...?
**
** Remove one or more files from the tree.
** Remove one or more files or directories from the repository.
**
** This command does not remove the files from disk.  It just marks the
** This command does NOT remove the files from disk.  It just marks the
** files as no longer being part of the project.  In other words, future
** changes to the named files will not be versioned.
**
** SUMMARY: fossil rm FILE1 ?FILE2 ...?
**      or: fossil delete FILE1 ?FILE2 ...?
*/
void delete_cmd(void){
  int i;
  int vid;

  db_must_be_within_tree();
  vid = db_lget_int("checkout", 0);
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
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
421
422
423
424
425
426
427







-
+
















-
+




+
+
+








/*
** COMMAND: addremove
**
** Usage: %fossil addremove ?--dotfiles? ?--ignore GLOBPATTERN? ?--test?
**
** Do all necessary "add" and "rm" commands to synchronize the repository
** with the content of the working checkout
** with the content of the working checkout:
**
**  *  All files in the checkout but not in the repository (that is,
**     all files displayed using the "extra" command) are added as
**     if by the "add" command.
**
**  *  All files in the repository but missing from the checkout (that is,
**     all files that show as MISSING with the "status" command) are
**     removed as if by the "rm" command.
**
** The command does not "commit".  You must run the "commit" separately
** as a separate step.
**
** Files and directories whose names begin with "." are ignored unless
** the --dotfiles option is used.
**
** The --ignore option overrides the "ignore-glob" setting.  See
** documentation on the "setting" command for further information.
** documentation on the "settings" command for further information.
**
** The --test option shows what would happen without actually doing anything.
**
** This command can be used to track third party software.
**
**
** SUMMARY: fossil addremove ?--dotfiles? ?--ignore GLOBPATTERN? ?--test?
*/
void import_cmd(void){
  Blob path;
  const char *zIgnoreFlag = find_option("ignore",0,1);
  int allFlag = find_option("dotfiles",0,0)!=0;
  int isTest = find_option("test",0,0)!=0;
  int n;
434
435
436
437
438
439
440
441

442
443
444
445
446
447
448
449
450
451
452
453
454
455
456

457
458
459
460
461
462
463
446
447
448
449
450
451
452

453
454
455
456
457
458
459
460
461
462
463
464
465
466
467

468
469
470
471
472
473
474
475







-
+














-
+







  /* now we read the complete file structure into a temp table */
  vfile_scan(0, &path, blob_size(&path), allFlag);
  if( file_tree_name(g.zRepositoryName, &repo, 0) ){
    db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
  }

  /* step 1: search for extra files */
  db_prepare(&q, 
  db_prepare(&q,
      "SELECT x, %Q || x FROM sfile"
      " WHERE x NOT IN (%s)"
      "   AND NOT %s"
      " ORDER BY 1",
      g.zLocalRoot,
      fossil_all_reserved_names(),
      glob_expr("x", zIgnoreFlag)
  );
  while( db_step(&q)==SQLITE_ROW ){
    add_one_file(db_column_text(&q, 1), vid, 0);
    nAdd++;
  }
  db_finalize(&q);
  /* step 2: search for missing files */
  db_prepare(&q, 
  db_prepare(&q,
      "SELECT pathname,%Q || pathname,deleted FROM vfile"
      " WHERE deleted!=1"
      " ORDER BY 1",
      g.zLocalRoot
  );
  while( db_step(&q)==SQLITE_ROW ){
    const char * zFile;
497
498
499
500
501
502
503
504


505
506

507
508




509
510
511
512
513
514
515
509
510
511
512
513
514
515

516
517
518

519
520
521
522
523
524
525
526
527
528
529
530
531
532







-
+
+

-
+


+
+
+
+







/*
** COMMAND: mv
** COMMAND: rename
**
** Usage: %fossil mv|rename OLDNAME NEWNAME
**    or: %fossil mv|rename OLDNAME... DIR
**
** Move or rename one or more files within the tree
** Move or rename one or more files or directories within the repository tree.
** You can either rename a file or directory or move it to another subdirectory.
**
** This command does not rename the files on disk.  This command merely
** This command does NOT rename or move the files on disk.  This command merely
** records the fact that filenames have changed so that appropriate notations
** can be made at the next commit/checkin.
**
**
** SUMMARY: fossil mv|rename OLDNAME NEWNAME
**      or: fossil mv|rename OLDNAME... DIR
*/
void mv_cmd(void){
  int i;
  int vid;
  char *zDest;
  Blob dest;
  Stmt q;