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.

stephan 2019-06-13 10:15 trunk
Commit c3b48561ab41ff658113cce7133ed809d5397815fb3cd823c4b137edc499ef66
1 file changed +30 -8
+30 -8
--- src/file.c
+++ src/file.c
@@ -1814,20 +1814,28 @@
18141814
**
18151815
** This command gets its name from the conventional Unix "touch"
18161816
** command.
18171817
**
18181818
** 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.
18191823
** -g GLOBLIST Comma-separated list of glob patterns. Default
18201824
** is to touch all SCM-controlled files.
18211825
** -G GLOBFILE Similar to -g but reads its globs from a
18221826
** fossil-conventional glob list file.
18231827
** -v|-verbose Outputs information about its globs and each
18241828
** file it touches.
18251829
** -n|--dry-run Outputs which files would require touching,
18261830
** but does not touch them.
18271831
**
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.
18291837
**
18301838
*/
18311839
void touch_cmd(){
18321840
const char * zGlobList; /* -g List of glob patterns */
18331841
const char * zGlobFile; /* -G File of glob patterns */
@@ -1834,21 +1842,28 @@
18341842
Glob * pGlob = 0; /* List of glob patterns */
18351843
int verboseFlag;
18361844
int dryRunFlag;
18371845
int vid; /* Checkout version */
18381846
int changeCount = 0; /* Number of files touched */
1847
+ int checkinFlag; /* -c|--checkin */
1848
+ i64 const nowTime = time(0);
18391849
Stmt q;
18401850
18411851
verboseFlag = find_option("verbose","v",0)!=0;
18421852
dryRunFlag = find_option("dry-run","n",0)!=0;
18431853
zGlobList = find_option("glob", "g",1);
18441854
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
+ }
18451863
18461864
verify_all_options();
1847
- if(zGlobList && zGlobFile){
1848
- fossil_fatal("Cannot use both -g and -G options.");
1849
- }
18501865
18511866
db_must_be_within_tree();
18521867
vid = db_lget_int("checkout", 0);
18531868
if(vid==0){
18541869
fossil_fatal("Cannot determine checkout version.");
@@ -1868,27 +1883,34 @@
18681883
if( pGlob && verboseFlag!=0 ){
18691884
int i;
18701885
for(i=0; i<pGlob->nPattern; ++i){
18711886
fossil_print("glob: %s\n", pGlob->azPattern[i]);
18721887
}
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
+ }
18731895
}
18741896
while(SQLITE_ROW==db_step(&q)){
18751897
const char * zName = db_column_text(&q, 1);
18761898
int const fid = db_column_int(&q, 0);
1877
- i64 scmMtime;
1899
+ i64 newMtime = checkinFlag ? 0 : nowTime;
18781900
i64 currentMtime;
18791901
if(pGlob){
18801902
if(glob_match(pGlob, zName)==0) continue;
18811903
}
18821904
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 ){
18851907
++changeCount;
18861908
if( dryRunFlag!=0 ){
18871909
fossil_print( "dry-run: %s\n", zName );
18881910
}else{
1889
- file_set_mtime(zName, scmMtime);
1911
+ file_set_mtime(zName, newMtime);
18901912
if( verboseFlag!=0 ){
18911913
fossil_print( "touched %s\n", zName );
18921914
}
18931915
}
18941916
}
18951917
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button