Fossil

Check-in [2c3a108c]
Login

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

Overview
Comment:Merge the status command into the changes command.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | andygoth-changes
Files: files | file ages | folders
SHA1: 2c3a108c72e7d596aa7ee3a653784d75aee437af
User & Date: andygoth 2016-11-05 23:11:36
Context
2016-11-06
02:35
Fold print_changes() into status_cmd() (formerly changes_cmd()). Remove C_SHA1SUM, C_HEADER, and C_VERBOSE flags which are no longer needed for communicating options to print_changes(). Move locate_unmanaged_files() closer to the top of the file so status_cmd() can call it. Implement C_UNMODIFIED and C_EXTRA in status_report(). Document the fact that the changes and status commands take optional path arguments. Let changes and status commands accept --case-sensitive (was already done), --dotfiles, and --ignore for the benefit of --extras. Incorporate search for extra files into status_cmd(). check-in: f15d20e3 user: andygoth tags: andygoth-changes
2016-11-05
23:11
Merge the status command into the changes command. check-in: 2c3a108c user: andygoth tags: andygoth-changes
22:41
Add TODO: reimplement ls and extras in terms of status_report() check-in: 442a3cd5 user: andygoth tags: andygoth-changes
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/checkin.c.

264
265
266
267
268
269
270

271
272
273
274






275
276
277
278
279
280
281
...
309
310
311
312
313
314
315


316
317
318
319
320
321
322
...
330
331
332
333
334
335
336
337
338
339
340
341
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
...
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
452
453
454
455
456
457
458

459
460
461
462
463
464
465
466
467
468



469



470

471
472
473
474
475
476
477
  }
  blob_write_to_file(&report, "-");
  blob_reset(&report);
}

/*
** COMMAND: changes

**
** Usage: %fossil changes ?OPTIONS?
**
** Report the change status of files in the current checkout.






**
** Each line of output is the name of a changed file, with paths shown
** 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),
................................................................................
**
** 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.


**    --header          Identify the repository if report is non-empty.
**    -v|--verbose      Say "(none)" if the change report is empty.
**    --classify        Start each line with the file's change type.
**    --no-classify     Do not print file change types.
**
** Filter options:
**    --edited          Display edited, merged, and conflicted files.
................................................................................
**    --meta            Display files with metadata changes.
**    --unmodified      Display unmodified 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, status
*/
void changes_cmd(void){
  /* Affirmative and negative flag option tables. */
  static const struct {
    const char *option;
    unsigned mask;

  } 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    }, {"unmodified" , C_UNMODIFIED},
    {"all"     , C_ALL     }, {"extra"      , C_EXTRA     },
    {"merge"   , C_MERGE   }, {"sha1sum"    , C_SHA1SUM   },
    {"header"  , C_HEADER  }, {"v"          , C_VERBOSE   },
    {"verbose" , C_VERBOSE }, {"classify"   , C_CLASSIFY  },
  }, noFlagDefs[] = {
    {"no-merge", C_MERGE   }, {"no-classify", C_CLASSIFY  },
  };

#ifdef FOSSIL_DEBUG
  static const char *const bits[] = {
    "EDITED", "UPDATED", "CHANGED", "MISSING", "ADDED", "DELETED", "RENAMED",
    "CONFLICT", "META", "UNMODIFIED", "EXTRA", "MERGE", "RELPATH", "SHA1SUM",
    "HEADER", "VERBOSE", "CLASSIFY",
  };
#endif


  unsigned flags = 0;
  int i;

  /* Load affirmative flag options. */
  for( i=0; i<count(flagDefs); ++i ){

    if( find_option(flagDefs[i].option, 0, 0) ){
      flags |= flagDefs[i].mask;
    }
  }

  /* If no filter options are specified, enable defaults. */
  if( !(flags & C_FILTER) ){
    flags |= C_DEFAULT;
  }

  /* If more than one filter is enabled, enable classification.  This is tricky.
   * Having one filter means flags masked by C_FILTER is a power of two.  If a
   * number masked by one less than itself is zero, it's either zero or a power
   * of two.  It's already known to not be zero because of the above defaults.
   * Unlike --all, --changed is a single filter, i.e. it sets only one bit. */

  if( flags & (flags-1) & C_FILTER ){
    flags |= C_CLASSIFY;
  }

  /* Negative flag options override defaults applied above. */
  for( i=0; i<count(noFlagDefs); ++i ){

    if( find_option(noFlagDefs[i].option, 0, 0) ){
      flags &= ~noFlagDefs[i].mask;
    }
  }


  db_must_be_within_tree();

  /* Relative path flag determination is done by a shared function. */
  if( determine_cwd_relative_option() ){
    flags |= C_RELPATH;
  }

................................................................................
  }
  printf("\n");
#endif

  /* We should be done with options. */
  verify_all_options();


  print_changes(flags);
}

/*
** COMMAND: status
**
** Usage: %fossil status ?OPTIONS?
**
** Report on the status of the current checkout.
**
** Pathnames are displayed according to the "relative-paths" setting,
** unless overridden by the --abs-paths or --rel-paths options.
**
** 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.
**
** See also: changes, extras, ls
*/
void status_cmd(void){
  int vid;
  unsigned flags = C_DEFAULT;

  /* Check options. */
  db_must_be_within_tree();
  if( find_option("sha1sum", 0, 0) ){
    flags |= C_SHA1SUM;
  }
  if( find_option("header", 0, 0) ){
    flags |= C_HEADER;
  }
  if( find_option("verbose", "v", 0) ){
    flags |= C_VERBOSE;
  }
  if( determine_cwd_relative_option() ){
    flags |= C_RELPATH;
  }
  verify_all_options();


  fossil_print("repository:   %s\n", db_repository_filename());
  fossil_print("local-root:   %s\n", g.zLocalRoot);
  if( g.zConfigDbName ){
    fossil_print("config-db:    %s\n", g.zConfigDbName);
  }
  vid = db_lget_int("checkout", 0);
  if( vid ){
    show_common_info(vid, "checkout:", 1, 1);
  }
  db_record_repository_filename(0);



  print_changes(flags);



  leaf_ambiguity_warning(vid, vid);

}

/*
** Take care of -r version of ls command
*/
static void ls_cmd_rev(
  const char *zRev,  /* Revision string given */







>

|


>
>
>
>
>
>







 







>
>







 







|

|




>

|
|
|
|
|
|
|
|
|

|










>

|



>
|













|
>
|





>
|




>







 







>
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
|
|
|
|
|
<
|
|
|
|
>
>
>

>
>
>
|
>







264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
...
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
...
339
340
341
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
418
...
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
452
453
454
455
456
457
458
  }
  blob_write_to_file(&report, "-");
  blob_reset(&report);
}

/*
** COMMAND: changes
** COMMAND: status
**
** Usage: %fossil changes|status ?OPTIONS?
**
** Report the change status of files in the current checkout.
**
** The status command is similar to the changes command, except it lacks
** several of the options supported by changes and it has its own header
** and footer information.  The header information is a subset of that
** shown by the info command, and the footer shows if there are any forks.
** Change type classification is always enabled for the status command.
**
** Each line of output is the name of a changed file, with paths shown
** 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),
................................................................................
**
** 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.
**
** Options specific to the changes command:
**    --header          Identify the repository if report is non-empty.
**    -v|--verbose      Say "(none)" if the change report is empty.
**    --classify        Start each line with the file's change type.
**    --no-classify     Do not print file change types.
**
** Filter options:
**    --edited          Display edited, merged, and conflicted files.
................................................................................
**    --meta            Display files with metadata changes.
**    --unmodified      Display unmodified 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}, {"unmodified" , C_UNMODIFIED, 0},
    {"all"     , C_ALL    , 0}, {"extra"      , C_EXTRA     , 0},
    {"merge"   , C_MERGE  , 0}, {"sha1sum"    , C_SHA1SUM   , 0},
    {"header"  , C_HEADER , 1}, {"v"          , C_VERBOSE   , 1},
    {"verbose" , C_VERBOSE, 1}, {"classify"   , C_CLASSIFY  , 1},
  }, noFlagDefs[] = {
    {"no-merge", C_MERGE  , 0}, {"no-classify", C_CLASSIFY  , 1},
  };

#ifdef FOSSIL_DEBUG
  static const char *const bits[] = {
    "EDITED", "UPDATED", "CHANGED", "MISSING", "ADDED", "DELETED", "RENAMED",
    "CONFLICT", "META", "UNMODIFIED", "EXTRA", "MERGE", "RELPATH", "SHA1SUM",
    "HEADER", "VERBOSE", "CLASSIFY",
  };
#endif

  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) ){
    flags |= C_DEFAULT;
  }

  /* If more than one filter is enabled, enable classification.  This is tricky.
   * Having one filter means flags masked by C_FILTER is a power of two.  If a
   * number masked by one less than itself is zero, it's either zero or a power
   * of two.  It's already known to not be zero because of the above defaults.
   * Unlike --all, --changed is a single filter, i.e. it sets only one bit.
   * 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();

  /* Relative path flag determination is done by a shared function. */
  if( determine_cwd_relative_option() ){
    flags |= C_RELPATH;
  }

................................................................................
  }
  printf("\n");
#endif

  /* We should be done with options. */
  verify_all_options();

  /* The status command prints general information before the change list. */
  if( !changes ){










































    vid = db_lget_int("checkout", 0);
    fossil_print("repository:   %s\n", db_repository_filename());
    fossil_print("local-root:   %s\n", g.zLocalRoot);
    if( g.zConfigDbName ){
      fossil_print("config-db:    %s\n", g.zConfigDbName);
    }

    if( vid ){
      show_common_info(vid, "checkout:", 1, 1);
    }
    db_record_repository_filename(0);
  }

  /* Print all requested changes. */
  print_changes(flags);

  /* The status command ends with warnings about ambiguous leaves (forks). */
  if( !changes ){
    leaf_ambiguity_warning(vid, vid);
  }
}

/*
** Take care of -r version of ls command
*/
static void ls_cmd_rev(
  const char *zRev,  /* Revision string given */