Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Added new 'touch' command to set the mtime of files to their SCM-side values. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | touch-command |
| Files: | files | file ages | folders |
| SHA3-256: |
4d9ec3e33c44ab59ff891051f1a3be28 |
| User & Date: | stephan 2019-06-13 08:04:20.604 |
Context
|
2019-06-13
| ||
| 08:13 | Help text typo. check-in: 85e3340b37 user: stephan tags: touch-command | |
| 08:04 | Added new 'touch' command to set the mtime of files to their SCM-side values. check-in: 4d9ec3e33c user: stephan tags: touch-command | |
| 06:15 | Documented the --setmtime flag to the update command. check-in: 34fcaf829a user: stephan tags: trunk | |
Changes
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
** comma-separated list of glob patterns, or all files if no glob is
** provided, set 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-control files.
** -G GLOBFILE Similar to -g but reads its globs from a
** fossil-conventional glob list file.
** -v|-verbose If true, outputs information about its globs
** and each file it touches.
** -n|--dry-run If given, 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);
}
}
|