Fossil SCM

Fix some issue with the timeline command when using the "after" keyword.

mgagnon 2025-04-11 21:47 trunk merge
Commit ee2a71b5c7e0aaed8be7466f7f7eada8b01b670df874c3db5bcf00df988cb904
2 files changed +15 -4 +15 -4
+15 -4
--- src/timeline.c
+++ src/timeline.c
@@ -3749,15 +3749,22 @@
37493749
}
37503750
}
37513751
37523752
if( mode==TIMELINE_MODE_NONE ) mode = TIMELINE_MODE_BEFORE;
37533753
blob_zero(&sql);
3754
+ if( mode==TIMELINE_MODE_AFTER ){
3755
+ /* Extra outer select to get older rows in reverse order */
3756
+ blob_append(&sql, "SELECT *\nFROM (", -1);
3757
+ }
37543758
blob_append(&sql, timeline_query_for_tty(), -1);
37553759
blob_append_sql(&sql, "\n AND event.mtime %s %s",
37563760
( mode==TIMELINE_MODE_BEFORE ||
37573761
mode==TIMELINE_MODE_PARENTS ) ? "<=" : ">=", zDate /*safe-for-%s*/
37583762
);
3763
+ if( zType && (zType[0]!='a') ){
3764
+ blob_append_sql(&sql, "\n AND event.type=%Q ", zType);
3765
+ }
37593766
37603767
/* When zFilePattern is specified, compute complete ancestry;
37613768
* limit later at print_timeline() */
37623769
if( mode==TIMELINE_MODE_CHILDREN || mode==TIMELINE_MODE_PARENTS ){
37633770
db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
@@ -3766,13 +3773,10 @@
37663773
}else{
37673774
compute_ancestors(objid, (zFilePattern ? 0 : n), 0, 0);
37683775
}
37693776
blob_append_sql(&sql, "\n AND blob.rid IN ok");
37703777
}
3771
- if( zType && (zType[0]!='a') ){
3772
- blob_append_sql(&sql, "\n AND event.type=%Q ", zType);
3773
- }
37743778
if( zFilePattern ){
37753779
blob_append(&sql,
37763780
"\n AND EXISTS(SELECT 1 FROM mlink\n"
37773781
" WHERE mlink.mid=event.objid\n"
37783782
" AND mlink.fnid IN ", -1);
@@ -3810,11 +3814,18 @@
38103814
" WHERE tx.value='%q'\n"
38113815
")\n" /* No merge closures */
38123816
" AND (tagxref.value IS NULL OR tagxref.value='%q')",
38133817
zBr, zBr, zBr, TAG_BRANCH, zBr, zBr);
38143818
}
3815
- blob_append_sql(&sql, "\nORDER BY event.mtime DESC");
3819
+
3820
+ if( mode==TIMELINE_MODE_AFTER ){
3821
+ /* Complete the above outer select. */
3822
+ blob_append_sql(&sql,
3823
+ "\nORDER BY event.mtime LIMIT abs(%d)) t ORDER BY t.mDateTime DESC;", n);
3824
+ }else{
3825
+ blob_append_sql(&sql, "\nORDER BY event.mtime DESC");
3826
+ }
38163827
if( iOffset>0 ){
38173828
/* Don't handle LIMIT here, otherwise print_timeline()
38183829
* will not determine the end-marker correctly! */
38193830
blob_append_sql(&sql, "\n LIMIT -1 OFFSET %d", iOffset);
38203831
}
38213832
--- src/timeline.c
+++ src/timeline.c
@@ -3749,15 +3749,22 @@
3749 }
3750 }
3751
3752 if( mode==TIMELINE_MODE_NONE ) mode = TIMELINE_MODE_BEFORE;
3753 blob_zero(&sql);
 
 
 
 
3754 blob_append(&sql, timeline_query_for_tty(), -1);
3755 blob_append_sql(&sql, "\n AND event.mtime %s %s",
3756 ( mode==TIMELINE_MODE_BEFORE ||
3757 mode==TIMELINE_MODE_PARENTS ) ? "<=" : ">=", zDate /*safe-for-%s*/
3758 );
 
 
 
3759
3760 /* When zFilePattern is specified, compute complete ancestry;
3761 * limit later at print_timeline() */
3762 if( mode==TIMELINE_MODE_CHILDREN || mode==TIMELINE_MODE_PARENTS ){
3763 db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
@@ -3766,13 +3773,10 @@
3766 }else{
3767 compute_ancestors(objid, (zFilePattern ? 0 : n), 0, 0);
3768 }
3769 blob_append_sql(&sql, "\n AND blob.rid IN ok");
3770 }
3771 if( zType && (zType[0]!='a') ){
3772 blob_append_sql(&sql, "\n AND event.type=%Q ", zType);
3773 }
3774 if( zFilePattern ){
3775 blob_append(&sql,
3776 "\n AND EXISTS(SELECT 1 FROM mlink\n"
3777 " WHERE mlink.mid=event.objid\n"
3778 " AND mlink.fnid IN ", -1);
@@ -3810,11 +3814,18 @@
3810 " WHERE tx.value='%q'\n"
3811 ")\n" /* No merge closures */
3812 " AND (tagxref.value IS NULL OR tagxref.value='%q')",
3813 zBr, zBr, zBr, TAG_BRANCH, zBr, zBr);
3814 }
3815 blob_append_sql(&sql, "\nORDER BY event.mtime DESC");
 
 
 
 
 
 
 
3816 if( iOffset>0 ){
3817 /* Don't handle LIMIT here, otherwise print_timeline()
3818 * will not determine the end-marker correctly! */
3819 blob_append_sql(&sql, "\n LIMIT -1 OFFSET %d", iOffset);
3820 }
3821
--- src/timeline.c
+++ src/timeline.c
@@ -3749,15 +3749,22 @@
3749 }
3750 }
3751
3752 if( mode==TIMELINE_MODE_NONE ) mode = TIMELINE_MODE_BEFORE;
3753 blob_zero(&sql);
3754 if( mode==TIMELINE_MODE_AFTER ){
3755 /* Extra outer select to get older rows in reverse order */
3756 blob_append(&sql, "SELECT *\nFROM (", -1);
3757 }
3758 blob_append(&sql, timeline_query_for_tty(), -1);
3759 blob_append_sql(&sql, "\n AND event.mtime %s %s",
3760 ( mode==TIMELINE_MODE_BEFORE ||
3761 mode==TIMELINE_MODE_PARENTS ) ? "<=" : ">=", zDate /*safe-for-%s*/
3762 );
3763 if( zType && (zType[0]!='a') ){
3764 blob_append_sql(&sql, "\n AND event.type=%Q ", zType);
3765 }
3766
3767 /* When zFilePattern is specified, compute complete ancestry;
3768 * limit later at print_timeline() */
3769 if( mode==TIMELINE_MODE_CHILDREN || mode==TIMELINE_MODE_PARENTS ){
3770 db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
@@ -3766,13 +3773,10 @@
3773 }else{
3774 compute_ancestors(objid, (zFilePattern ? 0 : n), 0, 0);
3775 }
3776 blob_append_sql(&sql, "\n AND blob.rid IN ok");
3777 }
 
 
 
3778 if( zFilePattern ){
3779 blob_append(&sql,
3780 "\n AND EXISTS(SELECT 1 FROM mlink\n"
3781 " WHERE mlink.mid=event.objid\n"
3782 " AND mlink.fnid IN ", -1);
@@ -3810,11 +3814,18 @@
3814 " WHERE tx.value='%q'\n"
3815 ")\n" /* No merge closures */
3816 " AND (tagxref.value IS NULL OR tagxref.value='%q')",
3817 zBr, zBr, zBr, TAG_BRANCH, zBr, zBr);
3818 }
3819
3820 if( mode==TIMELINE_MODE_AFTER ){
3821 /* Complete the above outer select. */
3822 blob_append_sql(&sql,
3823 "\nORDER BY event.mtime LIMIT abs(%d)) t ORDER BY t.mDateTime DESC;", n);
3824 }else{
3825 blob_append_sql(&sql, "\nORDER BY event.mtime DESC");
3826 }
3827 if( iOffset>0 ){
3828 /* Don't handle LIMIT here, otherwise print_timeline()
3829 * will not determine the end-marker correctly! */
3830 blob_append_sql(&sql, "\n LIMIT -1 OFFSET %d", iOffset);
3831 }
3832
+15 -4
--- src/timeline.c
+++ src/timeline.c
@@ -3749,15 +3749,22 @@
37493749
}
37503750
}
37513751
37523752
if( mode==TIMELINE_MODE_NONE ) mode = TIMELINE_MODE_BEFORE;
37533753
blob_zero(&sql);
3754
+ if( mode==TIMELINE_MODE_AFTER ){
3755
+ /* Extra outer select to get older rows in reverse order */
3756
+ blob_append(&sql, "SELECT *\nFROM (", -1);
3757
+ }
37543758
blob_append(&sql, timeline_query_for_tty(), -1);
37553759
blob_append_sql(&sql, "\n AND event.mtime %s %s",
37563760
( mode==TIMELINE_MODE_BEFORE ||
37573761
mode==TIMELINE_MODE_PARENTS ) ? "<=" : ">=", zDate /*safe-for-%s*/
37583762
);
3763
+ if( zType && (zType[0]!='a') ){
3764
+ blob_append_sql(&sql, "\n AND event.type=%Q ", zType);
3765
+ }
37593766
37603767
/* When zFilePattern is specified, compute complete ancestry;
37613768
* limit later at print_timeline() */
37623769
if( mode==TIMELINE_MODE_CHILDREN || mode==TIMELINE_MODE_PARENTS ){
37633770
db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
@@ -3766,13 +3773,10 @@
37663773
}else{
37673774
compute_ancestors(objid, (zFilePattern ? 0 : n), 0, 0);
37683775
}
37693776
blob_append_sql(&sql, "\n AND blob.rid IN ok");
37703777
}
3771
- if( zType && (zType[0]!='a') ){
3772
- blob_append_sql(&sql, "\n AND event.type=%Q ", zType);
3773
- }
37743778
if( zFilePattern ){
37753779
blob_append(&sql,
37763780
"\n AND EXISTS(SELECT 1 FROM mlink\n"
37773781
" WHERE mlink.mid=event.objid\n"
37783782
" AND mlink.fnid IN ", -1);
@@ -3810,11 +3814,18 @@
38103814
" WHERE tx.value='%q'\n"
38113815
")\n" /* No merge closures */
38123816
" AND (tagxref.value IS NULL OR tagxref.value='%q')",
38133817
zBr, zBr, zBr, TAG_BRANCH, zBr, zBr);
38143818
}
3815
- blob_append_sql(&sql, "\nORDER BY event.mtime DESC");
3819
+
3820
+ if( mode==TIMELINE_MODE_AFTER ){
3821
+ /* Complete the above outer select. */
3822
+ blob_append_sql(&sql,
3823
+ "\nORDER BY event.mtime LIMIT abs(%d)) t ORDER BY t.mDateTime DESC;", n);
3824
+ }else{
3825
+ blob_append_sql(&sql, "\nORDER BY event.mtime DESC");
3826
+ }
38163827
if( iOffset>0 ){
38173828
/* Don't handle LIMIT here, otherwise print_timeline()
38183829
* will not determine the end-marker correctly! */
38193830
blob_append_sql(&sql, "\n LIMIT -1 OFFSET %d", iOffset);
38203831
}
38213832
--- src/timeline.c
+++ src/timeline.c
@@ -3749,15 +3749,22 @@
3749 }
3750 }
3751
3752 if( mode==TIMELINE_MODE_NONE ) mode = TIMELINE_MODE_BEFORE;
3753 blob_zero(&sql);
 
 
 
 
3754 blob_append(&sql, timeline_query_for_tty(), -1);
3755 blob_append_sql(&sql, "\n AND event.mtime %s %s",
3756 ( mode==TIMELINE_MODE_BEFORE ||
3757 mode==TIMELINE_MODE_PARENTS ) ? "<=" : ">=", zDate /*safe-for-%s*/
3758 );
 
 
 
3759
3760 /* When zFilePattern is specified, compute complete ancestry;
3761 * limit later at print_timeline() */
3762 if( mode==TIMELINE_MODE_CHILDREN || mode==TIMELINE_MODE_PARENTS ){
3763 db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
@@ -3766,13 +3773,10 @@
3766 }else{
3767 compute_ancestors(objid, (zFilePattern ? 0 : n), 0, 0);
3768 }
3769 blob_append_sql(&sql, "\n AND blob.rid IN ok");
3770 }
3771 if( zType && (zType[0]!='a') ){
3772 blob_append_sql(&sql, "\n AND event.type=%Q ", zType);
3773 }
3774 if( zFilePattern ){
3775 blob_append(&sql,
3776 "\n AND EXISTS(SELECT 1 FROM mlink\n"
3777 " WHERE mlink.mid=event.objid\n"
3778 " AND mlink.fnid IN ", -1);
@@ -3810,11 +3814,18 @@
3810 " WHERE tx.value='%q'\n"
3811 ")\n" /* No merge closures */
3812 " AND (tagxref.value IS NULL OR tagxref.value='%q')",
3813 zBr, zBr, zBr, TAG_BRANCH, zBr, zBr);
3814 }
3815 blob_append_sql(&sql, "\nORDER BY event.mtime DESC");
 
 
 
 
 
 
 
3816 if( iOffset>0 ){
3817 /* Don't handle LIMIT here, otherwise print_timeline()
3818 * will not determine the end-marker correctly! */
3819 blob_append_sql(&sql, "\n LIMIT -1 OFFSET %d", iOffset);
3820 }
3821
--- src/timeline.c
+++ src/timeline.c
@@ -3749,15 +3749,22 @@
3749 }
3750 }
3751
3752 if( mode==TIMELINE_MODE_NONE ) mode = TIMELINE_MODE_BEFORE;
3753 blob_zero(&sql);
3754 if( mode==TIMELINE_MODE_AFTER ){
3755 /* Extra outer select to get older rows in reverse order */
3756 blob_append(&sql, "SELECT *\nFROM (", -1);
3757 }
3758 blob_append(&sql, timeline_query_for_tty(), -1);
3759 blob_append_sql(&sql, "\n AND event.mtime %s %s",
3760 ( mode==TIMELINE_MODE_BEFORE ||
3761 mode==TIMELINE_MODE_PARENTS ) ? "<=" : ">=", zDate /*safe-for-%s*/
3762 );
3763 if( zType && (zType[0]!='a') ){
3764 blob_append_sql(&sql, "\n AND event.type=%Q ", zType);
3765 }
3766
3767 /* When zFilePattern is specified, compute complete ancestry;
3768 * limit later at print_timeline() */
3769 if( mode==TIMELINE_MODE_CHILDREN || mode==TIMELINE_MODE_PARENTS ){
3770 db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
@@ -3766,13 +3773,10 @@
3773 }else{
3774 compute_ancestors(objid, (zFilePattern ? 0 : n), 0, 0);
3775 }
3776 blob_append_sql(&sql, "\n AND blob.rid IN ok");
3777 }
 
 
 
3778 if( zFilePattern ){
3779 blob_append(&sql,
3780 "\n AND EXISTS(SELECT 1 FROM mlink\n"
3781 " WHERE mlink.mid=event.objid\n"
3782 " AND mlink.fnid IN ", -1);
@@ -3810,11 +3814,18 @@
3814 " WHERE tx.value='%q'\n"
3815 ")\n" /* No merge closures */
3816 " AND (tagxref.value IS NULL OR tagxref.value='%q')",
3817 zBr, zBr, zBr, TAG_BRANCH, zBr, zBr);
3818 }
3819
3820 if( mode==TIMELINE_MODE_AFTER ){
3821 /* Complete the above outer select. */
3822 blob_append_sql(&sql,
3823 "\nORDER BY event.mtime LIMIT abs(%d)) t ORDER BY t.mDateTime DESC;", n);
3824 }else{
3825 blob_append_sql(&sql, "\nORDER BY event.mtime DESC");
3826 }
3827 if( iOffset>0 ){
3828 /* Don't handle LIMIT here, otherwise print_timeline()
3829 * will not determine the end-marker correctly! */
3830 blob_append_sql(&sql, "\n LIMIT -1 OFFSET %d", iOffset);
3831 }
3832

Keyboard Shortcuts

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