Fossil SCM
Per forum discussion, the "touch" command now defaults to --now (the current timestamp) unless --checkin is used, which applies the timestamp of the most recent checkin in which each file was modified.
Commit
c3b48561ab41ff658113cce7133ed809d5397815fb3cd823c4b137edc499ef66
Parent
0904aa8b10fb9fb…
1 file changed
+30
-8
+30
-8
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -1814,20 +1814,28 @@ | ||
| 1814 | 1814 | ** |
| 1815 | 1815 | ** This command gets its name from the conventional Unix "touch" |
| 1816 | 1816 | ** command. |
| 1817 | 1817 | ** |
| 1818 | 1818 | ** Options: |
| 1819 | +** --now Stamp each affected file with the current time. | |
| 1820 | +** This is the default behavior. | |
| 1821 | +** -c|--checkin Stamp each affected file with the time of the | |
| 1822 | +** most recent checkin which modified that file. | |
| 1819 | 1823 | ** -g GLOBLIST Comma-separated list of glob patterns. Default |
| 1820 | 1824 | ** is to touch all SCM-controlled files. |
| 1821 | 1825 | ** -G GLOBFILE Similar to -g but reads its globs from a |
| 1822 | 1826 | ** fossil-conventional glob list file. |
| 1823 | 1827 | ** -v|-verbose Outputs information about its globs and each |
| 1824 | 1828 | ** file it touches. |
| 1825 | 1829 | ** -n|--dry-run Outputs which files would require touching, |
| 1826 | 1830 | ** but does not touch them. |
| 1827 | 1831 | ** |
| 1828 | -** Only one of -g or -G may be used. | |
| 1832 | +** Only one of -g or -G may be used. If neither is provided, | |
| 1833 | +** the effect is as if a glob of '*' were provided. | |
| 1834 | +** | |
| 1835 | +** Only one of --now and --checkin may be used. The default | |
| 1836 | +** is --now. | |
| 1829 | 1837 | ** |
| 1830 | 1838 | */ |
| 1831 | 1839 | void touch_cmd(){ |
| 1832 | 1840 | const char * zGlobList; /* -g List of glob patterns */ |
| 1833 | 1841 | const char * zGlobFile; /* -G File of glob patterns */ |
| @@ -1834,21 +1842,28 @@ | ||
| 1834 | 1842 | Glob * pGlob = 0; /* List of glob patterns */ |
| 1835 | 1843 | int verboseFlag; |
| 1836 | 1844 | int dryRunFlag; |
| 1837 | 1845 | int vid; /* Checkout version */ |
| 1838 | 1846 | int changeCount = 0; /* Number of files touched */ |
| 1847 | + int checkinFlag; /* -c|--checkin */ | |
| 1848 | + i64 const nowTime = time(0); | |
| 1839 | 1849 | Stmt q; |
| 1840 | 1850 | |
| 1841 | 1851 | verboseFlag = find_option("verbose","v",0)!=0; |
| 1842 | 1852 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 1843 | 1853 | zGlobList = find_option("glob", "g",1); |
| 1844 | 1854 | zGlobFile = find_option("globfile", "G",1); |
| 1855 | + checkinFlag = find_option("checkin","c",0)!=0; | |
| 1856 | + | |
| 1857 | + if(find_option("now",0,0)!=0 && checkinFlag!=0){ | |
| 1858 | + fossil_fatal("Options --checkin and --now may not be used together."); | |
| 1859 | + } | |
| 1860 | + if(zGlobList && zGlobFile){ | |
| 1861 | + fossil_fatal("Options -g and -G may not be used together."); | |
| 1862 | + } | |
| 1845 | 1863 | |
| 1846 | 1864 | verify_all_options(); |
| 1847 | - if(zGlobList && zGlobFile){ | |
| 1848 | - fossil_fatal("Cannot use both -g and -G options."); | |
| 1849 | - } | |
| 1850 | 1865 | |
| 1851 | 1866 | db_must_be_within_tree(); |
| 1852 | 1867 | vid = db_lget_int("checkout", 0); |
| 1853 | 1868 | if(vid==0){ |
| 1854 | 1869 | fossil_fatal("Cannot determine checkout version."); |
| @@ -1868,27 +1883,34 @@ | ||
| 1868 | 1883 | if( pGlob && verboseFlag!=0 ){ |
| 1869 | 1884 | int i; |
| 1870 | 1885 | for(i=0; i<pGlob->nPattern; ++i){ |
| 1871 | 1886 | fossil_print("glob: %s\n", pGlob->azPattern[i]); |
| 1872 | 1887 | } |
| 1888 | + } | |
| 1889 | + if( verboseFlag ){ | |
| 1890 | + if(checkinFlag){ | |
| 1891 | + fossil_print("Using mtime from most recent commit(s).\n"); | |
| 1892 | + }else{ | |
| 1893 | + fossil_print("Using current time.\n"); | |
| 1894 | + } | |
| 1873 | 1895 | } |
| 1874 | 1896 | while(SQLITE_ROW==db_step(&q)){ |
| 1875 | 1897 | const char * zName = db_column_text(&q, 1); |
| 1876 | 1898 | int const fid = db_column_int(&q, 0); |
| 1877 | - i64 scmMtime; | |
| 1899 | + i64 newMtime = checkinFlag ? 0 : nowTime; | |
| 1878 | 1900 | i64 currentMtime; |
| 1879 | 1901 | if(pGlob){ |
| 1880 | 1902 | if(glob_match(pGlob, zName)==0) continue; |
| 1881 | 1903 | } |
| 1882 | 1904 | currentMtime = file_mtime(zName, 0); |
| 1883 | - if( mtime_of_manifest_file(vid, fid, &scmMtime)==0 ){ | |
| 1884 | - if( currentMtime!=scmMtime ){ | |
| 1905 | + if( newMtime || mtime_of_manifest_file(vid, fid, &newMtime)==0 ){ | |
| 1906 | + if( currentMtime!=newMtime ){ | |
| 1885 | 1907 | ++changeCount; |
| 1886 | 1908 | if( dryRunFlag!=0 ){ |
| 1887 | 1909 | fossil_print( "dry-run: %s\n", zName ); |
| 1888 | 1910 | }else{ |
| 1889 | - file_set_mtime(zName, scmMtime); | |
| 1911 | + file_set_mtime(zName, newMtime); | |
| 1890 | 1912 | if( verboseFlag!=0 ){ |
| 1891 | 1913 | fossil_print( "touched %s\n", zName ); |
| 1892 | 1914 | } |
| 1893 | 1915 | } |
| 1894 | 1916 | } |
| 1895 | 1917 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1814,20 +1814,28 @@ | |
| 1814 | ** |
| 1815 | ** This command gets its name from the conventional Unix "touch" |
| 1816 | ** command. |
| 1817 | ** |
| 1818 | ** Options: |
| 1819 | ** -g GLOBLIST Comma-separated list of glob patterns. Default |
| 1820 | ** is to touch all SCM-controlled files. |
| 1821 | ** -G GLOBFILE Similar to -g but reads its globs from a |
| 1822 | ** fossil-conventional glob list file. |
| 1823 | ** -v|-verbose Outputs information about its globs and each |
| 1824 | ** file it touches. |
| 1825 | ** -n|--dry-run Outputs which files would require touching, |
| 1826 | ** but does not touch them. |
| 1827 | ** |
| 1828 | ** Only one of -g or -G may be used. |
| 1829 | ** |
| 1830 | */ |
| 1831 | void touch_cmd(){ |
| 1832 | const char * zGlobList; /* -g List of glob patterns */ |
| 1833 | const char * zGlobFile; /* -G File of glob patterns */ |
| @@ -1834,21 +1842,28 @@ | |
| 1834 | Glob * pGlob = 0; /* List of glob patterns */ |
| 1835 | int verboseFlag; |
| 1836 | int dryRunFlag; |
| 1837 | int vid; /* Checkout version */ |
| 1838 | int changeCount = 0; /* Number of files touched */ |
| 1839 | Stmt q; |
| 1840 | |
| 1841 | verboseFlag = find_option("verbose","v",0)!=0; |
| 1842 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 1843 | zGlobList = find_option("glob", "g",1); |
| 1844 | zGlobFile = find_option("globfile", "G",1); |
| 1845 | |
| 1846 | verify_all_options(); |
| 1847 | if(zGlobList && zGlobFile){ |
| 1848 | fossil_fatal("Cannot use both -g and -G options."); |
| 1849 | } |
| 1850 | |
| 1851 | db_must_be_within_tree(); |
| 1852 | vid = db_lget_int("checkout", 0); |
| 1853 | if(vid==0){ |
| 1854 | fossil_fatal("Cannot determine checkout version."); |
| @@ -1868,27 +1883,34 @@ | |
| 1868 | if( pGlob && verboseFlag!=0 ){ |
| 1869 | int i; |
| 1870 | for(i=0; i<pGlob->nPattern; ++i){ |
| 1871 | fossil_print("glob: %s\n", pGlob->azPattern[i]); |
| 1872 | } |
| 1873 | } |
| 1874 | while(SQLITE_ROW==db_step(&q)){ |
| 1875 | const char * zName = db_column_text(&q, 1); |
| 1876 | int const fid = db_column_int(&q, 0); |
| 1877 | i64 scmMtime; |
| 1878 | i64 currentMtime; |
| 1879 | if(pGlob){ |
| 1880 | if(glob_match(pGlob, zName)==0) continue; |
| 1881 | } |
| 1882 | currentMtime = file_mtime(zName, 0); |
| 1883 | if( mtime_of_manifest_file(vid, fid, &scmMtime)==0 ){ |
| 1884 | if( currentMtime!=scmMtime ){ |
| 1885 | ++changeCount; |
| 1886 | if( dryRunFlag!=0 ){ |
| 1887 | fossil_print( "dry-run: %s\n", zName ); |
| 1888 | }else{ |
| 1889 | file_set_mtime(zName, scmMtime); |
| 1890 | if( verboseFlag!=0 ){ |
| 1891 | fossil_print( "touched %s\n", zName ); |
| 1892 | } |
| 1893 | } |
| 1894 | } |
| 1895 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1814,20 +1814,28 @@ | |
| 1814 | ** |
| 1815 | ** This command gets its name from the conventional Unix "touch" |
| 1816 | ** command. |
| 1817 | ** |
| 1818 | ** Options: |
| 1819 | ** --now Stamp each affected file with the current time. |
| 1820 | ** This is the default behavior. |
| 1821 | ** -c|--checkin Stamp each affected file with the time of the |
| 1822 | ** most recent checkin which modified that file. |
| 1823 | ** -g GLOBLIST Comma-separated list of glob patterns. Default |
| 1824 | ** is to touch all SCM-controlled files. |
| 1825 | ** -G GLOBFILE Similar to -g but reads its globs from a |
| 1826 | ** fossil-conventional glob list file. |
| 1827 | ** -v|-verbose Outputs information about its globs and each |
| 1828 | ** file it touches. |
| 1829 | ** -n|--dry-run Outputs which files would require touching, |
| 1830 | ** but does not touch them. |
| 1831 | ** |
| 1832 | ** Only one of -g or -G may be used. If neither is provided, |
| 1833 | ** the effect is as if a glob of '*' were provided. |
| 1834 | ** |
| 1835 | ** Only one of --now and --checkin may be used. The default |
| 1836 | ** is --now. |
| 1837 | ** |
| 1838 | */ |
| 1839 | void touch_cmd(){ |
| 1840 | const char * zGlobList; /* -g List of glob patterns */ |
| 1841 | const char * zGlobFile; /* -G File of glob patterns */ |
| @@ -1834,21 +1842,28 @@ | |
| 1842 | Glob * pGlob = 0; /* List of glob patterns */ |
| 1843 | int verboseFlag; |
| 1844 | int dryRunFlag; |
| 1845 | int vid; /* Checkout version */ |
| 1846 | int changeCount = 0; /* Number of files touched */ |
| 1847 | int checkinFlag; /* -c|--checkin */ |
| 1848 | i64 const nowTime = time(0); |
| 1849 | Stmt q; |
| 1850 | |
| 1851 | verboseFlag = find_option("verbose","v",0)!=0; |
| 1852 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 1853 | zGlobList = find_option("glob", "g",1); |
| 1854 | zGlobFile = find_option("globfile", "G",1); |
| 1855 | checkinFlag = find_option("checkin","c",0)!=0; |
| 1856 | |
| 1857 | if(find_option("now",0,0)!=0 && checkinFlag!=0){ |
| 1858 | fossil_fatal("Options --checkin and --now may not be used together."); |
| 1859 | } |
| 1860 | if(zGlobList && zGlobFile){ |
| 1861 | fossil_fatal("Options -g and -G may not be used together."); |
| 1862 | } |
| 1863 | |
| 1864 | verify_all_options(); |
| 1865 | |
| 1866 | db_must_be_within_tree(); |
| 1867 | vid = db_lget_int("checkout", 0); |
| 1868 | if(vid==0){ |
| 1869 | fossil_fatal("Cannot determine checkout version."); |
| @@ -1868,27 +1883,34 @@ | |
| 1883 | if( pGlob && verboseFlag!=0 ){ |
| 1884 | int i; |
| 1885 | for(i=0; i<pGlob->nPattern; ++i){ |
| 1886 | fossil_print("glob: %s\n", pGlob->azPattern[i]); |
| 1887 | } |
| 1888 | } |
| 1889 | if( verboseFlag ){ |
| 1890 | if(checkinFlag){ |
| 1891 | fossil_print("Using mtime from most recent commit(s).\n"); |
| 1892 | }else{ |
| 1893 | fossil_print("Using current time.\n"); |
| 1894 | } |
| 1895 | } |
| 1896 | while(SQLITE_ROW==db_step(&q)){ |
| 1897 | const char * zName = db_column_text(&q, 1); |
| 1898 | int const fid = db_column_int(&q, 0); |
| 1899 | i64 newMtime = checkinFlag ? 0 : nowTime; |
| 1900 | i64 currentMtime; |
| 1901 | if(pGlob){ |
| 1902 | if(glob_match(pGlob, zName)==0) continue; |
| 1903 | } |
| 1904 | currentMtime = file_mtime(zName, 0); |
| 1905 | if( newMtime || mtime_of_manifest_file(vid, fid, &newMtime)==0 ){ |
| 1906 | if( currentMtime!=newMtime ){ |
| 1907 | ++changeCount; |
| 1908 | if( dryRunFlag!=0 ){ |
| 1909 | fossil_print( "dry-run: %s\n", zName ); |
| 1910 | }else{ |
| 1911 | file_set_mtime(zName, newMtime); |
| 1912 | if( verboseFlag!=0 ){ |
| 1913 | fossil_print( "touched %s\n", zName ); |
| 1914 | } |
| 1915 | } |
| 1916 | } |
| 1917 |