Fossil SCM
Fix the computation of file-age so that it correctly detects file changes that occur on branches. Also: since file-age computation must now look at all branches instead of just the trunk, it is more expensive, so change the default "/tree" to be the flat-view.
Commit
7198da122dc9c080850defc86ac04afd21cddec6
Parent
046a5b12024b21b…
1 file changed
+20
-8
+20
-8
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -128,11 +128,11 @@ | ||
| 128 | 128 | const char *zSubdirLink; |
| 129 | 129 | int linkTrunk = 1; |
| 130 | 130 | int linkTip = 1; |
| 131 | 131 | HQuery sURI; |
| 132 | 132 | |
| 133 | - if( strcmp(PD("type",""),"tree")==0 ){ page_tree(); return; } | |
| 133 | + if( strcmp(PD("type","flat"),"tree")==0 ){ page_tree(); return; } | |
| 134 | 134 | login_check_credentials(); |
| 135 | 135 | if( !g.perm.Read ){ login_needed(); return; } |
| 136 | 136 | while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; } |
| 137 | 137 | style_header("File List"); |
| 138 | 138 | style_adunit_config(ADUNIT_RIGHT_OK); |
| @@ -540,11 +540,11 @@ | ||
| 540 | 540 | int startExpanded; /* True to start out with the tree expanded */ |
| 541 | 541 | int showDirOnly; /* Show directories only. Omit files */ |
| 542 | 542 | int nDir = 0; /* Number of directories. Used for ID attributes */ |
| 543 | 543 | char *zProjectName = db_get("project-name", 0); |
| 544 | 544 | |
| 545 | - if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; } | |
| 545 | + if( strcmp(PD("type","flat"),"flat")==0 ){ page_dir(); return; } | |
| 546 | 546 | memset(&sTree, 0, sizeof(sTree)); |
| 547 | 547 | login_check_credentials(); |
| 548 | 548 | if( !g.perm.Read ){ login_needed(); return; } |
| 549 | 549 | while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; } |
| 550 | 550 | sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, |
| @@ -897,20 +897,28 @@ | ||
| 897 | 897 | @ mid INTEGER, |
| 898 | 898 | @ mtime DATETIME, |
| 899 | 899 | @ pathname TEXT |
| 900 | 900 | @ ); |
| 901 | 901 | @ CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin; |
| 902 | +@ CREATE TEMP TABLE descendents(x INTEGER PRIMARY KEY); | |
| 902 | 903 | ; |
| 903 | 904 | |
| 904 | -static const char zComputeFileAgeRun[] = | |
| 905 | +static const char zComputeFileAgeRun1[] = | |
| 905 | 906 | @ WITH RECURSIVE |
| 906 | -@ ckin(x) AS (VALUES(:ckin) UNION ALL | |
| 907 | -@ SELECT pid FROM ckin, plink WHERE cid=x AND isprim) | |
| 907 | +@ ckin(x,m) AS (SELECT objid, mtime FROM event WHERE objid=:ckin | |
| 908 | +@ UNION | |
| 909 | +@ SELECT plink.pid, event.mtime | |
| 910 | +@ FROM ckin, plink, event | |
| 911 | +@ WHERE plink.cid=ckin.x AND event.objid=plink.pid | |
| 912 | +@ ORDER BY 2 DESC) | |
| 913 | +@ INSERT INTO descendents SELECT x FROM ckin; | |
| 914 | +; | |
| 915 | +static const char zComputeFileAgeRun2[] = | |
| 908 | 916 | @ INSERT OR IGNORE INTO fileage(fnid, fid, mid, mtime, pathname) |
| 909 | 917 | @ SELECT mlink.fnid, mlink.fid, x, event.mtime, filename.name |
| 910 | -@ FROM ckin, mlink, event, filename | |
| 911 | -@ WHERE mlink.mid=ckin.x | |
| 918 | +@ FROM descendents, mlink, event, filename | |
| 919 | +@ WHERE mlink.mid=descendents.x | |
| 912 | 920 | @ AND mlink.fnid IN (SELECT fnid FROM foci, filename |
| 913 | 921 | @ WHERE foci.checkinID=:ckin |
| 914 | 922 | @ AND filename.name=foci.filename |
| 915 | 923 | @ AND filename.name GLOB :glob) |
| 916 | 924 | @ AND filename.fnid=mlink.fnid |
| @@ -926,11 +934,15 @@ | ||
| 926 | 934 | ** the given glob are computed. |
| 927 | 935 | */ |
| 928 | 936 | int compute_fileage(int vid, const char* zGlob){ |
| 929 | 937 | Stmt q; |
| 930 | 938 | db_multi_exec(zComputeFileAgeSetup /*works-like:"constant"*/); |
| 931 | - db_prepare(&q, zComputeFileAgeRun /*works-like:"constant"*/); | |
| 939 | + db_prepare(&q, zComputeFileAgeRun1 /*works-like:"constant"*/); | |
| 940 | + db_bind_int(&q, ":ckin", vid); | |
| 941 | + db_exec(&q); | |
| 942 | + db_finalize(&q); | |
| 943 | + db_prepare(&q, zComputeFileAgeRun2 /*works-like:"constant"*/); | |
| 932 | 944 | db_bind_int(&q, ":ckin", vid); |
| 933 | 945 | db_bind_text(&q, ":glob", zGlob && zGlob[0] ? zGlob : "*"); |
| 934 | 946 | db_exec(&q); |
| 935 | 947 | db_finalize(&q); |
| 936 | 948 | return 0; |
| 937 | 949 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -128,11 +128,11 @@ | |
| 128 | const char *zSubdirLink; |
| 129 | int linkTrunk = 1; |
| 130 | int linkTip = 1; |
| 131 | HQuery sURI; |
| 132 | |
| 133 | if( strcmp(PD("type",""),"tree")==0 ){ page_tree(); return; } |
| 134 | login_check_credentials(); |
| 135 | if( !g.perm.Read ){ login_needed(); return; } |
| 136 | while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; } |
| 137 | style_header("File List"); |
| 138 | style_adunit_config(ADUNIT_RIGHT_OK); |
| @@ -540,11 +540,11 @@ | |
| 540 | int startExpanded; /* True to start out with the tree expanded */ |
| 541 | int showDirOnly; /* Show directories only. Omit files */ |
| 542 | int nDir = 0; /* Number of directories. Used for ID attributes */ |
| 543 | char *zProjectName = db_get("project-name", 0); |
| 544 | |
| 545 | if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; } |
| 546 | memset(&sTree, 0, sizeof(sTree)); |
| 547 | login_check_credentials(); |
| 548 | if( !g.perm.Read ){ login_needed(); return; } |
| 549 | while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; } |
| 550 | sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, |
| @@ -897,20 +897,28 @@ | |
| 897 | @ mid INTEGER, |
| 898 | @ mtime DATETIME, |
| 899 | @ pathname TEXT |
| 900 | @ ); |
| 901 | @ CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin; |
| 902 | ; |
| 903 | |
| 904 | static const char zComputeFileAgeRun[] = |
| 905 | @ WITH RECURSIVE |
| 906 | @ ckin(x) AS (VALUES(:ckin) UNION ALL |
| 907 | @ SELECT pid FROM ckin, plink WHERE cid=x AND isprim) |
| 908 | @ INSERT OR IGNORE INTO fileage(fnid, fid, mid, mtime, pathname) |
| 909 | @ SELECT mlink.fnid, mlink.fid, x, event.mtime, filename.name |
| 910 | @ FROM ckin, mlink, event, filename |
| 911 | @ WHERE mlink.mid=ckin.x |
| 912 | @ AND mlink.fnid IN (SELECT fnid FROM foci, filename |
| 913 | @ WHERE foci.checkinID=:ckin |
| 914 | @ AND filename.name=foci.filename |
| 915 | @ AND filename.name GLOB :glob) |
| 916 | @ AND filename.fnid=mlink.fnid |
| @@ -926,11 +934,15 @@ | |
| 926 | ** the given glob are computed. |
| 927 | */ |
| 928 | int compute_fileage(int vid, const char* zGlob){ |
| 929 | Stmt q; |
| 930 | db_multi_exec(zComputeFileAgeSetup /*works-like:"constant"*/); |
| 931 | db_prepare(&q, zComputeFileAgeRun /*works-like:"constant"*/); |
| 932 | db_bind_int(&q, ":ckin", vid); |
| 933 | db_bind_text(&q, ":glob", zGlob && zGlob[0] ? zGlob : "*"); |
| 934 | db_exec(&q); |
| 935 | db_finalize(&q); |
| 936 | return 0; |
| 937 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -128,11 +128,11 @@ | |
| 128 | const char *zSubdirLink; |
| 129 | int linkTrunk = 1; |
| 130 | int linkTip = 1; |
| 131 | HQuery sURI; |
| 132 | |
| 133 | if( strcmp(PD("type","flat"),"tree")==0 ){ page_tree(); return; } |
| 134 | login_check_credentials(); |
| 135 | if( !g.perm.Read ){ login_needed(); return; } |
| 136 | while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; } |
| 137 | style_header("File List"); |
| 138 | style_adunit_config(ADUNIT_RIGHT_OK); |
| @@ -540,11 +540,11 @@ | |
| 540 | int startExpanded; /* True to start out with the tree expanded */ |
| 541 | int showDirOnly; /* Show directories only. Omit files */ |
| 542 | int nDir = 0; /* Number of directories. Used for ID attributes */ |
| 543 | char *zProjectName = db_get("project-name", 0); |
| 544 | |
| 545 | if( strcmp(PD("type","flat"),"flat")==0 ){ page_dir(); return; } |
| 546 | memset(&sTree, 0, sizeof(sTree)); |
| 547 | login_check_credentials(); |
| 548 | if( !g.perm.Read ){ login_needed(); return; } |
| 549 | while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; } |
| 550 | sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, |
| @@ -897,20 +897,28 @@ | |
| 897 | @ mid INTEGER, |
| 898 | @ mtime DATETIME, |
| 899 | @ pathname TEXT |
| 900 | @ ); |
| 901 | @ CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin; |
| 902 | @ CREATE TEMP TABLE descendents(x INTEGER PRIMARY KEY); |
| 903 | ; |
| 904 | |
| 905 | static const char zComputeFileAgeRun1[] = |
| 906 | @ WITH RECURSIVE |
| 907 | @ ckin(x,m) AS (SELECT objid, mtime FROM event WHERE objid=:ckin |
| 908 | @ UNION |
| 909 | @ SELECT plink.pid, event.mtime |
| 910 | @ FROM ckin, plink, event |
| 911 | @ WHERE plink.cid=ckin.x AND event.objid=plink.pid |
| 912 | @ ORDER BY 2 DESC) |
| 913 | @ INSERT INTO descendents SELECT x FROM ckin; |
| 914 | ; |
| 915 | static const char zComputeFileAgeRun2[] = |
| 916 | @ INSERT OR IGNORE INTO fileage(fnid, fid, mid, mtime, pathname) |
| 917 | @ SELECT mlink.fnid, mlink.fid, x, event.mtime, filename.name |
| 918 | @ FROM descendents, mlink, event, filename |
| 919 | @ WHERE mlink.mid=descendents.x |
| 920 | @ AND mlink.fnid IN (SELECT fnid FROM foci, filename |
| 921 | @ WHERE foci.checkinID=:ckin |
| 922 | @ AND filename.name=foci.filename |
| 923 | @ AND filename.name GLOB :glob) |
| 924 | @ AND filename.fnid=mlink.fnid |
| @@ -926,11 +934,15 @@ | |
| 934 | ** the given glob are computed. |
| 935 | */ |
| 936 | int compute_fileage(int vid, const char* zGlob){ |
| 937 | Stmt q; |
| 938 | db_multi_exec(zComputeFileAgeSetup /*works-like:"constant"*/); |
| 939 | db_prepare(&q, zComputeFileAgeRun1 /*works-like:"constant"*/); |
| 940 | db_bind_int(&q, ":ckin", vid); |
| 941 | db_exec(&q); |
| 942 | db_finalize(&q); |
| 943 | db_prepare(&q, zComputeFileAgeRun2 /*works-like:"constant"*/); |
| 944 | db_bind_int(&q, ":ckin", vid); |
| 945 | db_bind_text(&q, ":glob", zGlob && zGlob[0] ? zGlob : "*"); |
| 946 | db_exec(&q); |
| 947 | db_finalize(&q); |
| 948 | return 0; |
| 949 |