Diff
Not logged in

Differences From Artifact [2eff77f006]:

To Artifact [f476f21117]:


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
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







+
+
+
+









-
+
+
+
+
+










+
+






+

-
+
+
+

-
+

+
+







** 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:
**   --now          Stamp each affected file with the current time.
**                  This is the default behavior.
**   -c|--checkin   Stamp each affected file with the time of the
**                  most recent checkin which modified that file.
**   -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.
** Only one of -g or -G may be used. If neither is provided,
** the effect is as if a glob of '*' were provided.
**
** Only one of --now and --checkin may be used. The default
** is --now.
**
*/
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 */
  int checkinFlag;        /* -c|--checkin */
  i64 const nowTime = time(0);
  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);
  checkinFlag = find_option("checkin","c",0)!=0;

  verify_all_options();
  if(find_option("now",0,0)!=0 && checkinFlag!=0){
    fossil_fatal("Options --checkin and --now may not be used together.");
  }
  if(zGlobList && zGlobFile){
    fossil_fatal("Cannot use both -g and -G options.");
    fossil_fatal("Options -g and -G may not be used together.");
  }

  verify_all_options();

  db_must_be_within_tree();
  vid = db_lget_int("checkout", 0);
  if(vid==0){
    fossil_fatal("Cannot determine checkout version.");
  }
  if(zGlobList){
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
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
1907
1908
1909
1910

1911
1912
1913
1914
1915
1916
1917
1918







+
+
+
+
+
+
+




-
+





-
-
+
+




-
+







             "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]);
    }
  }
  if( verboseFlag ){
    if(checkinFlag){
      fossil_print("Using mtime from most recent commit(s).\n");
    }else{
      fossil_print("Using current time.\n");
    }
  }
  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 newMtime = checkinFlag ? 0 : nowTime;
    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 ){
    if( newMtime || mtime_of_manifest_file(vid, fid, &newMtime)==0 ){
      if( currentMtime!=newMtime ){
        ++changeCount;
        if( dryRunFlag!=0 ){
          fossil_print( "dry-run: %s\n", zName );
        }else{
          file_set_mtime(zName, scmMtime);
          file_set_mtime(zName, newMtime);
          if( verboseFlag!=0 ){
            fossil_print( "touched %s\n", zName );
          }
        }
      }
    }
  }