Fossil

Check-in [cc3baab8]
Login

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

Overview
Comment:Implement changes option parser and default logic, still need to implement filtering
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | andygoth-changes
Files: files | file ages | folders
SHA1: cc3baab8ad31895d6c4bef0be0c24999c1fbe7f7
User & Date: andygoth 2016-11-05 21:25:51
Context
2016-11-05
21:26
Comment tweak check-in: c3f72593 user: andygoth tags: andygoth-changes
21:25
Implement changes option parser and default logic, still need to implement filtering check-in: cc3baab8 user: andygoth tags: andygoth-changes
19:25
Merge trunk check-in: e6787d1e user: andygoth tags: andygoth-changes
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/checkin.c.

18
19
20
21
22
23
24


































25
26
27
28
29
30
31
...
217
218
219
220
221
222
223
224

225
226



227
228
229
230
231
232
233
...
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
** This file contains code used to check-in versions of the project
** from the local repository.
*/
#include "config.h"
#include "checkin.h"
#include <assert.h>



































/*
** Generate text describing all changes.  Prepend zPrefix to each line
** of output.
**
** We assume that vfile_check_signature has been run.
**
** If missingIsFatal is true, then any files that are missing or which
................................................................................
** 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
** a code describing the file's change type, e.g. EDITED or RENAMED.  It
** is enabled by default except when exactly one filter option (besides

** --merge or --no-merge) is used.  The default can be overridden by the
** --classify or --no-classify options.



**
** The "fossil changes --extra" command is equivalent to "fossil extras".
**
** General options:
**    --abs-paths       Display absolute pathnames.
**    --rel-paths       Display pathnames relative to the current working
**                      directory.
................................................................................
**    --extra           Display unmanaged files.
**    --merge           Display merge contributors.
**    --no-merge        Do not display merge contributors.
**
** See also: extras, ls, status
*/
void changes_cmd(void){
  int useSha1sum = find_option("sha1sum", 0, 0)!=0;
  int showHdr = find_option("header",0,0)!=0;
  int verboseFlag = find_option("verbose","v",0)!=0;
  int cwdRelative = 0;






























































  db_must_be_within_tree();


  cwdRelative = determine_cwd_relative_option();












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

  print_changes(useSha1sum, showHdr, verboseFlag, cwdRelative);


}

/*
** COMMAND: status
**
** Usage: %fossil status ?OPTIONS?
**







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
>
|
|
>
>
>







 







|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
|
>
|
>
>
>
>
>
>
>
>
>
>
|


<
>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
...
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
...
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
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
** This file contains code used to check-in versions of the project
** from the local repository.
*/
#include "config.h"
#include "checkin.h"
#include <assert.h>

/*
** Change filter options.
*/
enum {
  /* Zero-based bit indexes. */
  CB_EDITED , CB_UPDATED , CB_CHANGED, CB_MISSING   , CB_ADDED   , CB_DELETED,
  CB_RENAMED, CB_CONFLICT, CB_META   , CB_UNMODIFIED, CB_EXTRA   , CB_MERGE  ,
  CB_RELPATH, CB_SHA1SUM , CB_HEADER , CB_VERBOSE   , CB_CLASSIFY,

  /* Bitmask values. */
  C_EDITED     = 1 << CB_EDITED,
  C_UPDATED    = 1 << CB_UPDATED,
  C_CHANGED    = 1 << CB_CHANGED, /* Resembles CB_EDITED|CB_UPDATED. */
  C_MISSING    = 1 << CB_MISSING,
  C_ADDED      = 1 << CB_ADDED,
  C_DELETED    = 1 << CB_DELETED,
  C_RENAMED    = 1 << CB_RENAMED,
  C_CONFLICT   = 1 << CB_CONFLICT,
  C_META       = 1 << CB_META,
  C_UNMODIFIED = 1 << CB_UNMODIFIED,
  C_EXTRA      = 1 << CB_EXTRA,
  C_MERGE      = 1 << CB_MERGE,
  C_FILTER     = C_EDITED  | C_UPDATED | C_CHANGED  | C_MISSING | C_ADDED
               | C_DELETED | C_RENAMED | C_CONFLICT | C_META    | C_UNMODIFIED
               | C_EXTRA   | C_MERGE,
  C_ALL        = C_FILTER & ~(C_CHANGED | C_EXTRA | C_MERGE),
  C_RELPATH    = 1 << CB_RELPATH,
  C_SHA1SUM    = 1 << CB_SHA1SUM,
  C_HEADER     = 1 << CB_HEADER,
  C_VERBOSE    = 1 << CB_VERBOSE,
  C_CLASSIFY   = 1 << CB_CLASSIFY,
  C_DEFAULT    = (C_ALL & ~C_UNMODIFIED) | C_MERGE | C_CLASSIFY,
};

/*
** Generate text describing all changes.  Prepend zPrefix to each line
** of output.
**
** We assume that vfile_check_signature has been run.
**
** If missingIsFatal is true, then any files that are missing or which
................................................................................
** 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
** a code describing the file's change type, e.g. EDITED or RENAMED.  It
** is enabled by default unless exactly one change type is selected.  For
** the purposes of determining the default, --changed counts as selecting
** one change type.  The default can be overridden by the --classify or
** --no-classify options.
**
** If both --merge and --no-merge are used, --no-merge has priority.  The
** same is true of --classify and --no-classify.
**
** The "fossil changes --extra" command is equivalent to "fossil extras".
**
** General options:
**    --abs-paths       Display absolute pathnames.
**    --rel-paths       Display pathnames relative to the current working
**                      directory.
................................................................................
**    --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, at this point in the code, --changed is treated as a single
   * filter, i.e. it only sets one bit.  If masking flags against itself less
   * one and C_FILTER yields nonzero, it has more than one C_FILTER bit set, so
   * classification should be turned on. */
  if( flags & (flags-1) & C_FILTER ){
    flags |= C_CLASSIFY;
  }

  /* Now that the --classify default is decided, convert --changed to be
   * --edited plus --updated. */
  if( flags & C_CHANGED ){
    flags = (flags | C_EDITED | C_UPDATED) & ~C_CHANGED;
  }

  /* 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;
  }

#ifdef FOSSIL_DEBUG
  for( i=0; i<count(bits); ++i ){
    if( flags & (1 << i) ){
      printf("%s ", bits[i]);
    }
  }
  printf("\n");
#endif

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


  print_changes(flags & C_SHA1SUM, flags & C_HEADER,
                flags & C_VERBOSE, flags & C_RELPATH);
}

/*
** COMMAND: status
**
** Usage: %fossil status ?OPTIONS?
**