Fossil

Check-in [d1214f37]
Login

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

Overview
Comment:Add more comments. Replace the changesOnly field with the knowledge that --classify and --no-classify are the only table-driven options specific to the changes command. Correctly ignore --header and -v|verbose when running the status command so their use triggers an error. Add the --differ option which combines the default list of changes (sans --merge) with --extra, i.e. all files that differ from the checked-out baseline version.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | andygoth-changes
Files: files | file ages | folders
SHA1: d1214f37977aff3798a5a130ae8b9453603f53e0
User & Date: andygoth 2016-11-06 05:09:52
Context
2016-11-06
05:15
Use clearer method of differentiating between the status and changes commands check-in: 4d33d958 user: andygoth tags: andygoth-changes
05:09
Add more comments. Replace the changesOnly field with the knowledge that --classify and --no-classify are the only table-driven options specific to the changes command. Correctly ignore --header and -v|verbose when running the status command so their use triggers an error. Add the --differ option which combines the default list of changes (sans --merge) with --extra, i.e. all files that differ from the checked-out baseline version. check-in: d1214f37 user: andygoth tags: andygoth-changes
04:23
Remove stale TODO comment. May still want to implement ls in terms of status_report() though. check-in: bfb7dd2a user: andygoth tags: andygoth-changes
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/checkin.c.

42
43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
...
336
337
338
339
340
341
342


343
344
345
346
347
348
349
...
361
362
363
364
365
366
367







368
369
370
371
372
373
374
...
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
428
429
430
431
432
433
434
435
436
437
438
439
440
...
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
  C_CONFLICT   = 1 << CB_CONFLICT,  /* Files having merge conflicts. */
  C_META       = 1 << CB_META,      /* Files with metadata changes. */
  C_UNCHANGED  = 1 << CB_UNCHANGED, /* Unchanged files. */
  C_EXTRA      = 1 << CB_EXTRA,     /* Unmanaged files. */
  C_MERGE      = 1 << CB_MERGE,     /* Merge contributors. */
  C_FILTER     = C_EDITED  | C_UPDATED | C_CHANGED  | C_MISSING | C_ADDED
               | C_DELETED | C_RENAMED | C_CONFLICT | C_META    | C_UNCHANGED
               | C_EXTRA   | C_MERGE,
  C_ALL        = C_FILTER & ~(C_EXTRA | C_MERGE),

  C_RELPATH    = 1 << CB_RELPATH,   /* Show relative paths. */
  C_CLASSIFY   = 1 << CB_CLASSIFY,  /* Show file change types. */
  C_DEFAULT    = (C_ALL & ~C_UNCHANGED) | C_MERGE | C_CLASSIFY,
  C_FATAL      = (1 << CB_FATAL) | C_MISSING, /* Fail on MISSING/NOT_A_FILE. */
  C_COMMENT    = 1 << CB_COMMENT,   /* Precede each line with "# ". */
};

................................................................................
** according to the "relative-paths" setting, unless overridden by the
** --abs-paths or --rel-paths options.
**
** By default, all changed files are selected for display.  This behavior
** can be overridden by using one or more filter options (listed below),
** in which case only files with the specified change type(s) are shown.
** As a special case, the --no-merge option does not inhibit this default.


**
** If no filter options are used, or if the --merge option is used, the
** SHA1 hash of each merge contributor check-in version is displayed at
** the end of the report.  The --no-merge option is useful to display the
** default set of changed files without the merge contributors.
**
** If change type classification is enabled, each output line starts with
................................................................................
** --edited and --updated produce disjoint sets.  --updated shows a file
** only when it is identical to that of its merge contributor, and the
** change type classification is UPDATED_BY_MERGE or UPDATED_BY_INTEGRATE.
** If the file had to be merged with any other changes, it is considered
** to be merged or conflicted and therefore will be shown by --edited, not
** --updated, with types EDITED or CONFLICT.  The --changed option can be
** used to display the union of --edited and --updated.







**
** General options:
**    --abs-paths       Display absolute pathnames.
**    --rel-paths       Display pathnames relative to the current working
**                      directory.
**    --sha1sum         Verify file status using SHA1 hashing rather than
**                      relying on file mtimes.
................................................................................
**    --deleted         Display deleted files.
**    --renamed         Display renamed files.
**    --conflict        Display files having merge conflicts.
**    --meta            Display files with metadata changes.
**    --unchanged       Display unchanged files.
**    --all             Display all managed files, i.e. all of the above.
**    --extra           Display unmanaged files.

**    --merge           Display merge contributors.
**    --no-merge        Do not display merge contributors.
**
** See also: extras, ls
*/
void status_cmd(void){
  /* Affirmative and negative flag option tables. */
  static const struct {
    const char *option;
    unsigned mask;
    int changesOnly;
  } flagDefs[] = {
    {"edited"  , C_EDITED , 0}, {"updated"    , C_UPDATED   , 0},
    {"changed" , C_CHANGED, 0}, {"missing"    , C_MISSING   , 0},
    {"added"   , C_ADDED  , 0}, {"deleted"    , C_DELETED   , 0},
    {"renamed" , C_RENAMED, 0}, {"conflict"   , C_CONFLICT  , 0},
    {"meta"    , C_META   , 0}, {"unchanged"  , C_UNCHANGED , 0},
    {"all"     , C_ALL    , 0}, {"extra"      , C_EXTRA     , 0},

    {"merge"   , C_MERGE  , 0}, {"classify"   , C_CLASSIFY  , 1},
  }, noFlagDefs[] = {
    {"no-merge", C_MERGE  , 0}, {"no-classify", C_CLASSIFY  , 1},
  };

  Blob report = BLOB_INITIALIZER;

  int useSha1sum = find_option("sha1sum", 0, 0)!=0;
  int showHdr = find_option("header",0,0)!=0;
  int verboseFlag = find_option("verbose","v",0)!=0;
  const char *zIgnoreFlag = find_option("ignore", 0, 1);
  unsigned scanFlags = 0;
  int changes = g.argv[1][0]=='c';
  unsigned flags = 0;
  int vid, i;

  /* Load affirmative flag options. */
  for( i=0; i<count(flagDefs); ++i ){
    if( (!flagDefs[i].changesOnly || changes)
     && find_option(flagDefs[i].option, 0, 0) ){
      flags |= flagDefs[i].mask;
    }
  }

  /* If no filter options are specified, enable defaults. */
  if( !(flags & C_FILTER) ){
................................................................................
   * Also force classification for the status command. */
  if( !changes || (flags & (flags-1) & C_FILTER) ){
    flags |= C_CLASSIFY;
  }

  /* Negative flag options override defaults applied above. */
  for( i=0; i<count(noFlagDefs); ++i ){
    if( (!noFlagDefs[i].changesOnly || changes)
     && find_option(noFlagDefs[i].option, 0, 0) ){
      flags &= ~noFlagDefs[i].mask;
    }
  }

  /* Confirm current working directory is within checkout. */
  db_must_be_within_tree();







|
|
>







 







>
>







 







>
>
>
>
>
>
>







 







>








|
|
<

|
|
|
|
|
|
>
|

|



>

|
|


<





|







 







|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
...
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
...
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
...
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
428
429
430
431
432
433
434
435
436
437
438

439
440
441
442
443
444
445
446
447
448
449
450
451
...
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
  C_CONFLICT   = 1 << CB_CONFLICT,  /* Files having merge conflicts. */
  C_META       = 1 << CB_META,      /* Files with metadata changes. */
  C_UNCHANGED  = 1 << CB_UNCHANGED, /* Unchanged files. */
  C_EXTRA      = 1 << CB_EXTRA,     /* Unmanaged files. */
  C_MERGE      = 1 << CB_MERGE,     /* Merge contributors. */
  C_FILTER     = C_EDITED  | C_UPDATED | C_CHANGED  | C_MISSING | C_ADDED
               | C_DELETED | C_RENAMED | C_CONFLICT | C_META    | C_UNCHANGED
               | C_EXTRA   | C_MERGE,                 /* All filter bits. */
  C_ALL        = C_FILTER & ~(C_EXTRA     | C_MERGE), /* All managed files. */
  C_DIFFER     = C_FILTER & ~(C_UNCHANGED | C_MERGE), /* All differences. */
  C_RELPATH    = 1 << CB_RELPATH,   /* Show relative paths. */
  C_CLASSIFY   = 1 << CB_CLASSIFY,  /* Show file change types. */
  C_DEFAULT    = (C_ALL & ~C_UNCHANGED) | C_MERGE | C_CLASSIFY,
  C_FATAL      = (1 << CB_FATAL) | C_MISSING, /* Fail on MISSING/NOT_A_FILE. */
  C_COMMENT    = 1 << CB_COMMENT,   /* Precede each line with "# ". */
};

................................................................................
** according to the "relative-paths" setting, unless overridden by the
** --abs-paths or --rel-paths options.
**
** By default, all changed files are selected for display.  This behavior
** can be overridden by using one or more filter options (listed below),
** in which case only files with the specified change type(s) are shown.
** As a special case, the --no-merge option does not inhibit this default.
** This default shows exactly the set of changes that would be checked
** in by the commit command.
**
** If no filter options are used, or if the --merge option is used, the
** SHA1 hash of each merge contributor check-in version is displayed at
** the end of the report.  The --no-merge option is useful to display the
** default set of changed files without the merge contributors.
**
** If change type classification is enabled, each output line starts with
................................................................................
** --edited and --updated produce disjoint sets.  --updated shows a file
** only when it is identical to that of its merge contributor, and the
** change type classification is UPDATED_BY_MERGE or UPDATED_BY_INTEGRATE.
** If the file had to be merged with any other changes, it is considered
** to be merged or conflicted and therefore will be shown by --edited, not
** --updated, with types EDITED or CONFLICT.  The --changed option can be
** used to display the union of --edited and --updated.
**
** --differ is so named because it lists all the differences between the
** checked-out version and the checkout directory.  In addition to the
** default changes (besides --merge), it lists extra files which (assuming
** ignore-glob is set correctly) may be worth adding.  Prior to doing a
** commit, it is good practice to check --differ to see not only which
** changes would be committed but also if any files need to be added.
**
** General options:
**    --abs-paths       Display absolute pathnames.
**    --rel-paths       Display pathnames relative to the current working
**                      directory.
**    --sha1sum         Verify file status using SHA1 hashing rather than
**                      relying on file mtimes.
................................................................................
**    --deleted         Display deleted files.
**    --renamed         Display renamed files.
**    --conflict        Display files having merge conflicts.
**    --meta            Display files with metadata changes.
**    --unchanged       Display unchanged files.
**    --all             Display all managed files, i.e. all of the above.
**    --extra           Display unmanaged files.
**    --differ          Display modified and extra files.
**    --merge           Display merge contributors.
**    --no-merge        Do not display merge contributors.
**
** See also: extras, ls
*/
void status_cmd(void){
  /* Affirmative and negative flag option tables. */
  static const struct {
    const char *option; /* Flag name. */
    unsigned mask;      /* Flag bits. */

  } flagDefs[] = {
    {"edited"  , C_EDITED  }, {"updated"    , C_UPDATED  },
    {"changed" , C_CHANGED }, {"missing"    , C_MISSING  },
    {"added"   , C_ADDED   }, {"deleted"    , C_DELETED  },
    {"renamed" , C_RENAMED }, {"conflict"   , C_CONFLICT },
    {"meta"    , C_META    }, {"unchanged"  , C_UNCHANGED},
    {"all"     , C_ALL     }, {"extra"      , C_EXTRA    },
    {"differ"  , C_DIFFER  }, {"merge"      , C_MERGE    },
    {"classify", C_CLASSIFY},
  }, noFlagDefs[] = {
    {"no-merge", C_MERGE   }, {"no-classify", C_CLASSIFY },
  };

  Blob report = BLOB_INITIALIZER;
  int changes = g.argv[1][0]=='c';
  int useSha1sum = find_option("sha1sum", 0, 0)!=0;
  int showHdr = changes && find_option("header", 0, 0);
  int verboseFlag = changes && find_option("verbose", "v", 0);
  const char *zIgnoreFlag = find_option("ignore", 0, 1);
  unsigned scanFlags = 0;

  unsigned flags = 0;
  int vid, i;

  /* Load affirmative flag options. */
  for( i=0; i<count(flagDefs); ++i ){
    if( (changes || !(flagDefs[i].mask & C_CLASSIFY))
     && find_option(flagDefs[i].option, 0, 0) ){
      flags |= flagDefs[i].mask;
    }
  }

  /* If no filter options are specified, enable defaults. */
  if( !(flags & C_FILTER) ){
................................................................................
   * Also force classification for the status command. */
  if( !changes || (flags & (flags-1) & C_FILTER) ){
    flags |= C_CLASSIFY;
  }

  /* Negative flag options override defaults applied above. */
  for( i=0; i<count(noFlagDefs); ++i ){
    if( (changes || !(noFlagDefs[i].mask & C_CLASSIFY))
     && find_option(noFlagDefs[i].option, 0, 0) ){
      flags &= ~noFlagDefs[i].mask;
    }
  }

  /* Confirm current working directory is within checkout. */
  db_must_be_within_tree();