Fossil SCM

On the header for a /timeline that uses the new to2= query parameter, use the value of either the to= or the to2= query parameter, whichever is valid.

drh 2024-03-11 19:20 trunk
Commit 452f050241b94485b74d1b1f3c992e648b028383c65ccfe92b45ce3a7c77929a
2 files changed +9 -2 +3 -2
+9 -2
--- src/name.c
+++ src/name.c
@@ -826,25 +826,32 @@
826826
** Try to resolve zQP1 into a check-in name. If zQP1 does not exist,
827827
** return 0. If zQP1 exists but cannot be resolved, then also try to
828828
** resolve zQP2 if it exists. If zQP1 cannot be resolved but zQP2 does
829829
** not exist, then raise an error. If both zQP1 and zQP2 exists but
830830
** neither can be resolved, also raise an error.
831
+**
832
+** If pzPick is not a NULL pointer, then *pzPick to be the value of whichever
833
+** query parameter ended up being used.
831834
*/
832
-int name_choice(const char *zQP1, const char *zQP2){
835
+int name_choice(const char *zQP1, const char *zQP2, const char **pzPick){
833836
const char *zName, *zName2;
834837
int rid;
835838
zName = P(zQP1);
836839
if( zName==0 || zName[0]==0 ) return 0;
837840
rid = symbolic_name_to_rid(zName, "ci");
838
- if( rid>0 ) return rid;
841
+ if( rid>0 ){
842
+ if( pzPick ) *pzPick = zName;
843
+ return rid;
844
+ }
839845
if( rid<0 ){
840846
fossil_fatal("ambiguous name: %s", zName);
841847
}
842848
zName2 = P(zQP2);
843849
if( zName2==0 || zName2[0]==0 ){
844850
fossil_fatal("cannot resolve name: %s", zName);
845851
}
852
+ if( pzPick ) *pzPick = zName2;
846853
return name_to_typed_rid(zName2, "ci");
847854
}
848855
849856
/*
850857
** WEBPAGE: ambiguous
851858
--- src/name.c
+++ src/name.c
@@ -826,25 +826,32 @@
826 ** Try to resolve zQP1 into a check-in name. If zQP1 does not exist,
827 ** return 0. If zQP1 exists but cannot be resolved, then also try to
828 ** resolve zQP2 if it exists. If zQP1 cannot be resolved but zQP2 does
829 ** not exist, then raise an error. If both zQP1 and zQP2 exists but
830 ** neither can be resolved, also raise an error.
 
 
 
831 */
832 int name_choice(const char *zQP1, const char *zQP2){
833 const char *zName, *zName2;
834 int rid;
835 zName = P(zQP1);
836 if( zName==0 || zName[0]==0 ) return 0;
837 rid = symbolic_name_to_rid(zName, "ci");
838 if( rid>0 ) return rid;
 
 
 
839 if( rid<0 ){
840 fossil_fatal("ambiguous name: %s", zName);
841 }
842 zName2 = P(zQP2);
843 if( zName2==0 || zName2[0]==0 ){
844 fossil_fatal("cannot resolve name: %s", zName);
845 }
 
846 return name_to_typed_rid(zName2, "ci");
847 }
848
849 /*
850 ** WEBPAGE: ambiguous
851
--- src/name.c
+++ src/name.c
@@ -826,25 +826,32 @@
826 ** Try to resolve zQP1 into a check-in name. If zQP1 does not exist,
827 ** return 0. If zQP1 exists but cannot be resolved, then also try to
828 ** resolve zQP2 if it exists. If zQP1 cannot be resolved but zQP2 does
829 ** not exist, then raise an error. If both zQP1 and zQP2 exists but
830 ** neither can be resolved, also raise an error.
831 **
832 ** If pzPick is not a NULL pointer, then *pzPick to be the value of whichever
833 ** query parameter ended up being used.
834 */
835 int name_choice(const char *zQP1, const char *zQP2, const char **pzPick){
836 const char *zName, *zName2;
837 int rid;
838 zName = P(zQP1);
839 if( zName==0 || zName[0]==0 ) return 0;
840 rid = symbolic_name_to_rid(zName, "ci");
841 if( rid>0 ){
842 if( pzPick ) *pzPick = zName;
843 return rid;
844 }
845 if( rid<0 ){
846 fossil_fatal("ambiguous name: %s", zName);
847 }
848 zName2 = P(zQP2);
849 if( zName2==0 || zName2[0]==0 ){
850 fossil_fatal("cannot resolve name: %s", zName);
851 }
852 if( pzPick ) *pzPick = zName2;
853 return name_to_typed_rid(zName2, "ci");
854 }
855
856 /*
857 ** WEBPAGE: ambiguous
858
+3 -2
--- src/timeline.c
+++ src/timeline.c
@@ -1838,11 +1838,12 @@
18381838
int tmFlags = 0; /* Timeline flags */
18391839
const char *zThisTag = 0; /* Suppress links to this tag */
18401840
const char *zThisUser = 0; /* Suppress links to this user */
18411841
HQuery url; /* URL for various branch links */
18421842
int from_rid = name_to_typed_rid(P("from"),"ci"); /* from= for paths */
1843
- int to_rid = name_choice("to","to2"); /* to= for path timelines */
1843
+ const char *zTo2 = 0;
1844
+ int to_rid = name_choice("to","to2",&zTo2); /* to= for path timelines */
18441845
int noMerge = P("shortest")==0; /* Follow merge links if shorter */
18451846
int me_rid = name_to_typed_rid(P("me"),"ci"); /* me= for common ancestory */
18461847
int you_rid = name_to_typed_rid(P("you"),"ci");/* you= for common ancst */
18471848
int pd_rid;
18481849
double rBefore, rAfter, rCirca; /* Boundary times */
@@ -2212,11 +2213,11 @@
22122213
p = path_shortest(from_rid, to_rid, 0, 1, 0);
22132214
}else{
22142215
p = path_shortest(to_rid, from_rid, 0, 1, 0);
22152216
}
22162217
zFrom = P("from");
2217
- zTo = P("to");
2218
+ zTo = zTo2 ? zTo2 : P("to");
22182219
}else{
22192220
if( path_common_ancestor(me_rid, you_rid) ){
22202221
p = path_first();
22212222
}
22222223
zFrom = P("me");
22232224
--- src/timeline.c
+++ src/timeline.c
@@ -1838,11 +1838,12 @@
1838 int tmFlags = 0; /* Timeline flags */
1839 const char *zThisTag = 0; /* Suppress links to this tag */
1840 const char *zThisUser = 0; /* Suppress links to this user */
1841 HQuery url; /* URL for various branch links */
1842 int from_rid = name_to_typed_rid(P("from"),"ci"); /* from= for paths */
1843 int to_rid = name_choice("to","to2"); /* to= for path timelines */
 
1844 int noMerge = P("shortest")==0; /* Follow merge links if shorter */
1845 int me_rid = name_to_typed_rid(P("me"),"ci"); /* me= for common ancestory */
1846 int you_rid = name_to_typed_rid(P("you"),"ci");/* you= for common ancst */
1847 int pd_rid;
1848 double rBefore, rAfter, rCirca; /* Boundary times */
@@ -2212,11 +2213,11 @@
2212 p = path_shortest(from_rid, to_rid, 0, 1, 0);
2213 }else{
2214 p = path_shortest(to_rid, from_rid, 0, 1, 0);
2215 }
2216 zFrom = P("from");
2217 zTo = P("to");
2218 }else{
2219 if( path_common_ancestor(me_rid, you_rid) ){
2220 p = path_first();
2221 }
2222 zFrom = P("me");
2223
--- src/timeline.c
+++ src/timeline.c
@@ -1838,11 +1838,12 @@
1838 int tmFlags = 0; /* Timeline flags */
1839 const char *zThisTag = 0; /* Suppress links to this tag */
1840 const char *zThisUser = 0; /* Suppress links to this user */
1841 HQuery url; /* URL for various branch links */
1842 int from_rid = name_to_typed_rid(P("from"),"ci"); /* from= for paths */
1843 const char *zTo2 = 0;
1844 int to_rid = name_choice("to","to2",&zTo2); /* to= for path timelines */
1845 int noMerge = P("shortest")==0; /* Follow merge links if shorter */
1846 int me_rid = name_to_typed_rid(P("me"),"ci"); /* me= for common ancestory */
1847 int you_rid = name_to_typed_rid(P("you"),"ci");/* you= for common ancst */
1848 int pd_rid;
1849 double rBefore, rAfter, rCirca; /* Boundary times */
@@ -2212,11 +2213,11 @@
2213 p = path_shortest(from_rid, to_rid, 0, 1, 0);
2214 }else{
2215 p = path_shortest(to_rid, from_rid, 0, 1, 0);
2216 }
2217 zFrom = P("from");
2218 zTo = zTo2 ? zTo2 : P("to");
2219 }else{
2220 if( path_common_ancestor(me_rid, you_rid) ){
2221 p = path_first();
2222 }
2223 zFrom = P("me");
2224

Keyboard Shortcuts

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