Fossil

Check-in [d52fd185]
Login

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

Overview
Comment:Minor optimization to status_report() to avoid building list of managed files if only unmanaged files are requested. Move unmanaged file reserved name filtering to status_report(). Ensure db_get*() calls happen after db_must_be_within_tree(). Implement extras_cmd() in terms of status_report().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | andygoth-changes
Files: files | file ages | folders
SHA1:d52fd18529c7faf8d1656d26cbf33edb18e6d3a9
User & Date: andygoth 2016-11-06 04:13:28
Context
2016-11-06
04:17
Change -unmodified/UNMODIFIED to -unchanged/UNCHANGED in status_report() for consistency with the ls -v command check-in: 5775d376 user: andygoth tags: andygoth-changes
04:13
Minor optimization to status_report() to avoid building list of managed files if only unmanaged files are requested. Move unmanaged file reserved name filtering to status_report(). Ensure db_get*() calls happen after db_must_be_within_tree(). Implement extras_cmd() in terms of status_report(). check-in: d52fd185 user: andygoth tags: andygoth-changes
03:16
Remove unused final argument to locate_unmanaged_files() check-in: c2b3f6b1 user: andygoth tags: andygoth-changes
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/checkin.c.

134
135
136
137
138
139
140
141
142


143
144
145
146
147
148
149
150
151
152

153
154
155
156

157



158
159
160
161
162
163
164
165
...
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
...
469
470
471
472
473
474
475










476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
...
766
767
768
769
770
771
772
773
774
775

776
777
778
779
780
781
782
783

784


785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816



817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
      "OR (pathname>'%q/' %s AND pathname<'%q0' %s)",
      (blob_size(&where)>0) ? "OR" : "AND", zName,
      filename_collation(), zName, filename_collation(),
      zName, filename_collation()
    );
  }

  /* Start building the SELECT statement. */
  blob_zero(&sql);


  blob_append_sql(&sql,
    "SELECT pathname, deleted, chnged, rid,"
    "       coalesce(origname!=pathname,0) AS renamed, islink, 1 AS managed"
    "  FROM vfile"
    " WHERE is_selected(id)%s", blob_sql_text(&where));

  /* Exclude unmodified files unless requested. */
  if( !(flags & C_UNMODIFIED) ){
    blob_append_sql(&sql,
        " AND (chnged OR deleted OR rid=0 OR pathname!=origname)");

  }

  /* If C_EXTRA, add unmanaged files to the query result too. */
  if( flags & C_EXTRA ){

    blob_append_sql(&sql, " UNION ALL SELECT x AS pathname, 0, 0, 0, 0, 0, 0"



                          " FROM sfile WHERE 1%s", blob_sql_text(&where));
  }

  /* Append an ORDER BY clause then compile the query. */
  blob_append_sql(&sql, " ORDER BY pathname");
  db_prepare(&q, "%s", blob_sql_text(&sql));
  blob_reset(&sql);
  blob_reset(&where);
................................................................................
  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;

  /* If --ignore is not specified, use the ignore-glob setting. */
  if( !zIgnoreFlag ){
    zIgnoreFlag = db_get("ignore-glob", 0);
  }

  /* Get the --dotfiles argument, or read it from the dotfiles setting. */
  if( find_option("dotfiles", 0, 0) || db_get_boolean("dotfiles", 0) ){
    scanFlags = SCAN_ALL;
  }

  /* 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;
    }
  }
................................................................................
  /* Get checkout version. l*/
  vid = db_lget_int("checkout", 0);

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











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

  /* Check for changed files. */
  vfile_check_signature(vid, useSha1sum ? CKSIG_SHA1 : 0);

  /* Search for unmanaged files if requested.  Exclude reserved files. */
  if( flags & C_EXTRA ){
    Glob *pIgnore = glob_create(zIgnoreFlag);
    locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore);
    glob_free(pIgnore);
    db_multi_exec("DELETE FROM sfile WHERE x IN (%s)",
        fossil_all_reserved_names(0));
  }

  /* The status command prints general information before the change list. */
  if( !changes ){
    fossil_print("repository:   %s\n", db_repository_filename());
    fossil_print("local-root:   %s\n", g.zLocalRoot);
    if( g.zConfigDbName ){
................................................................................
**    --ignore <CSG>   ignore files matching patterns from the argument
**    --rel-paths      Display pathnames relative to the current working
**                     directory.
**
** See also: changes, clean, status
*/
void extras_cmd(void){
  Stmt q;
  const char *zIgnoreFlag = find_option("ignore",0,1);
  unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;

  int showHdr = find_option("header",0,0)!=0;
  int cwdRelative = 0;
  Glob *pIgnore;
  Blob rewrittenPathname;
  const char *zPathname, *zDisplayName;

  if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
  db_must_be_within_tree();

  cwdRelative = determine_cwd_relative_option();



  if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL;

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

  if( zIgnoreFlag==0 ){
    zIgnoreFlag = db_get("ignore-glob", 0);
  }
  pIgnore = glob_create(zIgnoreFlag);
  locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore);
  glob_free(pIgnore);
  db_prepare(&q,
      "SELECT x FROM sfile"
      " WHERE x NOT IN (%s)"
      " ORDER BY 1",
      fossil_all_reserved_names(0)
  );
  db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
  blob_zero(&rewrittenPathname);
  g.allowSymlinks = 1;  /* Report on symbolic links */
  while( db_step(&q)==SQLITE_ROW ){
    zDisplayName = zPathname = db_column_text(&q, 0);
    if( cwdRelative ){
      char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
      file_relative_name(zFullName, &rewrittenPathname, 0);
      free(zFullName);
      zDisplayName = blob_str(&rewrittenPathname);
      if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){
        zDisplayName += 2;  /* no unnecessary ./ prefix */
      }
    }



    if( showHdr ){
      showHdr = 0;
      fossil_print("Extras for %s at %s:\n", db_get("project-name","???"),
                   g.zLocalRoot);
    }
    fossil_print("%s\n", zDisplayName);
  }
  blob_reset(&rewrittenPathname);
  db_finalize(&q);
}

/*
** COMMAND: clean
**
** Usage: %fossil clean ?OPTIONS? ?PATH ...?
**







|

>
>
|
|
|
|
|

|
|
|
|
>




>
|
>
>
>
|







 







<
<
<
<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>







|




<
<







 







|


>

<

<
<



>
|
>
>












<
<
<
<
<
<
<
<

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

<



|

|
<







134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
...
425
426
427
428
429
430
431










432
433
434
435
436
437
438
...
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494


495
496
497
498
499
500
501
...
771
772
773
774
775
776
777
778
779
780
781
782

783


784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802








803









804

805
806
807
808

809
810
811
812
813
814

815
816
817
818
819
820
821
      "OR (pathname>'%q/' %s AND pathname<'%q0' %s)",
      (blob_size(&where)>0) ? "OR" : "AND", zName,
      filename_collation(), zName, filename_collation(),
      zName, filename_collation()
    );
  }

  /* Obtain the list of managed files if appropriate. */
  blob_zero(&sql);
  if( flags & C_ALL ){
    /* Start with a list of all managed files. */
    blob_append_sql(&sql,
      "SELECT pathname, deleted, chnged, rid,"
      "       coalesce(origname!=pathname,0) AS renamed, islink, 1 AS managed"
      "  FROM vfile"
      " WHERE is_selected(id)%s", blob_sql_text(&where));

    /* Exclude unmodified files unless requested. */
    if( !(flags & C_UNMODIFIED) ){
      blob_append_sql(&sql,
          " AND (chnged OR deleted OR rid=0 OR pathname!=origname)");
    }
  }

  /* If C_EXTRA, add unmanaged files to the query result too. */
  if( flags & C_EXTRA ){
    if( blob_size(&sql) ){
      blob_append_sql(&sql, " UNION ALL");
    }
    blob_append_sql(&sql, " SELECT x AS pathname, 0, 0, 0, 0, 0, 0"
                          " FROM sfile WHERE pathname NOT IN (%s)%s",
                          fossil_all_reserved_names(0), blob_sql_text(&where));
  }

  /* Append an ORDER BY clause then compile the query. */
  blob_append_sql(&sql, " ORDER BY pathname");
  db_prepare(&q, "%s", blob_sql_text(&sql));
  blob_reset(&sql);
  blob_reset(&where);
................................................................................
  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;
    }
  }
................................................................................
  /* Get checkout version. l*/
  vid = db_lget_int("checkout", 0);

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

  /* If --ignore is not specified, use the ignore-glob setting. */
  if( !zIgnoreFlag ){
    zIgnoreFlag = db_get("ignore-glob", 0);
  }

  /* Get the --dotfiles argument, or read it from the dotfiles setting. */
  if( find_option("dotfiles", 0, 0) || db_get_boolean("dotfiles", 0) ){
    scanFlags = SCAN_ALL;
  }

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

  /* Check for changed files. */
  vfile_check_signature(vid, useSha1sum ? CKSIG_SHA1 : 0);

  /* Search for unmanaged files if requested. */
  if( flags & C_EXTRA ){
    Glob *pIgnore = glob_create(zIgnoreFlag);
    locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore);
    glob_free(pIgnore);


  }

  /* The status command prints general information before the change list. */
  if( !changes ){
    fossil_print("repository:   %s\n", db_repository_filename());
    fossil_print("local-root:   %s\n", g.zLocalRoot);
    if( g.zConfigDbName ){
................................................................................
**    --ignore <CSG>   ignore files matching patterns from the argument
**    --rel-paths      Display pathnames relative to the current working
**                     directory.
**
** See also: changes, clean, status
*/
void extras_cmd(void){
  Blob report = BLOB_INITIALIZER;
  const char *zIgnoreFlag = find_option("ignore",0,1);
  unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
  unsigned flags = C_EXTRA;
  int showHdr = find_option("header",0,0)!=0;

  Glob *pIgnore;



  if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
  db_must_be_within_tree();

  if( determine_cwd_relative_option() ){
    flags |= C_RELPATH;
  }

  if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL;

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

  if( zIgnoreFlag==0 ){
    zIgnoreFlag = db_get("ignore-glob", 0);
  }
  pIgnore = glob_create(zIgnoreFlag);
  locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore);
  glob_free(pIgnore);








  g.allowSymlinks = 1;  /* Report on symbolic links */











  blob_zero(&report);
  status_report(&report, flags);
  if( blob_size(&report) ){
    if( showHdr ){

      fossil_print("Extras for %s at %s:\n", db_get("project-name","???"),
                   g.zLocalRoot);
    }
    blob_write_to_file(&report, "-");
  }
  blob_reset(&report);

}

/*
** COMMAND: clean
**
** Usage: %fossil clean ?OPTIONS? ?PATH ...?
**