Fossil

Changes On Branch touch-command
Login

Changes On Branch touch-command

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

Changes In Branch touch-command Excluding Merge-Ins

This is equivalent to a diff from 34fcaf82 to c5521b64

2019-06-13
08:58
Add the --setmtime option to the "checkout" and "open" commands. Add a new "touch" command that does nothing but run --setmtime on all named files. ... (check-in: a7e86f5b user: drh tags: trunk)
08:20
Help text improvements. ... (Closed-Leaf check-in: c5521b64 user: stephan tags: touch-command)
08:13
Help text typo. ... (check-in: 85e3340b user: stephan tags: touch-command)
08:04
Added new 'touch' command to set the mtime of files to their SCM-side values. ... (check-in: 4d9ec3e3 user: stephan tags: touch-command)
07:49
Update the copyTextToClipboard() Javascript function to suppress scrolling, and remove the temporary textarea in case of an error (i.e. blocked clipboard access), as suggested here: https://fossil-scm.org/forum/forumpost/40189d7d2f. ... (Closed-Leaf check-in: ba3e6fe7 user: florian tags: copybtn.js-tweaks)
06:18
Added a -setmtime flag to the checkout and open commands which works identically to that flag for the update command. The open command should arguably do this by default. ... (Closed-Leaf check-in: e59d8d99 user: stephan tags: setmtime-checkout-open)
06:15
Documented the --setmtime flag to the update command. ... (check-in: 34fcaf82 user: stephan tags: trunk)
2019-06-12
12:11
Avoid attaching a database file that already exists. ... (check-in: 052c5f24 user: drh tags: trunk)

Changes to src/file.c.

1796
1797
1798
1799
1800
1801
1802








































































































  if( g.argc!=3 && g.argc!=4 ){
    usage("NAME [GLOB] [-nodots]");
  }
  zDir = g.argv[2];
  zGlob = g.argc==4 ? g.argv[3] : 0;
  fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles));
}















































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
  if( g.argc!=3 && g.argc!=4 ){
    usage("NAME [GLOB] [-nodots]");
  }
  zDir = g.argv[2];
  zGlob = g.argc==4 ? g.argv[3] : 0;
  fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles));
}


/*
** COMMAND: touch*
**
** Usage: %fossil touch ?OPTIONS?
**
** For each file in the current checkout matching one of the provided
** list of glob patterns, or all files if no globs are provided, sets
** the file's mtime to the time of the last checkin which modified
** that file.
**
** This command gets its name from the conventional Unix "touch"
** command.
**
** Options:
**   -g GLOBLIST    Comma-separated list of glob patterns. Default
**                  is to touch all SCM-controlled files.
**   -G GLOBFILE    Similar to -g but reads its globs from a
**                  fossil-conventional glob list file.
**   -v|-verbose    Outputs information about its globs and each
**                  file it touches.
**   -n|--dry-run   Outputs which files would require touching,
**                  but does not touch them.
**
** Only one of -g or -G may be used.
**
*/
void touch_cmd(){
  const char * zGlobList; /* -g List of glob patterns */ 
  const char * zGlobFile; /* -G File of glob patterns */
  Glob * pGlob = 0;       /* List of glob patterns */
  int verboseFlag;
  int dryRunFlag;
  int vid;                /* Checkout version */
  int changeCount = 0;    /* Number of files touched */
  Stmt q;

  verboseFlag = find_option("verbose","v",0)!=0;
  dryRunFlag = find_option("dry-run","n",0)!=0;
  zGlobList = find_option("glob", "g",1);
  zGlobFile = find_option("globfile", "G",1);

  verify_all_options();
  if(zGlobList && zGlobFile){
    fossil_fatal("Cannot use both -g and -G options.");
  }

  db_must_be_within_tree();
  vid = db_lget_int("checkout", 0);
  if(vid==0){
    fossil_fatal("Cannot determine checkout version.");
  }
  if(zGlobList){
    pGlob = *zGlobList ? glob_create(zGlobList) : 0;
  }else if(zGlobFile){
    Blob globs;
    blob_read_from_file(&globs, zGlobFile, ExtFILE);
    pGlob = glob_create( globs.aData );
    blob_reset(&globs);
  }
  db_begin_transaction();
  db_prepare(&q, "SELECT vfile.mrid, pathname "
             "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid "
             "WHERE vid=%d", vid);
  if( pGlob && verboseFlag!=0 ){
    int i;
    for(i=0; i<pGlob->nPattern; ++i){
      fossil_print("glob: %s\n", pGlob->azPattern[i]);
    }
  }
  while(SQLITE_ROW==db_step(&q)){
    const char * zName = db_column_text(&q, 1);
    int const fid = db_column_int(&q, 0);
    i64 scmMtime;
    i64 currentMtime;
    if(pGlob){
      if(glob_match(pGlob, zName)==0) continue;
    }
    currentMtime = file_mtime(zName, 0);
    if( mtime_of_manifest_file(vid, fid, &scmMtime)==0 ){
      if( currentMtime!=scmMtime ){
        ++changeCount;
        if( dryRunFlag!=0 ){
          fossil_print( "dry-run: %s\n", zName );
        }else{
          file_set_mtime(zName, scmMtime);
          if( verboseFlag!=0 ){
            fossil_print( "touched %s\n", zName );
          }
        }
      }
    }
  }
  db_finalize(&q);
  db_end_transaction(0);
  glob_free(pGlob);
  if( dryRunFlag!=0 ){
    fossil_print("dry-run: would have touched %d file(s)\n",
                 changeCount);
  }else if( verboseFlag!=0 ){
    fossil_print("Touched %d file(s)\n", changeCount);
  }
}