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.

drh 2020-01-09 15:29 trunk
Commit d08bc9e61f3abf2d928f53c8da36efa9c85ba33affc337004054a7a17ac96506
1 file changed +13
+13
--- src/doc.c
+++ src/doc.c
@@ -674,10 +674,13 @@
674674
**
675675
** "tip" means the most recent check-in
676676
**
677677
** "ckout" means the current check-out, if the server is run from
678678
** 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.
679682
**
680683
** FILE is the name of a file to delivered up as a webpage. FILE is relative
681684
** to the root of the source tree of the repository. The FILE must
682685
** be a part of CHECKIN, except when CHECKIN=="ckout" when FILE is read
683686
** directly from disk and need not be a managed file.
@@ -744,10 +747,20 @@
744747
if( zName==0 || zName[0]==0 ) zName = "tip/index.wiki";
745748
for(i=0; zName[i] && zName[i]!='/'; i++){}
746749
zCheckin = mprintf("%.*s", i, zName);
747750
if( fossil_strcmp(zCheckin,"ckout")==0 && g.localOpen==0 ){
748751
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;
749762
}
750763
}
751764
if( nMiss==count(azSuffix) ){
752765
zName = "404.md";
753766
zDfltTitle = "Not Found";
754767
--- 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

Keyboard Shortcuts

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