Fossil SCM

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.

andygoth 2016-11-06 05:09 UTC andygoth-changes
Commit d1214f37977aff3798a5a130ae8b9453603f53e0
1 file changed +29 -18
+29 -18
--- src/checkin.c
+++ src/checkin.c
@@ -44,12 +44,13 @@
4444
C_UNCHANGED = 1 << CB_UNCHANGED, /* Unchanged files. */
4545
C_EXTRA = 1 << CB_EXTRA, /* Unmanaged files. */
4646
C_MERGE = 1 << CB_MERGE, /* Merge contributors. */
4747
C_FILTER = C_EDITED | C_UPDATED | C_CHANGED | C_MISSING | C_ADDED
4848
| C_DELETED | C_RENAMED | C_CONFLICT | C_META | C_UNCHANGED
49
- | C_EXTRA | C_MERGE,
50
- C_ALL = C_FILTER & ~(C_EXTRA | C_MERGE),
49
+ | C_EXTRA | C_MERGE, /* All filter bits. */
50
+ C_ALL = C_FILTER & ~(C_EXTRA | C_MERGE), /* All managed files. */
51
+ C_DIFFER = C_FILTER & ~(C_UNCHANGED | C_MERGE), /* All differences. */
5152
C_RELPATH = 1 << CB_RELPATH, /* Show relative paths. */
5253
C_CLASSIFY = 1 << CB_CLASSIFY, /* Show file change types. */
5354
C_DEFAULT = (C_ALL & ~C_UNCHANGED) | C_MERGE | C_CLASSIFY,
5455
C_FATAL = (1 << CB_FATAL) | C_MISSING, /* Fail on MISSING/NOT_A_FILE. */
5556
C_COMMENT = 1 << CB_COMMENT, /* Precede each line with "# ". */
@@ -338,10 +339,12 @@
338339
**
339340
** By default, all changed files are selected for display. This behavior
340341
** can be overridden by using one or more filter options (listed below),
341342
** in which case only files with the specified change type(s) are shown.
342343
** As a special case, the --no-merge option does not inhibit this default.
344
+** This default shows exactly the set of changes that would be checked
345
+** in by the commit command.
343346
**
344347
** If no filter options are used, or if the --merge option is used, the
345348
** SHA1 hash of each merge contributor check-in version is displayed at
346349
** the end of the report. The --no-merge option is useful to display the
347350
** default set of changed files without the merge contributors.
@@ -363,10 +366,17 @@
363366
** change type classification is UPDATED_BY_MERGE or UPDATED_BY_INTEGRATE.
364367
** If the file had to be merged with any other changes, it is considered
365368
** to be merged or conflicted and therefore will be shown by --edited, not
366369
** --updated, with types EDITED or CONFLICT. The --changed option can be
367370
** used to display the union of --edited and --updated.
371
+**
372
+** --differ is so named because it lists all the differences between the
373
+** checked-out version and the checkout directory. In addition to the
374
+** default changes (besides --merge), it lists extra files which (assuming
375
+** ignore-glob is set correctly) may be worth adding. Prior to doing a
376
+** commit, it is good practice to check --differ to see not only which
377
+** changes would be committed but also if any files need to be added.
368378
**
369379
** General options:
370380
** --abs-paths Display absolute pathnames.
371381
** --rel-paths Display pathnames relative to the current working
372382
** directory.
@@ -393,46 +403,47 @@
393403
** --conflict Display files having merge conflicts.
394404
** --meta Display files with metadata changes.
395405
** --unchanged Display unchanged files.
396406
** --all Display all managed files, i.e. all of the above.
397407
** --extra Display unmanaged files.
408
+** --differ Display modified and extra files.
398409
** --merge Display merge contributors.
399410
** --no-merge Do not display merge contributors.
400411
**
401412
** See also: extras, ls
402413
*/
403414
void status_cmd(void){
404415
/* Affirmative and negative flag option tables. */
405416
static const struct {
406
- const char *option;
407
- unsigned mask;
408
- int changesOnly;
417
+ const char *option; /* Flag name. */
418
+ unsigned mask; /* Flag bits. */
409419
} flagDefs[] = {
410
- {"edited" , C_EDITED , 0}, {"updated" , C_UPDATED , 0},
411
- {"changed" , C_CHANGED, 0}, {"missing" , C_MISSING , 0},
412
- {"added" , C_ADDED , 0}, {"deleted" , C_DELETED , 0},
413
- {"renamed" , C_RENAMED, 0}, {"conflict" , C_CONFLICT , 0},
414
- {"meta" , C_META , 0}, {"unchanged" , C_UNCHANGED , 0},
415
- {"all" , C_ALL , 0}, {"extra" , C_EXTRA , 0},
416
- {"merge" , C_MERGE , 0}, {"classify" , C_CLASSIFY , 1},
420
+ {"edited" , C_EDITED }, {"updated" , C_UPDATED },
421
+ {"changed" , C_CHANGED }, {"missing" , C_MISSING },
422
+ {"added" , C_ADDED }, {"deleted" , C_DELETED },
423
+ {"renamed" , C_RENAMED }, {"conflict" , C_CONFLICT },
424
+ {"meta" , C_META }, {"unchanged" , C_UNCHANGED},
425
+ {"all" , C_ALL }, {"extra" , C_EXTRA },
426
+ {"differ" , C_DIFFER }, {"merge" , C_MERGE },
427
+ {"classify", C_CLASSIFY},
417428
}, noFlagDefs[] = {
418
- {"no-merge", C_MERGE , 0}, {"no-classify", C_CLASSIFY , 1},
429
+ {"no-merge", C_MERGE }, {"no-classify", C_CLASSIFY },
419430
};
420431
421432
Blob report = BLOB_INITIALIZER;
433
+ int changes = g.argv[1][0]=='c';
422434
int useSha1sum = find_option("sha1sum", 0, 0)!=0;
423
- int showHdr = find_option("header",0,0)!=0;
424
- int verboseFlag = find_option("verbose","v",0)!=0;
435
+ int showHdr = changes && find_option("header", 0, 0);
436
+ int verboseFlag = changes && find_option("verbose", "v", 0);
425437
const char *zIgnoreFlag = find_option("ignore", 0, 1);
426438
unsigned scanFlags = 0;
427
- int changes = g.argv[1][0]=='c';
428439
unsigned flags = 0;
429440
int vid, i;
430441
431442
/* Load affirmative flag options. */
432443
for( i=0; i<count(flagDefs); ++i ){
433
- if( (!flagDefs[i].changesOnly || changes)
444
+ if( (changes || !(flagDefs[i].mask & C_CLASSIFY))
434445
&& find_option(flagDefs[i].option, 0, 0) ){
435446
flags |= flagDefs[i].mask;
436447
}
437448
}
438449
@@ -451,11 +462,11 @@
451462
flags |= C_CLASSIFY;
452463
}
453464
454465
/* Negative flag options override defaults applied above. */
455466
for( i=0; i<count(noFlagDefs); ++i ){
456
- if( (!noFlagDefs[i].changesOnly || changes)
467
+ if( (changes || !(noFlagDefs[i].mask & C_CLASSIFY))
457468
&& find_option(noFlagDefs[i].option, 0, 0) ){
458469
flags &= ~noFlagDefs[i].mask;
459470
}
460471
}
461472
462473
--- src/checkin.c
+++ src/checkin.c
@@ -44,12 +44,13 @@
44 C_UNCHANGED = 1 << CB_UNCHANGED, /* Unchanged files. */
45 C_EXTRA = 1 << CB_EXTRA, /* Unmanaged files. */
46 C_MERGE = 1 << CB_MERGE, /* Merge contributors. */
47 C_FILTER = C_EDITED | C_UPDATED | C_CHANGED | C_MISSING | C_ADDED
48 | C_DELETED | C_RENAMED | C_CONFLICT | C_META | C_UNCHANGED
49 | C_EXTRA | C_MERGE,
50 C_ALL = C_FILTER & ~(C_EXTRA | C_MERGE),
 
51 C_RELPATH = 1 << CB_RELPATH, /* Show relative paths. */
52 C_CLASSIFY = 1 << CB_CLASSIFY, /* Show file change types. */
53 C_DEFAULT = (C_ALL & ~C_UNCHANGED) | C_MERGE | C_CLASSIFY,
54 C_FATAL = (1 << CB_FATAL) | C_MISSING, /* Fail on MISSING/NOT_A_FILE. */
55 C_COMMENT = 1 << CB_COMMENT, /* Precede each line with "# ". */
@@ -338,10 +339,12 @@
338 **
339 ** By default, all changed files are selected for display. This behavior
340 ** can be overridden by using one or more filter options (listed below),
341 ** in which case only files with the specified change type(s) are shown.
342 ** As a special case, the --no-merge option does not inhibit this default.
 
 
343 **
344 ** If no filter options are used, or if the --merge option is used, the
345 ** SHA1 hash of each merge contributor check-in version is displayed at
346 ** the end of the report. The --no-merge option is useful to display the
347 ** default set of changed files without the merge contributors.
@@ -363,10 +366,17 @@
363 ** change type classification is UPDATED_BY_MERGE or UPDATED_BY_INTEGRATE.
364 ** If the file had to be merged with any other changes, it is considered
365 ** to be merged or conflicted and therefore will be shown by --edited, not
366 ** --updated, with types EDITED or CONFLICT. The --changed option can be
367 ** used to display the union of --edited and --updated.
 
 
 
 
 
 
 
368 **
369 ** General options:
370 ** --abs-paths Display absolute pathnames.
371 ** --rel-paths Display pathnames relative to the current working
372 ** directory.
@@ -393,46 +403,47 @@
393 ** --conflict Display files having merge conflicts.
394 ** --meta Display files with metadata changes.
395 ** --unchanged Display unchanged files.
396 ** --all Display all managed files, i.e. all of the above.
397 ** --extra Display unmanaged files.
 
398 ** --merge Display merge contributors.
399 ** --no-merge Do not display merge contributors.
400 **
401 ** See also: extras, ls
402 */
403 void status_cmd(void){
404 /* Affirmative and negative flag option tables. */
405 static const struct {
406 const char *option;
407 unsigned mask;
408 int changesOnly;
409 } flagDefs[] = {
410 {"edited" , C_EDITED , 0}, {"updated" , C_UPDATED , 0},
411 {"changed" , C_CHANGED, 0}, {"missing" , C_MISSING , 0},
412 {"added" , C_ADDED , 0}, {"deleted" , C_DELETED , 0},
413 {"renamed" , C_RENAMED, 0}, {"conflict" , C_CONFLICT , 0},
414 {"meta" , C_META , 0}, {"unchanged" , C_UNCHANGED , 0},
415 {"all" , C_ALL , 0}, {"extra" , C_EXTRA , 0},
416 {"merge" , C_MERGE , 0}, {"classify" , C_CLASSIFY , 1},
 
417 }, noFlagDefs[] = {
418 {"no-merge", C_MERGE , 0}, {"no-classify", C_CLASSIFY , 1},
419 };
420
421 Blob report = BLOB_INITIALIZER;
 
422 int useSha1sum = find_option("sha1sum", 0, 0)!=0;
423 int showHdr = find_option("header",0,0)!=0;
424 int verboseFlag = find_option("verbose","v",0)!=0;
425 const char *zIgnoreFlag = find_option("ignore", 0, 1);
426 unsigned scanFlags = 0;
427 int changes = g.argv[1][0]=='c';
428 unsigned flags = 0;
429 int vid, i;
430
431 /* Load affirmative flag options. */
432 for( i=0; i<count(flagDefs); ++i ){
433 if( (!flagDefs[i].changesOnly || changes)
434 && find_option(flagDefs[i].option, 0, 0) ){
435 flags |= flagDefs[i].mask;
436 }
437 }
438
@@ -451,11 +462,11 @@
451 flags |= C_CLASSIFY;
452 }
453
454 /* Negative flag options override defaults applied above. */
455 for( i=0; i<count(noFlagDefs); ++i ){
456 if( (!noFlagDefs[i].changesOnly || changes)
457 && find_option(noFlagDefs[i].option, 0, 0) ){
458 flags &= ~noFlagDefs[i].mask;
459 }
460 }
461
462
--- src/checkin.c
+++ src/checkin.c
@@ -44,12 +44,13 @@
44 C_UNCHANGED = 1 << CB_UNCHANGED, /* Unchanged files. */
45 C_EXTRA = 1 << CB_EXTRA, /* Unmanaged files. */
46 C_MERGE = 1 << CB_MERGE, /* Merge contributors. */
47 C_FILTER = C_EDITED | C_UPDATED | C_CHANGED | C_MISSING | C_ADDED
48 | C_DELETED | C_RENAMED | C_CONFLICT | C_META | C_UNCHANGED
49 | C_EXTRA | C_MERGE, /* All filter bits. */
50 C_ALL = C_FILTER & ~(C_EXTRA | C_MERGE), /* All managed files. */
51 C_DIFFER = C_FILTER & ~(C_UNCHANGED | C_MERGE), /* All differences. */
52 C_RELPATH = 1 << CB_RELPATH, /* Show relative paths. */
53 C_CLASSIFY = 1 << CB_CLASSIFY, /* Show file change types. */
54 C_DEFAULT = (C_ALL & ~C_UNCHANGED) | C_MERGE | C_CLASSIFY,
55 C_FATAL = (1 << CB_FATAL) | C_MISSING, /* Fail on MISSING/NOT_A_FILE. */
56 C_COMMENT = 1 << CB_COMMENT, /* Precede each line with "# ". */
@@ -338,10 +339,12 @@
339 **
340 ** By default, all changed files are selected for display. This behavior
341 ** can be overridden by using one or more filter options (listed below),
342 ** in which case only files with the specified change type(s) are shown.
343 ** As a special case, the --no-merge option does not inhibit this default.
344 ** This default shows exactly the set of changes that would be checked
345 ** in by the commit command.
346 **
347 ** If no filter options are used, or if the --merge option is used, the
348 ** SHA1 hash of each merge contributor check-in version is displayed at
349 ** the end of the report. The --no-merge option is useful to display the
350 ** default set of changed files without the merge contributors.
@@ -363,10 +366,17 @@
366 ** change type classification is UPDATED_BY_MERGE or UPDATED_BY_INTEGRATE.
367 ** If the file had to be merged with any other changes, it is considered
368 ** to be merged or conflicted and therefore will be shown by --edited, not
369 ** --updated, with types EDITED or CONFLICT. The --changed option can be
370 ** used to display the union of --edited and --updated.
371 **
372 ** --differ is so named because it lists all the differences between the
373 ** checked-out version and the checkout directory. In addition to the
374 ** default changes (besides --merge), it lists extra files which (assuming
375 ** ignore-glob is set correctly) may be worth adding. Prior to doing a
376 ** commit, it is good practice to check --differ to see not only which
377 ** changes would be committed but also if any files need to be added.
378 **
379 ** General options:
380 ** --abs-paths Display absolute pathnames.
381 ** --rel-paths Display pathnames relative to the current working
382 ** directory.
@@ -393,46 +403,47 @@
403 ** --conflict Display files having merge conflicts.
404 ** --meta Display files with metadata changes.
405 ** --unchanged Display unchanged files.
406 ** --all Display all managed files, i.e. all of the above.
407 ** --extra Display unmanaged files.
408 ** --differ Display modified and extra files.
409 ** --merge Display merge contributors.
410 ** --no-merge Do not display merge contributors.
411 **
412 ** See also: extras, ls
413 */
414 void status_cmd(void){
415 /* Affirmative and negative flag option tables. */
416 static const struct {
417 const char *option; /* Flag name. */
418 unsigned mask; /* Flag bits. */
 
419 } flagDefs[] = {
420 {"edited" , C_EDITED }, {"updated" , C_UPDATED },
421 {"changed" , C_CHANGED }, {"missing" , C_MISSING },
422 {"added" , C_ADDED }, {"deleted" , C_DELETED },
423 {"renamed" , C_RENAMED }, {"conflict" , C_CONFLICT },
424 {"meta" , C_META }, {"unchanged" , C_UNCHANGED},
425 {"all" , C_ALL }, {"extra" , C_EXTRA },
426 {"differ" , C_DIFFER }, {"merge" , C_MERGE },
427 {"classify", C_CLASSIFY},
428 }, noFlagDefs[] = {
429 {"no-merge", C_MERGE }, {"no-classify", C_CLASSIFY },
430 };
431
432 Blob report = BLOB_INITIALIZER;
433 int changes = g.argv[1][0]=='c';
434 int useSha1sum = find_option("sha1sum", 0, 0)!=0;
435 int showHdr = changes && find_option("header", 0, 0);
436 int verboseFlag = changes && find_option("verbose", "v", 0);
437 const char *zIgnoreFlag = find_option("ignore", 0, 1);
438 unsigned scanFlags = 0;
 
439 unsigned flags = 0;
440 int vid, i;
441
442 /* Load affirmative flag options. */
443 for( i=0; i<count(flagDefs); ++i ){
444 if( (changes || !(flagDefs[i].mask & C_CLASSIFY))
445 && find_option(flagDefs[i].option, 0, 0) ){
446 flags |= flagDefs[i].mask;
447 }
448 }
449
@@ -451,11 +462,11 @@
462 flags |= C_CLASSIFY;
463 }
464
465 /* Negative flag options override defaults applied above. */
466 for( i=0; i<count(noFlagDefs); ++i ){
467 if( (changes || !(noFlagDefs[i].mask & C_CLASSIFY))
468 && find_option(noFlagDefs[i].option, 0, 0) ){
469 flags &= ~noFlagDefs[i].mask;
470 }
471 }
472
473

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button