Fossil SCM
Fix timeline -n 0 to display an unlimited number of lines (rather than zero) to match documentation. Correct timeline -n for negative N documentation to match actual behavior. Limit compute_ancestors() and compute_descendants() on the assumption that there is no more than one entry per line.
Commit
def9af43a3921234fe6d1a5dce0d31a201698c0d
Parent
3eeab4a58954f28…
2 files changed
+14
-4
+3
-2
+14
-4
| --- src/descendants.c | ||
| +++ src/descendants.c | ||
| @@ -158,14 +158,19 @@ | ||
| 158 | 158 | ); |
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /* |
| 163 | -** Load the record ID rid and up to N-1 closest ancestors into | |
| 164 | -** the "ok" table. | |
| 163 | +** Load the record ID rid and up to |N|-1 closest ancestors into | |
| 164 | +** the "ok" table. If N is zero, no limit. | |
| 165 | 165 | */ |
| 166 | 166 | void compute_ancestors(int rid, int N, int directOnly){ |
| 167 | + if( !N ){ | |
| 168 | + N = -1; | |
| 169 | + }else if( N<0 ){ | |
| 170 | + N = -N; | |
| 171 | + } | |
| 167 | 172 | db_multi_exec( |
| 168 | 173 | "WITH RECURSIVE " |
| 169 | 174 | " ancestor(rid, mtime) AS (" |
| 170 | 175 | " SELECT %d, mtime FROM event WHERE objid=%d " |
| 171 | 176 | " UNION " |
| @@ -236,14 +241,19 @@ | ||
| 236 | 241 | db_reset(&q); |
| 237 | 242 | return 0; |
| 238 | 243 | } |
| 239 | 244 | |
| 240 | 245 | /* |
| 241 | -** Load the record ID rid and up to N-1 closest descendants into | |
| 242 | -** the "ok" table. | |
| 246 | +** Load the record ID rid and up to |N|-1 closest descendants into | |
| 247 | +** the "ok" table. If N is zero, no limit. | |
| 243 | 248 | */ |
| 244 | 249 | void compute_descendants(int rid, int N){ |
| 250 | + if( !N ){ | |
| 251 | + N = -1; | |
| 252 | + }else if( N<0 ){ | |
| 253 | + N = -N; | |
| 254 | + } | |
| 245 | 255 | db_multi_exec( |
| 246 | 256 | "WITH RECURSIVE" |
| 247 | 257 | " dx(rid,mtime) AS (" |
| 248 | 258 | " SELECT %d, 0" |
| 249 | 259 | " UNION" |
| 250 | 260 |
| --- src/descendants.c | |
| +++ src/descendants.c | |
| @@ -158,14 +158,19 @@ | |
| 158 | ); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | /* |
| 163 | ** Load the record ID rid and up to N-1 closest ancestors into |
| 164 | ** the "ok" table. |
| 165 | */ |
| 166 | void compute_ancestors(int rid, int N, int directOnly){ |
| 167 | db_multi_exec( |
| 168 | "WITH RECURSIVE " |
| 169 | " ancestor(rid, mtime) AS (" |
| 170 | " SELECT %d, mtime FROM event WHERE objid=%d " |
| 171 | " UNION " |
| @@ -236,14 +241,19 @@ | |
| 236 | db_reset(&q); |
| 237 | return 0; |
| 238 | } |
| 239 | |
| 240 | /* |
| 241 | ** Load the record ID rid and up to N-1 closest descendants into |
| 242 | ** the "ok" table. |
| 243 | */ |
| 244 | void compute_descendants(int rid, int N){ |
| 245 | db_multi_exec( |
| 246 | "WITH RECURSIVE" |
| 247 | " dx(rid,mtime) AS (" |
| 248 | " SELECT %d, 0" |
| 249 | " UNION" |
| 250 |
| --- src/descendants.c | |
| +++ src/descendants.c | |
| @@ -158,14 +158,19 @@ | |
| 158 | ); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | /* |
| 163 | ** Load the record ID rid and up to |N|-1 closest ancestors into |
| 164 | ** the "ok" table. If N is zero, no limit. |
| 165 | */ |
| 166 | void compute_ancestors(int rid, int N, int directOnly){ |
| 167 | if( !N ){ |
| 168 | N = -1; |
| 169 | }else if( N<0 ){ |
| 170 | N = -N; |
| 171 | } |
| 172 | db_multi_exec( |
| 173 | "WITH RECURSIVE " |
| 174 | " ancestor(rid, mtime) AS (" |
| 175 | " SELECT %d, mtime FROM event WHERE objid=%d " |
| 176 | " UNION " |
| @@ -236,14 +241,19 @@ | |
| 241 | db_reset(&q); |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | /* |
| 246 | ** Load the record ID rid and up to |N|-1 closest descendants into |
| 247 | ** the "ok" table. If N is zero, no limit. |
| 248 | */ |
| 249 | void compute_descendants(int rid, int N){ |
| 250 | if( !N ){ |
| 251 | N = -1; |
| 252 | }else if( N<0 ){ |
| 253 | N = -N; |
| 254 | } |
| 255 | db_multi_exec( |
| 256 | "WITH RECURSIVE" |
| 257 | " dx(rid,mtime) AS (" |
| 258 | " SELECT %d, 0" |
| 259 | " UNION" |
| 260 |
+3
-2
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -2335,12 +2335,13 @@ | ||
| 2335 | 2335 | ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z" |
| 2336 | 2336 | ** means UTC. |
| 2337 | 2337 | ** |
| 2338 | 2338 | ** |
| 2339 | 2339 | ** Options: |
| 2340 | -** -n|--limit N Output the first N entries (default 20 lines). | |
| 2341 | -** N=0 means no limit. | |
| 2340 | +** -n|--limit N If N is positive, output the first N entries. If | |
| 2341 | +** N is negative, output the first -N lines. If N is | |
| 2342 | +** zero, no limit. Default is -20 meaning 20 lines. | |
| 2342 | 2343 | ** -p|--path PATH Output items affecting PATH only. |
| 2343 | 2344 | ** PATH can be a file or a sub directory. |
| 2344 | 2345 | ** --offset P skip P changes |
| 2345 | 2346 | ** -t|--type TYPE Output items from the given types only, such as: |
| 2346 | 2347 | ** ci = file commits only |
| 2347 | 2348 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -2335,12 +2335,13 @@ | |
| 2335 | ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z" |
| 2336 | ** means UTC. |
| 2337 | ** |
| 2338 | ** |
| 2339 | ** Options: |
| 2340 | ** -n|--limit N Output the first N entries (default 20 lines). |
| 2341 | ** N=0 means no limit. |
| 2342 | ** -p|--path PATH Output items affecting PATH only. |
| 2343 | ** PATH can be a file or a sub directory. |
| 2344 | ** --offset P skip P changes |
| 2345 | ** -t|--type TYPE Output items from the given types only, such as: |
| 2346 | ** ci = file commits only |
| 2347 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -2335,12 +2335,13 @@ | |
| 2335 | ** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z" |
| 2336 | ** means UTC. |
| 2337 | ** |
| 2338 | ** |
| 2339 | ** Options: |
| 2340 | ** -n|--limit N If N is positive, output the first N entries. If |
| 2341 | ** N is negative, output the first -N lines. If N is |
| 2342 | ** zero, no limit. Default is -20 meaning 20 lines. |
| 2343 | ** -p|--path PATH Output items affecting PATH only. |
| 2344 | ** PATH can be a file or a sub directory. |
| 2345 | ** --offset P skip P changes |
| 2346 | ** -t|--type TYPE Output items from the given types only, such as: |
| 2347 | ** ci = file commits only |
| 2348 |