Fossil

Check-in [6c72cab73c]
Login

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

Overview
Comment:Add --keep option to "fossil clean", and versionable "keep-glob" setting
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | clean-with-ignore
Files: files | file ages | folders
SHA1: 6c72cab73ca1f51bd25ab44717aa3f940e61beed
User & Date: jan.nijtmans 2013-03-12 15:48:20.925
Context
2013-03-12
15:54
fix "fossil clean --test" check-in: ca5903240d user: jan.nijtmans tags: clean-with-ignore
15:48
Add --keep option to "fossil clean", and versionable "keep-glob" setting check-in: 6c72cab73c user: jan.nijtmans tags: clean-with-ignore
15:30
Fix "fossil clean --test" not to remove files. check-in: 1c8efa5cab user: jan.nijtmans tags: trunk
12:48
merge trunk check-in: b72908bc5b user: jan.nijtmans tags: clean-with-ignore
Changes
Unified Diff Ignore Whitespace Patch
Added .fossil-settings/keep-glob.




>
>
1
2
fossil
fossil.exe
Changes to src/checkin.c.
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
419
420
421



422
423
424
425
426

427

428
429
430
431
432
433
434
** Usage: %fossil clean ?OPTIONS?
**
** Delete all "extra" files in the source tree.  "Extra" files are
** files that are not officially part of the checkout. This operation
** cannot be undone.
**
** You will be prompted before removing each file, except for files
** matching the pattern specified with --ignore.  The GLOBPATTERN
** specified by the "ignore-glob" setting is used if the --ignore

** option is omitted.  If you are sure you wish to remove all "extra"
** files you can specify the optional --force flag and no prompts will
** be issued.

**
** Files and subdirectories whose names begin with "." are
** normally skipped.  They are included if the "--dotfiles" option
** is used.
**
** Options:
**    --dotfiles       include files beginning with a dot (".")
**    --force          Remove files without prompting
**    --ignore <CSG>   don't prompt for files matching this
**                     comma separated list of glob patterns.


**    --temp           Remove only Fossil-generated temporary files
**
** See also: addremove, extra, status
*/
void clean_cmd(void){
  int allFlag;
  unsigned scanFlags = 0;
  const char *zIgnoreFlag;
  Blob path, repo;
  Stmt q;
  int n;
  Glob *pIgnore;
  int testFlag = 0;

  allFlag = find_option("force","f",0)!=0;
  if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
  if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
  zIgnoreFlag = find_option("ignore",0,1);

  testFlag = find_option("test",0,0)!=0;
  db_must_be_within_tree();
  if( zIgnoreFlag==0 ){
    zIgnoreFlag = db_get("ignore-glob", 0);
  }



  db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
                filename_collation());
  n = strlen(g.zLocalRoot);
  blob_init(&path, g.zLocalRoot, n-1);
  pIgnore = glob_create(zIgnoreFlag);

  vfile_scan(&path, blob_size(&path), scanFlags, NULL);

  db_prepare(&q,
      "SELECT %Q || x FROM sfile"
      " WHERE x NOT IN (%s)"
      " ORDER BY 1",
      g.zLocalRoot, fossil_all_reserved_names(0)
  );
  if( file_tree_name(g.zRepositoryName, &repo, 0) ){







|

>
|
|
|
>


|







>
>







|



|






>





>
>
>





>
|
>







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
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
** Usage: %fossil clean ?OPTIONS?
**
** Delete all "extra" files in the source tree.  "Extra" files are
** files that are not officially part of the checkout. This operation
** cannot be undone.
**
** You will be prompted before removing each file, except for files
** matching the patterns specified with --ignore and --keep.  The GLOBPATTERN
** specified by the "ignore-glob" setting is used if the --ignore
** option is omitted, the same with "keep-glob" and --keep.  If you are
** sure you wish to remove all "extra" files except the ones specified
** with --keep, you can specify the optional --force flag and no prompts
** will be issued. If any file matches both --keep and --ignore, --keep
** takes precedence.
**
** Files and subdirectories whose names begin with "." are
** normally kept.  They are handled if the "--dotfiles" option
** is used.
**
** Options:
**    --dotfiles       include files beginning with a dot (".")
**    --force          Remove files without prompting
**    --ignore <CSG>   don't prompt for files matching this
**                     comma separated list of glob patterns.
**    --keep <CSG>     keep files matching this comma separated
**                     list of glob patterns.
**    --temp           Remove only Fossil-generated temporary files
**
** See also: addremove, extra, status
*/
void clean_cmd(void){
  int allFlag;
  unsigned scanFlags = 0;
  const char *zIgnoreFlag, *zKeepFlag;
  Blob path, repo;
  Stmt q;
  int n;
  Glob *pIgnore, *pKeep;
  int testFlag = 0;

  allFlag = find_option("force","f",0)!=0;
  if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
  if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
  zIgnoreFlag = find_option("ignore",0,1);
  zKeepFlag = find_option("keep",0,1);
  testFlag = find_option("test",0,0)!=0;
  db_must_be_within_tree();
  if( zIgnoreFlag==0 ){
    zIgnoreFlag = db_get("ignore-glob", 0);
  }
  if( zKeepFlag==0 ){
    zKeepFlag = db_get("keep-glob", 0);
  }
  db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
                filename_collation());
  n = strlen(g.zLocalRoot);
  blob_init(&path, g.zLocalRoot, n-1);
  pIgnore = glob_create(zIgnoreFlag);
  pKeep = glob_create(zKeepFlag);
  vfile_scan(&path, blob_size(&path), scanFlags, pKeep);
  glob_free(pKeep);
  db_prepare(&q,
      "SELECT %Q || x FROM sfile"
      " WHERE x NOT IN (%s)"
      " ORDER BY 1",
      g.zLocalRoot, fossil_all_reserved_names(0)
  );
  if( file_tree_name(g.zRepositoryName, &repo, 0) ){
Changes to src/configure.c.
100
101
102
103
104
105
106

107
108
109
110
111
112
113
#endif

  { "project-name",           CONFIGSET_PROJ },
  { "project-description",    CONFIGSET_PROJ },
  { "manifest",               CONFIGSET_PROJ },
  { "binary-glob",            CONFIGSET_PROJ },
  { "ignore-glob",            CONFIGSET_PROJ },

  { "crnl-glob",              CONFIGSET_PROJ },
  { "encoding-glob",          CONFIGSET_PROJ },
  { "empty-dirs",             CONFIGSET_PROJ },
  { "allow-symlinks",         CONFIGSET_PROJ },

  { "ticket-table",           CONFIGSET_TKT  },
  { "ticket-common",          CONFIGSET_TKT  },







>







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#endif

  { "project-name",           CONFIGSET_PROJ },
  { "project-description",    CONFIGSET_PROJ },
  { "manifest",               CONFIGSET_PROJ },
  { "binary-glob",            CONFIGSET_PROJ },
  { "ignore-glob",            CONFIGSET_PROJ },
  { "keep-glob",              CONFIGSET_PROJ },
  { "crnl-glob",              CONFIGSET_PROJ },
  { "encoding-glob",          CONFIGSET_PROJ },
  { "empty-dirs",             CONFIGSET_PROJ },
  { "allow-symlinks",         CONFIGSET_PROJ },

  { "ticket-table",           CONFIGSET_TKT  },
  { "ticket-common",          CONFIGSET_TKT  },
Changes to src/db.c.
2101
2102
2103
2104
2105
2106
2107

2108
2109
2110
2111
2112
2113
2114
  { "empty-dirs",    0,               40, 1, ""                    },
  { "encoding-glob",  0,              40, 1, ""                    },
  { "gdiff-command", 0,               40, 0, "gdiff"               },
  { "gmerge-command",0,               40, 0, ""                    },
  { "http-port",     0,               16, 0, "8080"                },
  { "https-login",   0,                0, 0, "off"                 },
  { "ignore-glob",   0,               40, 1, ""                    },

  { "localauth",     0,                0, 0, "off"                 },
  { "main-branch",   0,               40, 0, "trunk"               },
  { "manifest",      0,                0, 1, "off"                 },
#ifdef FOSSIL_ENABLE_MARKDOWN
  { "markdown",      0,                0, 0, "off"                 },
#endif
  { "max-upload",    0,               25, 0, "250000"              },







>







2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
  { "empty-dirs",    0,               40, 1, ""                    },
  { "encoding-glob",  0,              40, 1, ""                    },
  { "gdiff-command", 0,               40, 0, "gdiff"               },
  { "gmerge-command",0,               40, 0, ""                    },
  { "http-port",     0,               16, 0, "8080"                },
  { "https-login",   0,                0, 0, "off"                 },
  { "ignore-glob",   0,               40, 1, ""                    },
  { "keep-glob",     0,               40, 1, ""                    },
  { "localauth",     0,                0, 0, "off"                 },
  { "main-branch",   0,               40, 0, "trunk"               },
  { "manifest",      0,                0, 1, "off"                 },
#ifdef FOSSIL_ENABLE_MARKDOWN
  { "markdown",      0,                0, 0, "off"                 },
#endif
  { "max-upload",    0,               25, 0, "250000"              },
2234
2235
2236
2237
2238
2239
2240




2241
2242
2243
2244
2245
2246
2247
**
**    https-login      Send login credentials using HTTPS instead of HTTP
**                     even if the login page request came via HTTP.
**
**    ignore-glob      The VALUE is a comma or newline-separated list of GLOB
**     (versionable)   patterns specifying files that the "extra" command will
**                     ignore.  Example:  *.o,*.obj,*.exe




**
**    localauth        If enabled, require that HTTP connections from
**                     127.0.0.1 be authenticated by password.  If
**                     false, all HTTP requests from localhost have
**                     unrestricted access to the repository.
**
**    main-branch      The primary branch for the project.  Default: trunk







>
>
>
>







2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
**
**    https-login      Send login credentials using HTTPS instead of HTTP
**                     even if the login page request came via HTTP.
**
**    ignore-glob      The VALUE is a comma or newline-separated list of GLOB
**     (versionable)   patterns specifying files that the "extra" command will
**                     ignore.  Example:  *.o,*.obj,*.exe
**
**    keep-glob        The VALUE is a comma or newline-separated list of GLOB
**     (versionable)   patterns specifying files that the "clean" command will
**                     keep.  Example:  *.log
**
**    localauth        If enabled, require that HTTP connections from
**                     127.0.0.1 be authenticated by password.  If
**                     false, all HTTP requests from localhost have
**                     unrestricted access to the repository.
**
**    main-branch      The primary branch for the project.  Default: trunk
Changes to src/json_config.c.
62
63
64
65
66
67
68

69
70
71
72
73
74
75
{ "timeline-block-markup",  CONFIGSET_SKIN },
{ "timeline-max-comment",   CONFIGSET_SKIN },

{ "project-name",           CONFIGSET_PROJ },
{ "project-description",    CONFIGSET_PROJ },
{ "manifest",               CONFIGSET_PROJ },
{ "ignore-glob",            CONFIGSET_PROJ },

{ "crnl-glob",              CONFIGSET_PROJ },
{ "empty-dirs",             CONFIGSET_PROJ },
{ "allow-symlinks",         CONFIGSET_PROJ },

{ "ticket-table",           CONFIGSET_TKT  },
{ "ticket-common",          CONFIGSET_TKT  },
{ "ticket-change",          CONFIGSET_TKT  },







>







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{ "timeline-block-markup",  CONFIGSET_SKIN },
{ "timeline-max-comment",   CONFIGSET_SKIN },

{ "project-name",           CONFIGSET_PROJ },
{ "project-description",    CONFIGSET_PROJ },
{ "manifest",               CONFIGSET_PROJ },
{ "ignore-glob",            CONFIGSET_PROJ },
{ "keep-glob",              CONFIGSET_PROJ },
{ "crnl-glob",              CONFIGSET_PROJ },
{ "empty-dirs",             CONFIGSET_PROJ },
{ "allow-symlinks",         CONFIGSET_PROJ },

{ "ticket-table",           CONFIGSET_TKT  },
{ "ticket-common",          CONFIGSET_TKT  },
{ "ticket-change",          CONFIGSET_TKT  },