Fossil SCM

On the "timeline" command, if a YYYY-MM-DD date string is entered without the "before" keyword, then show all changes on the date given.

drh 2009-11-09 00:58 trunk
Commit 0239325f58a4a0c99463582852ba86f95875e25c
1 file changed +18 -2
+18 -2
--- src/timeline.c
+++ src/timeline.c
@@ -846,15 +846,27 @@
846846
{
847847
blob_appendf( &bl, " AND event.type=%Q", zType );
848848
}
849849
return blob_buffer(&bl);
850850
}
851
+
852
+/*
853
+** Return true if the input string is a date in the ISO 8601 format:
854
+** YYYY-MM-DD.
855
+*/
856
+static int isIsoDate(const char *z){
857
+ return strlen(z)==10
858
+ && z[4]=='-'
859
+ && z[7]=='-'
860
+ && isdigit(z[0])
861
+ && isdigit(z[5]);
862
+}
851863
852864
/*
853865
** COMMAND: timeline
854866
**
855
-** Usage: %fossil timeline ?WHEN? ?BASELINE|DATETIME? ?-n|--count N? ?-t|--type TYPE?
867
+** Usage: %fossil timeline ?WHEN? ?BASELINE|DATETIME? ?-n N? ?-t TYPE?
856868
**
857869
** Print a summary of activity going backwards in date and time
858870
** specified or from the current date and time if no arguments
859871
** are given. Show as many as N (default 20) check-ins. The
860872
** WHEN argument can be any unique abbreviation of one of these
@@ -885,11 +897,11 @@
885897
char *zOrigin;
886898
char *zDate;
887899
char *zSQL;
888900
int objid = 0;
889901
Blob uuid;
890
- int mode = 1 ; /* 1: before 2:after 3:children 4:parents */
902
+ int mode = 0 ; /* 0:none 1: before 2:after 3:children 4:parents */
891903
db_find_and_open_repository(1);
892904
zCount = find_option("count","n",1);
893905
zType = find_option("type","t",1);
894906
if( zCount ){
895907
n = atoi(zCount);
@@ -942,10 +954,14 @@
942954
zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid);
943955
}else{
944956
if( mode==3 || mode==4 ){
945957
fossil_fatal("cannot compute descendants or ancestors of a date");
946958
}
959
+ if( mode==0 ){
960
+ mode = 1;
961
+ if( isIsoDate(zOrigin) ) zOrigin[9]++;
962
+ }
947963
zDate = mprintf("(SELECT julianday(%Q, 'utc'))", zOrigin);
948964
}
949965
zSQL = mprintf("%z AND event.mtime %s %s",
950966
timeline_query_for_tty_m(),
951967
(mode==1 || mode==4) ? "<=" : ">=",
952968
--- src/timeline.c
+++ src/timeline.c
@@ -846,15 +846,27 @@
846 {
847 blob_appendf( &bl, " AND event.type=%Q", zType );
848 }
849 return blob_buffer(&bl);
850 }
 
 
 
 
 
 
 
 
 
 
 
 
851
852 /*
853 ** COMMAND: timeline
854 **
855 ** Usage: %fossil timeline ?WHEN? ?BASELINE|DATETIME? ?-n|--count N? ?-t|--type TYPE?
856 **
857 ** Print a summary of activity going backwards in date and time
858 ** specified or from the current date and time if no arguments
859 ** are given. Show as many as N (default 20) check-ins. The
860 ** WHEN argument can be any unique abbreviation of one of these
@@ -885,11 +897,11 @@
885 char *zOrigin;
886 char *zDate;
887 char *zSQL;
888 int objid = 0;
889 Blob uuid;
890 int mode = 1 ; /* 1: before 2:after 3:children 4:parents */
891 db_find_and_open_repository(1);
892 zCount = find_option("count","n",1);
893 zType = find_option("type","t",1);
894 if( zCount ){
895 n = atoi(zCount);
@@ -942,10 +954,14 @@
942 zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid);
943 }else{
944 if( mode==3 || mode==4 ){
945 fossil_fatal("cannot compute descendants or ancestors of a date");
946 }
 
 
 
 
947 zDate = mprintf("(SELECT julianday(%Q, 'utc'))", zOrigin);
948 }
949 zSQL = mprintf("%z AND event.mtime %s %s",
950 timeline_query_for_tty_m(),
951 (mode==1 || mode==4) ? "<=" : ">=",
952
--- src/timeline.c
+++ src/timeline.c
@@ -846,15 +846,27 @@
846 {
847 blob_appendf( &bl, " AND event.type=%Q", zType );
848 }
849 return blob_buffer(&bl);
850 }
851
852 /*
853 ** Return true if the input string is a date in the ISO 8601 format:
854 ** YYYY-MM-DD.
855 */
856 static int isIsoDate(const char *z){
857 return strlen(z)==10
858 && z[4]=='-'
859 && z[7]=='-'
860 && isdigit(z[0])
861 && isdigit(z[5]);
862 }
863
864 /*
865 ** COMMAND: timeline
866 **
867 ** Usage: %fossil timeline ?WHEN? ?BASELINE|DATETIME? ?-n N? ?-t TYPE?
868 **
869 ** Print a summary of activity going backwards in date and time
870 ** specified or from the current date and time if no arguments
871 ** are given. Show as many as N (default 20) check-ins. The
872 ** WHEN argument can be any unique abbreviation of one of these
@@ -885,11 +897,11 @@
897 char *zOrigin;
898 char *zDate;
899 char *zSQL;
900 int objid = 0;
901 Blob uuid;
902 int mode = 0 ; /* 0:none 1: before 2:after 3:children 4:parents */
903 db_find_and_open_repository(1);
904 zCount = find_option("count","n",1);
905 zType = find_option("type","t",1);
906 if( zCount ){
907 n = atoi(zCount);
@@ -942,10 +954,14 @@
954 zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid);
955 }else{
956 if( mode==3 || mode==4 ){
957 fossil_fatal("cannot compute descendants or ancestors of a date");
958 }
959 if( mode==0 ){
960 mode = 1;
961 if( isIsoDate(zOrigin) ) zOrigin[9]++;
962 }
963 zDate = mprintf("(SELECT julianday(%Q, 'utc'))", zOrigin);
964 }
965 zSQL = mprintf("%z AND event.mtime %s %s",
966 timeline_query_for_tty_m(),
967 (mode==1 || mode==4) ? "<=" : ">=",
968

Keyboard Shortcuts

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