Fossil SCM

Fix the "min" and "shortest" query parameters so that they operate independently of one another.

drh 2025-03-09 10:20 min-from-to
Commit 93269c9f8909c62c8466e3ca51f547f7b9af53dbd7bc1f76cac70ac3d93f5036
2 files changed +12 +3 -3
+12
--- src/path.c
+++ src/path.c
@@ -271,10 +271,22 @@
271271
PathNode *p;
272272
p = path.pStart;
273273
if( p ) p = p->u.pTo;
274274
return p;
275275
}
276
+
277
+/*
278
+** Return the branch for a path node.
279
+**
280
+** Storage space is managed by the path subsystem. The returned value
281
+** is valid until the path is reset.
282
+*/
283
+const char *path_branch(PathNode *p){
284
+ if( p==0 ) return 0;
285
+ if( p->zBranch==0 ) p->zBranch = branch_of_rid(p->rid);
286
+ return p->zBranch;
287
+}
276288
277289
/*
278290
** Return an estimate of the number of comparisons remaining in order
279291
** to bisect path. This is based on the log2() of path.nStep.
280292
*/
281293
--- src/path.c
+++ src/path.c
@@ -271,10 +271,22 @@
271 PathNode *p;
272 p = path.pStart;
273 if( p ) p = p->u.pTo;
274 return p;
275 }
 
 
 
 
 
 
 
 
 
 
 
 
276
277 /*
278 ** Return an estimate of the number of comparisons remaining in order
279 ** to bisect path. This is based on the log2() of path.nStep.
280 */
281
--- src/path.c
+++ src/path.c
@@ -271,10 +271,22 @@
271 PathNode *p;
272 p = path.pStart;
273 if( p ) p = p->u.pTo;
274 return p;
275 }
276
277 /*
278 ** Return the branch for a path node.
279 **
280 ** Storage space is managed by the path subsystem. The returned value
281 ** is valid until the path is reset.
282 */
283 const char *path_branch(PathNode *p){
284 if( p==0 ) return 0;
285 if( p->zBranch==0 ) p->zBranch = branch_of_rid(p->rid);
286 return p->zBranch;
287 }
288
289 /*
290 ** Return an estimate of the number of comparisons remaining in order
291 ** to bisect path. This is based on the log2() of path.nStep.
292 */
293
+3 -3
--- src/timeline.c
+++ src/timeline.c
@@ -2074,11 +2074,11 @@
20742074
const char *zTo = 0;
20752075
Blob ins;
20762076
int nNodeOnPath = 0;
20772077
int commonAncs = 0; /* Common ancestors of me_rid and you_rid. */
20782078
int earlierRid = 0, laterRid = 0;
2079
- int cost = bMin || !bShort ? 1 : 0;
2079
+ int cost = bShort ? 0 : 1;
20802080
20812081
if( from_rid && to_rid ){
20822082
if( from_to_mode==0 ){
20832083
p = path_shortest(from_rid, to_rid, 0, 0, 0, cost);
20842084
}else if( from_to_mode==1 ){
@@ -2119,12 +2119,12 @@
21192119
blob_append_sql(&ins, "INSERT INTO pathnode(x) VALUES(%d)", p->rid);
21202120
if( p->u.pTo==0 ) bMin = 0;
21212121
for(p=p->u.pTo; p; p=p->u.pTo){
21222122
if( bMin
21232123
&& p->u.pTo!=0
2124
- && fossil_strcmp(p->pFrom->zBranch,p->zBranch)==0
2125
- && fossil_strcmp(p->zBranch,p->u.pTo->zBranch)==0
2124
+ && fossil_strcmp(path_branch(p->pFrom),path_branch(p))==0
2125
+ && fossil_strcmp(path_branch(p),path_branch(p->u.pTo))==0
21262126
){
21272127
continue;
21282128
}
21292129
if( cnt==8 ){
21302130
blob_append_sql(&ins, ",\n (%d)", p->rid);
21312131
--- src/timeline.c
+++ src/timeline.c
@@ -2074,11 +2074,11 @@
2074 const char *zTo = 0;
2075 Blob ins;
2076 int nNodeOnPath = 0;
2077 int commonAncs = 0; /* Common ancestors of me_rid and you_rid. */
2078 int earlierRid = 0, laterRid = 0;
2079 int cost = bMin || !bShort ? 1 : 0;
2080
2081 if( from_rid && to_rid ){
2082 if( from_to_mode==0 ){
2083 p = path_shortest(from_rid, to_rid, 0, 0, 0, cost);
2084 }else if( from_to_mode==1 ){
@@ -2119,12 +2119,12 @@
2119 blob_append_sql(&ins, "INSERT INTO pathnode(x) VALUES(%d)", p->rid);
2120 if( p->u.pTo==0 ) bMin = 0;
2121 for(p=p->u.pTo; p; p=p->u.pTo){
2122 if( bMin
2123 && p->u.pTo!=0
2124 && fossil_strcmp(p->pFrom->zBranch,p->zBranch)==0
2125 && fossil_strcmp(p->zBranch,p->u.pTo->zBranch)==0
2126 ){
2127 continue;
2128 }
2129 if( cnt==8 ){
2130 blob_append_sql(&ins, ",\n (%d)", p->rid);
2131
--- src/timeline.c
+++ src/timeline.c
@@ -2074,11 +2074,11 @@
2074 const char *zTo = 0;
2075 Blob ins;
2076 int nNodeOnPath = 0;
2077 int commonAncs = 0; /* Common ancestors of me_rid and you_rid. */
2078 int earlierRid = 0, laterRid = 0;
2079 int cost = bShort ? 0 : 1;
2080
2081 if( from_rid && to_rid ){
2082 if( from_to_mode==0 ){
2083 p = path_shortest(from_rid, to_rid, 0, 0, 0, cost);
2084 }else if( from_to_mode==1 ){
@@ -2119,12 +2119,12 @@
2119 blob_append_sql(&ins, "INSERT INTO pathnode(x) VALUES(%d)", p->rid);
2120 if( p->u.pTo==0 ) bMin = 0;
2121 for(p=p->u.pTo; p; p=p->u.pTo){
2122 if( bMin
2123 && p->u.pTo!=0
2124 && fossil_strcmp(path_branch(p->pFrom),path_branch(p))==0
2125 && fossil_strcmp(path_branch(p),path_branch(p->u.pTo))==0
2126 ){
2127 continue;
2128 }
2129 if( cnt==8 ){
2130 blob_append_sql(&ins, ",\n (%d)", p->rid);
2131

Keyboard Shortcuts

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