Fossil SCM
added glob=pattern option to /fileage, per ML request.
Commit
b26e9c87995b7b7f63da1486f9d207af44a85258
Parent
9dca00425e954ab…
1 file changed
+11
-5
+11
-5
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -732,13 +732,14 @@ | ||
| 732 | 732 | |
| 733 | 733 | /* |
| 734 | 734 | ** Look at all file containing in the version "vid". Construct a |
| 735 | 735 | ** temporary table named "fileage" that contains the file-id for each |
| 736 | 736 | ** files, the pathname, the check-in where the file was added, and the |
| 737 | -** mtime on that checkin. | |
| 737 | +** mtime on that checkin. If zGlob is not NULL then only files | |
| 738 | +** matching the given glob are computed. | |
| 738 | 739 | */ |
| 739 | -int compute_fileage(int vid){ | |
| 740 | +int compute_fileage(int vid, char const * zGlob){ | |
| 740 | 741 | Manifest *pManifest; |
| 741 | 742 | ManifestFile *pFile; |
| 742 | 743 | int nFile = 0; |
| 743 | 744 | double vmtime; |
| 744 | 745 | Stmt ins; |
| @@ -760,10 +761,11 @@ | ||
| 760 | 761 | db_prepare(&ins, |
| 761 | 762 | "INSERT INTO temp.fileage(fid, pathname)" |
| 762 | 763 | " SELECT rid, :path FROM blob WHERE uuid=:uuid" |
| 763 | 764 | ); |
| 764 | 765 | while( (pFile = manifest_file_next(pManifest, 0))!=0 ){ |
| 766 | + if(zGlob && !strglob(zGlob, pFile->zName)) continue; | |
| 765 | 767 | db_bind_text(&ins, ":uuid", pFile->zUuid); |
| 766 | 768 | db_bind_text(&ins, ":path", pFile->zName); |
| 767 | 769 | db_step(&ins); |
| 768 | 770 | db_reset(&ins); |
| 769 | 771 | nFile++; |
| @@ -807,20 +809,22 @@ | ||
| 807 | 809 | |
| 808 | 810 | /* |
| 809 | 811 | ** WEBPAGE: fileage |
| 810 | 812 | ** |
| 811 | 813 | ** Parameters: |
| 812 | -** name=VERSION | |
| 814 | +** name=VERSION Selects the checkin version (default=tip). | |
| 815 | +** glob=STRING Only shows files matching this glob pattern | |
| 816 | +** (e.g. *.c or *.txt). | |
| 813 | 817 | */ |
| 814 | 818 | void fileage_page(void){ |
| 815 | 819 | int rid; |
| 816 | 820 | const char *zName; |
| 817 | 821 | char *zBaseTime; |
| 822 | + char const * zGlob; | |
| 818 | 823 | Stmt q; |
| 819 | 824 | double baseTime; |
| 820 | 825 | int lastMid = -1; |
| 821 | - | |
| 822 | 826 | login_check_credentials(); |
| 823 | 827 | if( !g.perm.Read ){ login_needed(); return; } |
| 824 | 828 | zName = P("name"); |
| 825 | 829 | if( zName==0 ) zName = "tip"; |
| 826 | 830 | rid = symbolic_name_to_rid(zName, "ci"); |
| @@ -827,11 +831,13 @@ | ||
| 827 | 831 | if( rid==0 ){ |
| 828 | 832 | fossil_fatal("not a valid check-in: %s", zName); |
| 829 | 833 | } |
| 830 | 834 | style_submenu_element("Tree-View", "Tree-View", "%R/tree?ci=%T", zName); |
| 831 | 835 | style_header("File Ages", zName); |
| 832 | - compute_fileage(rid); | |
| 836 | + zGlob = P("glob"); | |
| 837 | + if(zGlob && !*zGlob) zGlob = NULL; | |
| 838 | + compute_fileage(rid,zGlob); | |
| 833 | 839 | baseTime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid); |
| 834 | 840 | zBaseTime = db_text("","SELECT datetime(%.20g%s)", baseTime, timeline_utc()); |
| 835 | 841 | @ <h2>File Ages For Check-in |
| 836 | 842 | @ %z(href("%R/info?name=%T",zName))%h(zName)</a></h2> |
| 837 | 843 | @ |
| 838 | 844 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -732,13 +732,14 @@ | |
| 732 | |
| 733 | /* |
| 734 | ** Look at all file containing in the version "vid". Construct a |
| 735 | ** temporary table named "fileage" that contains the file-id for each |
| 736 | ** files, the pathname, the check-in where the file was added, and the |
| 737 | ** mtime on that checkin. |
| 738 | */ |
| 739 | int compute_fileage(int vid){ |
| 740 | Manifest *pManifest; |
| 741 | ManifestFile *pFile; |
| 742 | int nFile = 0; |
| 743 | double vmtime; |
| 744 | Stmt ins; |
| @@ -760,10 +761,11 @@ | |
| 760 | db_prepare(&ins, |
| 761 | "INSERT INTO temp.fileage(fid, pathname)" |
| 762 | " SELECT rid, :path FROM blob WHERE uuid=:uuid" |
| 763 | ); |
| 764 | while( (pFile = manifest_file_next(pManifest, 0))!=0 ){ |
| 765 | db_bind_text(&ins, ":uuid", pFile->zUuid); |
| 766 | db_bind_text(&ins, ":path", pFile->zName); |
| 767 | db_step(&ins); |
| 768 | db_reset(&ins); |
| 769 | nFile++; |
| @@ -807,20 +809,22 @@ | |
| 807 | |
| 808 | /* |
| 809 | ** WEBPAGE: fileage |
| 810 | ** |
| 811 | ** Parameters: |
| 812 | ** name=VERSION |
| 813 | */ |
| 814 | void fileage_page(void){ |
| 815 | int rid; |
| 816 | const char *zName; |
| 817 | char *zBaseTime; |
| 818 | Stmt q; |
| 819 | double baseTime; |
| 820 | int lastMid = -1; |
| 821 | |
| 822 | login_check_credentials(); |
| 823 | if( !g.perm.Read ){ login_needed(); return; } |
| 824 | zName = P("name"); |
| 825 | if( zName==0 ) zName = "tip"; |
| 826 | rid = symbolic_name_to_rid(zName, "ci"); |
| @@ -827,11 +831,13 @@ | |
| 827 | if( rid==0 ){ |
| 828 | fossil_fatal("not a valid check-in: %s", zName); |
| 829 | } |
| 830 | style_submenu_element("Tree-View", "Tree-View", "%R/tree?ci=%T", zName); |
| 831 | style_header("File Ages", zName); |
| 832 | compute_fileage(rid); |
| 833 | baseTime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid); |
| 834 | zBaseTime = db_text("","SELECT datetime(%.20g%s)", baseTime, timeline_utc()); |
| 835 | @ <h2>File Ages For Check-in |
| 836 | @ %z(href("%R/info?name=%T",zName))%h(zName)</a></h2> |
| 837 | @ |
| 838 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -732,13 +732,14 @@ | |
| 732 | |
| 733 | /* |
| 734 | ** Look at all file containing in the version "vid". Construct a |
| 735 | ** temporary table named "fileage" that contains the file-id for each |
| 736 | ** files, the pathname, the check-in where the file was added, and the |
| 737 | ** mtime on that checkin. If zGlob is not NULL then only files |
| 738 | ** matching the given glob are computed. |
| 739 | */ |
| 740 | int compute_fileage(int vid, char const * zGlob){ |
| 741 | Manifest *pManifest; |
| 742 | ManifestFile *pFile; |
| 743 | int nFile = 0; |
| 744 | double vmtime; |
| 745 | Stmt ins; |
| @@ -760,10 +761,11 @@ | |
| 761 | db_prepare(&ins, |
| 762 | "INSERT INTO temp.fileage(fid, pathname)" |
| 763 | " SELECT rid, :path FROM blob WHERE uuid=:uuid" |
| 764 | ); |
| 765 | while( (pFile = manifest_file_next(pManifest, 0))!=0 ){ |
| 766 | if(zGlob && !strglob(zGlob, pFile->zName)) continue; |
| 767 | db_bind_text(&ins, ":uuid", pFile->zUuid); |
| 768 | db_bind_text(&ins, ":path", pFile->zName); |
| 769 | db_step(&ins); |
| 770 | db_reset(&ins); |
| 771 | nFile++; |
| @@ -807,20 +809,22 @@ | |
| 809 | |
| 810 | /* |
| 811 | ** WEBPAGE: fileage |
| 812 | ** |
| 813 | ** Parameters: |
| 814 | ** name=VERSION Selects the checkin version (default=tip). |
| 815 | ** glob=STRING Only shows files matching this glob pattern |
| 816 | ** (e.g. *.c or *.txt). |
| 817 | */ |
| 818 | void fileage_page(void){ |
| 819 | int rid; |
| 820 | const char *zName; |
| 821 | char *zBaseTime; |
| 822 | char const * zGlob; |
| 823 | Stmt q; |
| 824 | double baseTime; |
| 825 | int lastMid = -1; |
| 826 | login_check_credentials(); |
| 827 | if( !g.perm.Read ){ login_needed(); return; } |
| 828 | zName = P("name"); |
| 829 | if( zName==0 ) zName = "tip"; |
| 830 | rid = symbolic_name_to_rid(zName, "ci"); |
| @@ -827,11 +831,13 @@ | |
| 831 | if( rid==0 ){ |
| 832 | fossil_fatal("not a valid check-in: %s", zName); |
| 833 | } |
| 834 | style_submenu_element("Tree-View", "Tree-View", "%R/tree?ci=%T", zName); |
| 835 | style_header("File Ages", zName); |
| 836 | zGlob = P("glob"); |
| 837 | if(zGlob && !*zGlob) zGlob = NULL; |
| 838 | compute_fileage(rid,zGlob); |
| 839 | baseTime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid); |
| 840 | zBaseTime = db_text("","SELECT datetime(%.20g%s)", baseTime, timeline_utc()); |
| 841 | @ <h2>File Ages For Check-in |
| 842 | @ %z(href("%R/info?name=%T",zName))%h(zName)</a></h2> |
| 843 | @ |
| 844 |