Fossil SCM
Modify the /doc webpage so that if the first term of the argument is "latest" it chooses the most recent check-in for the document regardless of what branch that check-in occurred on.
Commit
d08bc9e61f3abf2d928f53c8da36efa9c85ba33affc337004054a7a17ac96506
Parent
9dcb3de471d35e7…
1 file changed
+13
+13
| --- src/doc.c | ||
| +++ src/doc.c | ||
| @@ -674,10 +674,13 @@ | ||
| 674 | 674 | ** |
| 675 | 675 | ** "tip" means the most recent check-in |
| 676 | 676 | ** |
| 677 | 677 | ** "ckout" means the current check-out, if the server is run from |
| 678 | 678 | ** within a check-out, otherwise it is the same as "tip" |
| 679 | +** | |
| 680 | +** "latest" means use the most recent check-in for the document | |
| 681 | +** regardless of what branch it occurs on. | |
| 679 | 682 | ** |
| 680 | 683 | ** FILE is the name of a file to delivered up as a webpage. FILE is relative |
| 681 | 684 | ** to the root of the source tree of the repository. The FILE must |
| 682 | 685 | ** be a part of CHECKIN, except when CHECKIN=="ckout" when FILE is read |
| 683 | 686 | ** directly from disk and need not be a managed file. |
| @@ -744,10 +747,20 @@ | ||
| 744 | 747 | if( zName==0 || zName[0]==0 ) zName = "tip/index.wiki"; |
| 745 | 748 | for(i=0; zName[i] && zName[i]!='/'; i++){} |
| 746 | 749 | zCheckin = mprintf("%.*s", i, zName); |
| 747 | 750 | if( fossil_strcmp(zCheckin,"ckout")==0 && g.localOpen==0 ){ |
| 748 | 751 | zCheckin = "tip"; |
| 752 | + }else if( fossil_strcmp(zCheckin,"latest")==0 ){ | |
| 753 | + char *zNewCkin = db_text(0, | |
| 754 | + "SELECT uuid FROM blob, mlink, event, filename" | |
| 755 | + " WHERE filename.name=%Q" | |
| 756 | + " AND mlink.fnid=filename.fnid" | |
| 757 | + " AND blob.rid=mlink.mid" | |
| 758 | + " AND event.objid=mlink.mid" | |
| 759 | + " ORDER BY event.mtime DESC LIMIT 1", | |
| 760 | + zName + i + 1); | |
| 761 | + if( zNewCkin ) zCheckin = zNewCkin; | |
| 749 | 762 | } |
| 750 | 763 | } |
| 751 | 764 | if( nMiss==count(azSuffix) ){ |
| 752 | 765 | zName = "404.md"; |
| 753 | 766 | zDfltTitle = "Not Found"; |
| 754 | 767 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -674,10 +674,13 @@ | |
| 674 | ** |
| 675 | ** "tip" means the most recent check-in |
| 676 | ** |
| 677 | ** "ckout" means the current check-out, if the server is run from |
| 678 | ** within a check-out, otherwise it is the same as "tip" |
| 679 | ** |
| 680 | ** FILE is the name of a file to delivered up as a webpage. FILE is relative |
| 681 | ** to the root of the source tree of the repository. The FILE must |
| 682 | ** be a part of CHECKIN, except when CHECKIN=="ckout" when FILE is read |
| 683 | ** directly from disk and need not be a managed file. |
| @@ -744,10 +747,20 @@ | |
| 744 | if( zName==0 || zName[0]==0 ) zName = "tip/index.wiki"; |
| 745 | for(i=0; zName[i] && zName[i]!='/'; i++){} |
| 746 | zCheckin = mprintf("%.*s", i, zName); |
| 747 | if( fossil_strcmp(zCheckin,"ckout")==0 && g.localOpen==0 ){ |
| 748 | zCheckin = "tip"; |
| 749 | } |
| 750 | } |
| 751 | if( nMiss==count(azSuffix) ){ |
| 752 | zName = "404.md"; |
| 753 | zDfltTitle = "Not Found"; |
| 754 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -674,10 +674,13 @@ | |
| 674 | ** |
| 675 | ** "tip" means the most recent check-in |
| 676 | ** |
| 677 | ** "ckout" means the current check-out, if the server is run from |
| 678 | ** within a check-out, otherwise it is the same as "tip" |
| 679 | ** |
| 680 | ** "latest" means use the most recent check-in for the document |
| 681 | ** regardless of what branch it occurs on. |
| 682 | ** |
| 683 | ** FILE is the name of a file to delivered up as a webpage. FILE is relative |
| 684 | ** to the root of the source tree of the repository. The FILE must |
| 685 | ** be a part of CHECKIN, except when CHECKIN=="ckout" when FILE is read |
| 686 | ** directly from disk and need not be a managed file. |
| @@ -744,10 +747,20 @@ | |
| 747 | if( zName==0 || zName[0]==0 ) zName = "tip/index.wiki"; |
| 748 | for(i=0; zName[i] && zName[i]!='/'; i++){} |
| 749 | zCheckin = mprintf("%.*s", i, zName); |
| 750 | if( fossil_strcmp(zCheckin,"ckout")==0 && g.localOpen==0 ){ |
| 751 | zCheckin = "tip"; |
| 752 | }else if( fossil_strcmp(zCheckin,"latest")==0 ){ |
| 753 | char *zNewCkin = db_text(0, |
| 754 | "SELECT uuid FROM blob, mlink, event, filename" |
| 755 | " WHERE filename.name=%Q" |
| 756 | " AND mlink.fnid=filename.fnid" |
| 757 | " AND blob.rid=mlink.mid" |
| 758 | " AND event.objid=mlink.mid" |
| 759 | " ORDER BY event.mtime DESC LIMIT 1", |
| 760 | zName + i + 1); |
| 761 | if( zNewCkin ) zCheckin = zNewCkin; |
| 762 | } |
| 763 | } |
| 764 | if( nMiss==count(azSuffix) ){ |
| 765 | zName = "404.md"; |
| 766 | zDfltTitle = "Not Found"; |
| 767 |