Fossil SCM

Minor reformatting, doc updates, and corrected duplicate display of touched file count in dry-run mode.

stephan 2019-06-13 21:28 trunk
Commit adbbeac1515ce9107bcd8c6c949d94510f8ac98ab96a1a778424ccdc3a68c66a
1 file changed +22 -19
+22 -19
--- src/file.c
+++ src/file.c
@@ -1801,23 +1801,23 @@
18011801
fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles));
18021802
}
18031803
18041804
/*
18051805
** Internal helper for touch_cmd(). zAbsName must be resolvable as-is
1806
-** to a file - this function does not expand/normalize it. i.e. it
1807
-** "really should" be an absolute path. zTreeName is strictly
1808
-** cosmetic: it is used when dryRunFlag or verboseFlag generate
1809
-** output. It is assumed to be a repo-relative or or subdir-relative
1810
-** filename.
1806
+** to an existing file - this function does not expand/normalize
1807
+** it. i.e. it "really should" be an absolute path. zTreeName is
1808
+** strictly cosmetic: it is used when dryRunFlag or verboseFlag
1809
+** generate output. It is assumed to be a repo-relative or or
1810
+** subdir-relative filename.
18111811
**
18121812
** newMTime is the file's new timestamp (Unix epoch).
18131813
**
18141814
** Returns 1 if it sets zAbsName's mtime, 0 if it does not (indicating
18151815
** that the file already has that timestamp). Dies fatally if given an
18161816
** unresolvable filename. If dryRunFlag is true then it outputs the
18171817
** name of the file it would have timestamped but does not stamp the
1818
-** file. If verboseFlag is true, it outputs a message if the files
1818
+** file. If verboseFlag is true, it outputs a message if the file's
18191819
** timestamp is actually modified.
18201820
*/
18211821
static int touch_cmd_stamp_one_file(char const *zAbsName,
18221822
char const *zTreeName,
18231823
i64 newMtime, int dryRunFlag,
@@ -1837,20 +1837,23 @@
18371837
}
18381838
return 1;
18391839
}
18401840
18411841
/*
1842
-** Internal helper for touch_cmd(). If the given name is found in the
1843
-** given checkout version, which MUST be the checkout version
1842
+** Internal helper for touch_cmd(). If the given file name is found in
1843
+** the given checkout version, which MUST be the checkout version
18441844
** currently populating the vfile table, the vfile.mrid value for the
18451845
** file is returned, else 0 is returned. zName must be resolvable
1846
-** as-is - this function performs neither expands nor normalizes it.
1846
+** as-is from the vfile table - this function neither expands nor
1847
+** normalizes it, though it does compare using the repo's
1848
+** filename_collation() preference.
18471849
*/
18481850
static int touch_cmd_vfile_mrid( int vid, char const *zName ){
18491851
int mrid = 0;
18501852
static Stmt q = empty_Stmt_m;
1851
- db_static_prepare(&q, "SELECT vfile.mrid "
1853
+ db_static_prepare(&q,
1854
+ "SELECT vfile.mrid "
18521855
"FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid "
18531856
"WHERE vid=:vid AND pathname=:pathname %s",
18541857
filename_collation());
18551858
db_bind_int(&q, ":vid", vid);
18561859
db_bind_text(&q, ":pathname", zName);
@@ -1917,11 +1920,11 @@
19171920
int changeCount = 0; /* Number of files touched */
19181921
int quietFlag = 0; /* -q|--quiet */
19191922
int timeFlag; /* -1==--checkin, 1==--checkout, 0==--now */
19201923
i64 nowTime = 0; /* Timestamp of --now or --checkout */
19211924
Stmt q;
1922
- Blob absBuffer = empty_blob;
1925
+ Blob absBuffer = empty_blob; /* Absolute filename buffer */
19231926
19241927
verboseFlag = find_option("verbose","v",0)!=0;
19251928
quietFlag = find_option("quiet","q",0)!=0;
19261929
dryRunFlag = find_option("dry-run","n",0)!=0
19271930
|| find_option("dryrun",0,0)!=0;
@@ -1997,16 +2000,15 @@
19972000
fossil_fatal("Could not determine out checkout version's time!");
19982001
}
19992002
}else{ /* --checkin */
20002003
assert(0 == nowTime);
20012004
}
2002
- if((pGlob && pGlob->nPattern>0)
2003
- || g.argc<3 /* no non-flag arguments */ ){
2005
+ if((pGlob && pGlob->nPattern>0) || g.argc<3){
20042006
/*
2005
- ** We have either globs or no trailing filenames (in which case an
2006
- ** effective glob pattern of '*' is assumed). If there are neither
2007
- ** globs nor filenames then we operate on all managed files.
2007
+ ** We have either (1) globs or (2) no trailing filenames. If there
2008
+ ** are neither globs nor filenames then we operate on all managed
2009
+ ** files.
20082010
*/
20092011
db_prepare(&q,
20102012
"SELECT vfile.mrid, pathname "
20112013
"FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid "
20122014
"WHERE vid=%d", vid);
@@ -2037,20 +2039,19 @@
20372039
** Trailing filenames on the command line. These require extra
20382040
** care to avoid modifying unmanaged or out-of-tree files and
20392041
** finding an associated --checkin timestamp.
20402042
*/
20412043
int i;
2042
- Blob treeNameBuf = empty_blob;
2044
+ Blob treeNameBuf = empty_blob; /* Buffer for file_tree_name(). */
20432045
for( i = 2; i < g.argc; ++i,
20442046
blob_reset(&treeNameBuf) ){
20452047
char const * zArg = g.argv[i];
20462048
char const * zTreeFile; /* repo-relative filename */
20472049
char const * zAbs; /* absolute filename */
20482050
i64 newMtime = nowTime;
20492051
int nameCheck;
20502052
int fid; /* vfile.mrid of file */
2051
- absBuffer.nUsed = 0;
20522053
nameCheck = file_tree_name( zArg, &treeNameBuf, 0, 0 );
20532054
if(nameCheck==0){
20542055
if(quietFlag==0){
20552056
fossil_print("SKIPPING out-of-tree file: %s\n", zArg);
20562057
}
@@ -2062,10 +2063,11 @@
20622063
if(quietFlag==0){
20632064
fossil_print("SKIPPING unmanaged file: %s\n", zArg);
20642065
}
20652066
continue;
20662067
}
2068
+ absBuffer.nUsed = 0;
20672069
blob_appendf(&absBuffer, "%s%s", g.zLocalRoot, zTreeFile);
20682070
zAbs = blob_str(&absBuffer);
20692071
if(timeFlag<0){/*--checkin*/
20702072
if(mtime_of_manifest_file( vid, fid, &newMtime )!=0){
20712073
fossil_fatal("Could not resolve --checkin mtime of %s", zTreeFile);
@@ -2081,8 +2083,9 @@
20812083
db_end_transaction(0);
20822084
blob_reset(&absBuffer);
20832085
if( dryRunFlag!=0 ){
20842086
fossil_print("dry-run: would have touched %d file(s)\n",
20852087
changeCount);
2088
+ }else{
2089
+ fossil_print("Touched %d file(s)\n", changeCount);
20862090
}
2087
- fossil_print("Touched %d file(s)\n", changeCount);
20882091
}
20892092
--- src/file.c
+++ src/file.c
@@ -1801,23 +1801,23 @@
1801 fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles));
1802 }
1803
1804 /*
1805 ** Internal helper for touch_cmd(). zAbsName must be resolvable as-is
1806 ** to a file - this function does not expand/normalize it. i.e. it
1807 ** "really should" be an absolute path. zTreeName is strictly
1808 ** cosmetic: it is used when dryRunFlag or verboseFlag generate
1809 ** output. It is assumed to be a repo-relative or or subdir-relative
1810 ** filename.
1811 **
1812 ** newMTime is the file's new timestamp (Unix epoch).
1813 **
1814 ** Returns 1 if it sets zAbsName's mtime, 0 if it does not (indicating
1815 ** that the file already has that timestamp). Dies fatally if given an
1816 ** unresolvable filename. If dryRunFlag is true then it outputs the
1817 ** name of the file it would have timestamped but does not stamp the
1818 ** file. If verboseFlag is true, it outputs a message if the files
1819 ** timestamp is actually modified.
1820 */
1821 static int touch_cmd_stamp_one_file(char const *zAbsName,
1822 char const *zTreeName,
1823 i64 newMtime, int dryRunFlag,
@@ -1837,20 +1837,23 @@
1837 }
1838 return 1;
1839 }
1840
1841 /*
1842 ** Internal helper for touch_cmd(). If the given name is found in the
1843 ** given checkout version, which MUST be the checkout version
1844 ** currently populating the vfile table, the vfile.mrid value for the
1845 ** file is returned, else 0 is returned. zName must be resolvable
1846 ** as-is - this function performs neither expands nor normalizes it.
 
 
1847 */
1848 static int touch_cmd_vfile_mrid( int vid, char const *zName ){
1849 int mrid = 0;
1850 static Stmt q = empty_Stmt_m;
1851 db_static_prepare(&q, "SELECT vfile.mrid "
 
1852 "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid "
1853 "WHERE vid=:vid AND pathname=:pathname %s",
1854 filename_collation());
1855 db_bind_int(&q, ":vid", vid);
1856 db_bind_text(&q, ":pathname", zName);
@@ -1917,11 +1920,11 @@
1917 int changeCount = 0; /* Number of files touched */
1918 int quietFlag = 0; /* -q|--quiet */
1919 int timeFlag; /* -1==--checkin, 1==--checkout, 0==--now */
1920 i64 nowTime = 0; /* Timestamp of --now or --checkout */
1921 Stmt q;
1922 Blob absBuffer = empty_blob;
1923
1924 verboseFlag = find_option("verbose","v",0)!=0;
1925 quietFlag = find_option("quiet","q",0)!=0;
1926 dryRunFlag = find_option("dry-run","n",0)!=0
1927 || find_option("dryrun",0,0)!=0;
@@ -1997,16 +2000,15 @@
1997 fossil_fatal("Could not determine out checkout version's time!");
1998 }
1999 }else{ /* --checkin */
2000 assert(0 == nowTime);
2001 }
2002 if((pGlob && pGlob->nPattern>0)
2003 || g.argc<3 /* no non-flag arguments */ ){
2004 /*
2005 ** We have either globs or no trailing filenames (in which case an
2006 ** effective glob pattern of '*' is assumed). If there are neither
2007 ** globs nor filenames then we operate on all managed files.
2008 */
2009 db_prepare(&q,
2010 "SELECT vfile.mrid, pathname "
2011 "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid "
2012 "WHERE vid=%d", vid);
@@ -2037,20 +2039,19 @@
2037 ** Trailing filenames on the command line. These require extra
2038 ** care to avoid modifying unmanaged or out-of-tree files and
2039 ** finding an associated --checkin timestamp.
2040 */
2041 int i;
2042 Blob treeNameBuf = empty_blob;
2043 for( i = 2; i < g.argc; ++i,
2044 blob_reset(&treeNameBuf) ){
2045 char const * zArg = g.argv[i];
2046 char const * zTreeFile; /* repo-relative filename */
2047 char const * zAbs; /* absolute filename */
2048 i64 newMtime = nowTime;
2049 int nameCheck;
2050 int fid; /* vfile.mrid of file */
2051 absBuffer.nUsed = 0;
2052 nameCheck = file_tree_name( zArg, &treeNameBuf, 0, 0 );
2053 if(nameCheck==0){
2054 if(quietFlag==0){
2055 fossil_print("SKIPPING out-of-tree file: %s\n", zArg);
2056 }
@@ -2062,10 +2063,11 @@
2062 if(quietFlag==0){
2063 fossil_print("SKIPPING unmanaged file: %s\n", zArg);
2064 }
2065 continue;
2066 }
 
2067 blob_appendf(&absBuffer, "%s%s", g.zLocalRoot, zTreeFile);
2068 zAbs = blob_str(&absBuffer);
2069 if(timeFlag<0){/*--checkin*/
2070 if(mtime_of_manifest_file( vid, fid, &newMtime )!=0){
2071 fossil_fatal("Could not resolve --checkin mtime of %s", zTreeFile);
@@ -2081,8 +2083,9 @@
2081 db_end_transaction(0);
2082 blob_reset(&absBuffer);
2083 if( dryRunFlag!=0 ){
2084 fossil_print("dry-run: would have touched %d file(s)\n",
2085 changeCount);
 
 
2086 }
2087 fossil_print("Touched %d file(s)\n", changeCount);
2088 }
2089
--- src/file.c
+++ src/file.c
@@ -1801,23 +1801,23 @@
1801 fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles));
1802 }
1803
1804 /*
1805 ** Internal helper for touch_cmd(). zAbsName must be resolvable as-is
1806 ** to an existing file - this function does not expand/normalize
1807 ** it. i.e. it "really should" be an absolute path. zTreeName is
1808 ** strictly cosmetic: it is used when dryRunFlag or verboseFlag
1809 ** generate output. It is assumed to be a repo-relative or or
1810 ** subdir-relative filename.
1811 **
1812 ** newMTime is the file's new timestamp (Unix epoch).
1813 **
1814 ** Returns 1 if it sets zAbsName's mtime, 0 if it does not (indicating
1815 ** that the file already has that timestamp). Dies fatally if given an
1816 ** unresolvable filename. If dryRunFlag is true then it outputs the
1817 ** name of the file it would have timestamped but does not stamp the
1818 ** file. If verboseFlag is true, it outputs a message if the file's
1819 ** timestamp is actually modified.
1820 */
1821 static int touch_cmd_stamp_one_file(char const *zAbsName,
1822 char const *zTreeName,
1823 i64 newMtime, int dryRunFlag,
@@ -1837,20 +1837,23 @@
1837 }
1838 return 1;
1839 }
1840
1841 /*
1842 ** Internal helper for touch_cmd(). If the given file name is found in
1843 ** the given checkout version, which MUST be the checkout version
1844 ** currently populating the vfile table, the vfile.mrid value for the
1845 ** file is returned, else 0 is returned. zName must be resolvable
1846 ** as-is from the vfile table - this function neither expands nor
1847 ** normalizes it, though it does compare using the repo's
1848 ** filename_collation() preference.
1849 */
1850 static int touch_cmd_vfile_mrid( int vid, char const *zName ){
1851 int mrid = 0;
1852 static Stmt q = empty_Stmt_m;
1853 db_static_prepare(&q,
1854 "SELECT vfile.mrid "
1855 "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid "
1856 "WHERE vid=:vid AND pathname=:pathname %s",
1857 filename_collation());
1858 db_bind_int(&q, ":vid", vid);
1859 db_bind_text(&q, ":pathname", zName);
@@ -1917,11 +1920,11 @@
1920 int changeCount = 0; /* Number of files touched */
1921 int quietFlag = 0; /* -q|--quiet */
1922 int timeFlag; /* -1==--checkin, 1==--checkout, 0==--now */
1923 i64 nowTime = 0; /* Timestamp of --now or --checkout */
1924 Stmt q;
1925 Blob absBuffer = empty_blob; /* Absolute filename buffer */
1926
1927 verboseFlag = find_option("verbose","v",0)!=0;
1928 quietFlag = find_option("quiet","q",0)!=0;
1929 dryRunFlag = find_option("dry-run","n",0)!=0
1930 || find_option("dryrun",0,0)!=0;
@@ -1997,16 +2000,15 @@
2000 fossil_fatal("Could not determine out checkout version's time!");
2001 }
2002 }else{ /* --checkin */
2003 assert(0 == nowTime);
2004 }
2005 if((pGlob && pGlob->nPattern>0) || g.argc<3){
 
2006 /*
2007 ** We have either (1) globs or (2) no trailing filenames. If there
2008 ** are neither globs nor filenames then we operate on all managed
2009 ** files.
2010 */
2011 db_prepare(&q,
2012 "SELECT vfile.mrid, pathname "
2013 "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid "
2014 "WHERE vid=%d", vid);
@@ -2037,20 +2039,19 @@
2039 ** Trailing filenames on the command line. These require extra
2040 ** care to avoid modifying unmanaged or out-of-tree files and
2041 ** finding an associated --checkin timestamp.
2042 */
2043 int i;
2044 Blob treeNameBuf = empty_blob; /* Buffer for file_tree_name(). */
2045 for( i = 2; i < g.argc; ++i,
2046 blob_reset(&treeNameBuf) ){
2047 char const * zArg = g.argv[i];
2048 char const * zTreeFile; /* repo-relative filename */
2049 char const * zAbs; /* absolute filename */
2050 i64 newMtime = nowTime;
2051 int nameCheck;
2052 int fid; /* vfile.mrid of file */
 
2053 nameCheck = file_tree_name( zArg, &treeNameBuf, 0, 0 );
2054 if(nameCheck==0){
2055 if(quietFlag==0){
2056 fossil_print("SKIPPING out-of-tree file: %s\n", zArg);
2057 }
@@ -2062,10 +2063,11 @@
2063 if(quietFlag==0){
2064 fossil_print("SKIPPING unmanaged file: %s\n", zArg);
2065 }
2066 continue;
2067 }
2068 absBuffer.nUsed = 0;
2069 blob_appendf(&absBuffer, "%s%s", g.zLocalRoot, zTreeFile);
2070 zAbs = blob_str(&absBuffer);
2071 if(timeFlag<0){/*--checkin*/
2072 if(mtime_of_manifest_file( vid, fid, &newMtime )!=0){
2073 fossil_fatal("Could not resolve --checkin mtime of %s", zTreeFile);
@@ -2081,8 +2083,9 @@
2083 db_end_transaction(0);
2084 blob_reset(&absBuffer);
2085 if( dryRunFlag!=0 ){
2086 fossil_print("dry-run: would have touched %d file(s)\n",
2087 changeCount);
2088 }else{
2089 fossil_print("Touched %d file(s)\n", changeCount);
2090 }
 
2091 }
2092

Keyboard Shortcuts

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