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.
Commit
0239325f58a4a0c99463582852ba86f95875e25c
Parent
20600107f137736…
1 file changed
+18
-2
+18
-2
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -846,15 +846,27 @@ | ||
| 846 | 846 | { |
| 847 | 847 | blob_appendf( &bl, " AND event.type=%Q", zType ); |
| 848 | 848 | } |
| 849 | 849 | return blob_buffer(&bl); |
| 850 | 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 | +} | |
| 851 | 863 | |
| 852 | 864 | /* |
| 853 | 865 | ** COMMAND: timeline |
| 854 | 866 | ** |
| 855 | -** Usage: %fossil timeline ?WHEN? ?BASELINE|DATETIME? ?-n|--count N? ?-t|--type TYPE? | |
| 867 | +** Usage: %fossil timeline ?WHEN? ?BASELINE|DATETIME? ?-n N? ?-t TYPE? | |
| 856 | 868 | ** |
| 857 | 869 | ** Print a summary of activity going backwards in date and time |
| 858 | 870 | ** specified or from the current date and time if no arguments |
| 859 | 871 | ** are given. Show as many as N (default 20) check-ins. The |
| 860 | 872 | ** WHEN argument can be any unique abbreviation of one of these |
| @@ -885,11 +897,11 @@ | ||
| 885 | 897 | char *zOrigin; |
| 886 | 898 | char *zDate; |
| 887 | 899 | char *zSQL; |
| 888 | 900 | int objid = 0; |
| 889 | 901 | 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 */ | |
| 891 | 903 | db_find_and_open_repository(1); |
| 892 | 904 | zCount = find_option("count","n",1); |
| 893 | 905 | zType = find_option("type","t",1); |
| 894 | 906 | if( zCount ){ |
| 895 | 907 | n = atoi(zCount); |
| @@ -942,10 +954,14 @@ | ||
| 942 | 954 | zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid); |
| 943 | 955 | }else{ |
| 944 | 956 | if( mode==3 || mode==4 ){ |
| 945 | 957 | fossil_fatal("cannot compute descendants or ancestors of a date"); |
| 946 | 958 | } |
| 959 | + if( mode==0 ){ | |
| 960 | + mode = 1; | |
| 961 | + if( isIsoDate(zOrigin) ) zOrigin[9]++; | |
| 962 | + } | |
| 947 | 963 | zDate = mprintf("(SELECT julianday(%Q, 'utc'))", zOrigin); |
| 948 | 964 | } |
| 949 | 965 | zSQL = mprintf("%z AND event.mtime %s %s", |
| 950 | 966 | timeline_query_for_tty_m(), |
| 951 | 967 | (mode==1 || mode==4) ? "<=" : ">=", |
| 952 | 968 |
| --- 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 |