Fossil SCM
Add the --filevers option to the "annotate" command and the "filevers" query parameter to the "annotate" web method. This was used to help analyze the problem described by ticket [f91862eed367]
Commit
c8f10e551ec413b63bf44ae9a9b1b17315645988
Parent
2d92db7ebf4c3f7…
1 file changed
+19
-6
+19
-6
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -747,10 +747,13 @@ | ||
| 747 | 747 | if( zSrc==0 ) zSrc = g.argv[g.argc-1]; |
| 748 | 748 | printf("%10s: %.*s\n", zSrc, x.aOrig[i].n, x.aOrig[i].z); |
| 749 | 749 | } |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | +/* Annotation flags */ | |
| 753 | +#define ANN_FILE_VERS 0x001 /* Show file version rather than commit version */ | |
| 754 | + | |
| 752 | 755 | /* |
| 753 | 756 | ** Compute a complete annotation on a file. The file is identified |
| 754 | 757 | ** by its filename number (filename.fnid) and the baseline in which |
| 755 | 758 | ** it was checked in (mlink.mid). |
| 756 | 759 | */ |
| @@ -757,11 +760,12 @@ | ||
| 757 | 760 | static void annotate_file( |
| 758 | 761 | Annotator *p, /* The annotator */ |
| 759 | 762 | int fnid, /* The name of the file to be annotated */ |
| 760 | 763 | int mid, /* The specific version of the file for this step */ |
| 761 | 764 | int webLabel, /* Use web-style annotations if true */ |
| 762 | - int iLimit /* Limit the number of levels if greater than zero */ | |
| 765 | + int iLimit, /* Limit the number of levels if greater than zero */ | |
| 766 | + int annFlags /* Flags to alter the annotation */ | |
| 763 | 767 | ){ |
| 764 | 768 | Blob toAnnotate; /* Text of the final version of the file */ |
| 765 | 769 | Blob step; /* Text of previous revision */ |
| 766 | 770 | int rid; /* Artifact ID of the file being annotated */ |
| 767 | 771 | char *zLabel; /* Label to apply to a line */ |
| @@ -778,19 +782,21 @@ | ||
| 778 | 782 | db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)"); |
| 779 | 783 | compute_ancestors(mid, 1000000000); |
| 780 | 784 | annotation_start(p, &toAnnotate); |
| 781 | 785 | |
| 782 | 786 | db_prepare(&q, |
| 783 | - "SELECT mlink.fid, blob.uuid, date(event.mtime), " | |
| 787 | + "SELECT mlink.fid," | |
| 788 | + " (SELECT uuid FROM blob WHERE rid=mlink.%s)," | |
| 789 | + " date(event.mtime), " | |
| 784 | 790 | " coalesce(event.euser,event.user) " |
| 785 | - " FROM mlink, blob, event" | |
| 791 | + " FROM mlink, event" | |
| 786 | 792 | " WHERE mlink.fnid=%d" |
| 787 | 793 | " AND mlink.mid IN ok" |
| 788 | - " AND blob.rid=mlink.mid" | |
| 789 | 794 | " AND event.objid=mlink.mid" |
| 790 | 795 | " ORDER BY event.mtime DESC" |
| 791 | 796 | " LIMIT %d", |
| 797 | + (annFlags & ANN_FILE_VERS)!=0 ? "fid" : "mid", | |
| 792 | 798 | fnid, |
| 793 | 799 | iLimit>0 ? iLimit : 10000000 |
| 794 | 800 | ); |
| 795 | 801 | while( db_step(&q)==SQLITE_ROW ){ |
| 796 | 802 | int pid = db_column_int(&q, 0); |
| @@ -826,10 +832,11 @@ | ||
| 826 | 832 | void annotation_page(void){ |
| 827 | 833 | int mid; |
| 828 | 834 | int fnid; |
| 829 | 835 | int i; |
| 830 | 836 | int iLimit; |
| 837 | + int annFlags = 0; | |
| 831 | 838 | Annotator ann; |
| 832 | 839 | |
| 833 | 840 | login_check_credentials(); |
| 834 | 841 | if( !g.okRead ){ login_needed(); return; } |
| 835 | 842 | mid = name_to_rid(PD("checkin","0")); |
| @@ -838,11 +845,12 @@ | ||
| 838 | 845 | iLimit = atoi(PD("limit","-1")); |
| 839 | 846 | if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){ |
| 840 | 847 | fossil_redirect_home(); |
| 841 | 848 | } |
| 842 | 849 | style_header("File Annotation"); |
| 843 | - annotate_file(&ann, fnid, mid, g.okHistory, iLimit); | |
| 850 | + if( P("filevers") ) annFlags |= ANN_FILE_VERS; | |
| 851 | + annotate_file(&ann, fnid, mid, g.okHistory, iLimit, annFlags); | |
| 844 | 852 | if( P("log") ){ |
| 845 | 853 | int i; |
| 846 | 854 | @ <h2>Versions analyzed:</h2> |
| 847 | 855 | @ <ol> |
| 848 | 856 | for(i=0; i<ann.nVers; i++){ |
| @@ -870,10 +878,11 @@ | ||
| 870 | 878 | ** the file was last modified. |
| 871 | 879 | ** |
| 872 | 880 | ** Options: |
| 873 | 881 | ** --limit N Only look backwards in time by N versions |
| 874 | 882 | ** --log List all versions analyzed |
| 883 | +** --filevers Show file version numbers rather than check-in versions | |
| 875 | 884 | */ |
| 876 | 885 | void annotate_cmd(void){ |
| 877 | 886 | int fnid; /* Filename ID */ |
| 878 | 887 | int fid; /* File instance ID */ |
| 879 | 888 | int mid; /* Manifest where file was checked in */ |
| @@ -882,15 +891,18 @@ | ||
| 882 | 891 | Annotator ann; /* The annotation of the file */ |
| 883 | 892 | int i; /* Loop counter */ |
| 884 | 893 | const char *zLimit; /* The value to the --limit option */ |
| 885 | 894 | int iLimit; /* How far back in time to look */ |
| 886 | 895 | int showLog; /* True to show the log */ |
| 896 | + int fileVers; /* Show file version instead of check-in versions */ | |
| 897 | + int annFlags = 0; /* Flags to control annotation properties */ | |
| 887 | 898 | |
| 888 | 899 | zLimit = find_option("limit",0,1); |
| 889 | 900 | if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1"; |
| 890 | 901 | iLimit = atoi(zLimit); |
| 891 | 902 | showLog = find_option("log",0,0)!=0; |
| 903 | + fileVers = find_option("filevers",0,0)!=0; | |
| 892 | 904 | db_must_be_within_tree(); |
| 893 | 905 | if (g.argc<3) { |
| 894 | 906 | usage("FILENAME"); |
| 895 | 907 | } |
| 896 | 908 | file_tree_name(g.argv[2], &treename, 1); |
| @@ -905,11 +917,12 @@ | ||
| 905 | 917 | } |
| 906 | 918 | mid = db_int(0, "SELECT mid FROM mlink WHERE fid=%d AND fnid=%d", fid, fnid); |
| 907 | 919 | if( mid==0 ){ |
| 908 | 920 | fossil_panic("unable to find manifest"); |
| 909 | 921 | } |
| 910 | - annotate_file(&ann, fnid, mid, 0, iLimit); | |
| 922 | + if( fileVers ) annFlags |= ANN_FILE_VERS; | |
| 923 | + annotate_file(&ann, fnid, mid, 0, iLimit, annFlags); | |
| 911 | 924 | if( showLog ){ |
| 912 | 925 | for(i=0; i<ann.nVers; i++){ |
| 913 | 926 | printf("version %3d: %s\n", i+1, ann.azVers[i]); |
| 914 | 927 | } |
| 915 | 928 | printf("---------------------------------------------------\n"); |
| 916 | 929 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -747,10 +747,13 @@ | |
| 747 | if( zSrc==0 ) zSrc = g.argv[g.argc-1]; |
| 748 | printf("%10s: %.*s\n", zSrc, x.aOrig[i].n, x.aOrig[i].z); |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | /* |
| 753 | ** Compute a complete annotation on a file. The file is identified |
| 754 | ** by its filename number (filename.fnid) and the baseline in which |
| 755 | ** it was checked in (mlink.mid). |
| 756 | */ |
| @@ -757,11 +760,12 @@ | |
| 757 | static void annotate_file( |
| 758 | Annotator *p, /* The annotator */ |
| 759 | int fnid, /* The name of the file to be annotated */ |
| 760 | int mid, /* The specific version of the file for this step */ |
| 761 | int webLabel, /* Use web-style annotations if true */ |
| 762 | int iLimit /* Limit the number of levels if greater than zero */ |
| 763 | ){ |
| 764 | Blob toAnnotate; /* Text of the final version of the file */ |
| 765 | Blob step; /* Text of previous revision */ |
| 766 | int rid; /* Artifact ID of the file being annotated */ |
| 767 | char *zLabel; /* Label to apply to a line */ |
| @@ -778,19 +782,21 @@ | |
| 778 | db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)"); |
| 779 | compute_ancestors(mid, 1000000000); |
| 780 | annotation_start(p, &toAnnotate); |
| 781 | |
| 782 | db_prepare(&q, |
| 783 | "SELECT mlink.fid, blob.uuid, date(event.mtime), " |
| 784 | " coalesce(event.euser,event.user) " |
| 785 | " FROM mlink, blob, event" |
| 786 | " WHERE mlink.fnid=%d" |
| 787 | " AND mlink.mid IN ok" |
| 788 | " AND blob.rid=mlink.mid" |
| 789 | " AND event.objid=mlink.mid" |
| 790 | " ORDER BY event.mtime DESC" |
| 791 | " LIMIT %d", |
| 792 | fnid, |
| 793 | iLimit>0 ? iLimit : 10000000 |
| 794 | ); |
| 795 | while( db_step(&q)==SQLITE_ROW ){ |
| 796 | int pid = db_column_int(&q, 0); |
| @@ -826,10 +832,11 @@ | |
| 826 | void annotation_page(void){ |
| 827 | int mid; |
| 828 | int fnid; |
| 829 | int i; |
| 830 | int iLimit; |
| 831 | Annotator ann; |
| 832 | |
| 833 | login_check_credentials(); |
| 834 | if( !g.okRead ){ login_needed(); return; } |
| 835 | mid = name_to_rid(PD("checkin","0")); |
| @@ -838,11 +845,12 @@ | |
| 838 | iLimit = atoi(PD("limit","-1")); |
| 839 | if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){ |
| 840 | fossil_redirect_home(); |
| 841 | } |
| 842 | style_header("File Annotation"); |
| 843 | annotate_file(&ann, fnid, mid, g.okHistory, iLimit); |
| 844 | if( P("log") ){ |
| 845 | int i; |
| 846 | @ <h2>Versions analyzed:</h2> |
| 847 | @ <ol> |
| 848 | for(i=0; i<ann.nVers; i++){ |
| @@ -870,10 +878,11 @@ | |
| 870 | ** the file was last modified. |
| 871 | ** |
| 872 | ** Options: |
| 873 | ** --limit N Only look backwards in time by N versions |
| 874 | ** --log List all versions analyzed |
| 875 | */ |
| 876 | void annotate_cmd(void){ |
| 877 | int fnid; /* Filename ID */ |
| 878 | int fid; /* File instance ID */ |
| 879 | int mid; /* Manifest where file was checked in */ |
| @@ -882,15 +891,18 @@ | |
| 882 | Annotator ann; /* The annotation of the file */ |
| 883 | int i; /* Loop counter */ |
| 884 | const char *zLimit; /* The value to the --limit option */ |
| 885 | int iLimit; /* How far back in time to look */ |
| 886 | int showLog; /* True to show the log */ |
| 887 | |
| 888 | zLimit = find_option("limit",0,1); |
| 889 | if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1"; |
| 890 | iLimit = atoi(zLimit); |
| 891 | showLog = find_option("log",0,0)!=0; |
| 892 | db_must_be_within_tree(); |
| 893 | if (g.argc<3) { |
| 894 | usage("FILENAME"); |
| 895 | } |
| 896 | file_tree_name(g.argv[2], &treename, 1); |
| @@ -905,11 +917,12 @@ | |
| 905 | } |
| 906 | mid = db_int(0, "SELECT mid FROM mlink WHERE fid=%d AND fnid=%d", fid, fnid); |
| 907 | if( mid==0 ){ |
| 908 | fossil_panic("unable to find manifest"); |
| 909 | } |
| 910 | annotate_file(&ann, fnid, mid, 0, iLimit); |
| 911 | if( showLog ){ |
| 912 | for(i=0; i<ann.nVers; i++){ |
| 913 | printf("version %3d: %s\n", i+1, ann.azVers[i]); |
| 914 | } |
| 915 | printf("---------------------------------------------------\n"); |
| 916 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -747,10 +747,13 @@ | |
| 747 | if( zSrc==0 ) zSrc = g.argv[g.argc-1]; |
| 748 | printf("%10s: %.*s\n", zSrc, x.aOrig[i].n, x.aOrig[i].z); |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | /* Annotation flags */ |
| 753 | #define ANN_FILE_VERS 0x001 /* Show file version rather than commit version */ |
| 754 | |
| 755 | /* |
| 756 | ** Compute a complete annotation on a file. The file is identified |
| 757 | ** by its filename number (filename.fnid) and the baseline in which |
| 758 | ** it was checked in (mlink.mid). |
| 759 | */ |
| @@ -757,11 +760,12 @@ | |
| 760 | static void annotate_file( |
| 761 | Annotator *p, /* The annotator */ |
| 762 | int fnid, /* The name of the file to be annotated */ |
| 763 | int mid, /* The specific version of the file for this step */ |
| 764 | int webLabel, /* Use web-style annotations if true */ |
| 765 | int iLimit, /* Limit the number of levels if greater than zero */ |
| 766 | int annFlags /* Flags to alter the annotation */ |
| 767 | ){ |
| 768 | Blob toAnnotate; /* Text of the final version of the file */ |
| 769 | Blob step; /* Text of previous revision */ |
| 770 | int rid; /* Artifact ID of the file being annotated */ |
| 771 | char *zLabel; /* Label to apply to a line */ |
| @@ -778,19 +782,21 @@ | |
| 782 | db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)"); |
| 783 | compute_ancestors(mid, 1000000000); |
| 784 | annotation_start(p, &toAnnotate); |
| 785 | |
| 786 | db_prepare(&q, |
| 787 | "SELECT mlink.fid," |
| 788 | " (SELECT uuid FROM blob WHERE rid=mlink.%s)," |
| 789 | " date(event.mtime), " |
| 790 | " coalesce(event.euser,event.user) " |
| 791 | " FROM mlink, event" |
| 792 | " WHERE mlink.fnid=%d" |
| 793 | " AND mlink.mid IN ok" |
| 794 | " AND event.objid=mlink.mid" |
| 795 | " ORDER BY event.mtime DESC" |
| 796 | " LIMIT %d", |
| 797 | (annFlags & ANN_FILE_VERS)!=0 ? "fid" : "mid", |
| 798 | fnid, |
| 799 | iLimit>0 ? iLimit : 10000000 |
| 800 | ); |
| 801 | while( db_step(&q)==SQLITE_ROW ){ |
| 802 | int pid = db_column_int(&q, 0); |
| @@ -826,10 +832,11 @@ | |
| 832 | void annotation_page(void){ |
| 833 | int mid; |
| 834 | int fnid; |
| 835 | int i; |
| 836 | int iLimit; |
| 837 | int annFlags = 0; |
| 838 | Annotator ann; |
| 839 | |
| 840 | login_check_credentials(); |
| 841 | if( !g.okRead ){ login_needed(); return; } |
| 842 | mid = name_to_rid(PD("checkin","0")); |
| @@ -838,11 +845,12 @@ | |
| 845 | iLimit = atoi(PD("limit","-1")); |
| 846 | if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){ |
| 847 | fossil_redirect_home(); |
| 848 | } |
| 849 | style_header("File Annotation"); |
| 850 | if( P("filevers") ) annFlags |= ANN_FILE_VERS; |
| 851 | annotate_file(&ann, fnid, mid, g.okHistory, iLimit, annFlags); |
| 852 | if( P("log") ){ |
| 853 | int i; |
| 854 | @ <h2>Versions analyzed:</h2> |
| 855 | @ <ol> |
| 856 | for(i=0; i<ann.nVers; i++){ |
| @@ -870,10 +878,11 @@ | |
| 878 | ** the file was last modified. |
| 879 | ** |
| 880 | ** Options: |
| 881 | ** --limit N Only look backwards in time by N versions |
| 882 | ** --log List all versions analyzed |
| 883 | ** --filevers Show file version numbers rather than check-in versions |
| 884 | */ |
| 885 | void annotate_cmd(void){ |
| 886 | int fnid; /* Filename ID */ |
| 887 | int fid; /* File instance ID */ |
| 888 | int mid; /* Manifest where file was checked in */ |
| @@ -882,15 +891,18 @@ | |
| 891 | Annotator ann; /* The annotation of the file */ |
| 892 | int i; /* Loop counter */ |
| 893 | const char *zLimit; /* The value to the --limit option */ |
| 894 | int iLimit; /* How far back in time to look */ |
| 895 | int showLog; /* True to show the log */ |
| 896 | int fileVers; /* Show file version instead of check-in versions */ |
| 897 | int annFlags = 0; /* Flags to control annotation properties */ |
| 898 | |
| 899 | zLimit = find_option("limit",0,1); |
| 900 | if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1"; |
| 901 | iLimit = atoi(zLimit); |
| 902 | showLog = find_option("log",0,0)!=0; |
| 903 | fileVers = find_option("filevers",0,0)!=0; |
| 904 | db_must_be_within_tree(); |
| 905 | if (g.argc<3) { |
| 906 | usage("FILENAME"); |
| 907 | } |
| 908 | file_tree_name(g.argv[2], &treename, 1); |
| @@ -905,11 +917,12 @@ | |
| 917 | } |
| 918 | mid = db_int(0, "SELECT mid FROM mlink WHERE fid=%d AND fnid=%d", fid, fnid); |
| 919 | if( mid==0 ){ |
| 920 | fossil_panic("unable to find manifest"); |
| 921 | } |
| 922 | if( fileVers ) annFlags |= ANN_FILE_VERS; |
| 923 | annotate_file(&ann, fnid, mid, 0, iLimit, annFlags); |
| 924 | if( showLog ){ |
| 925 | for(i=0; i<ann.nVers; i++){ |
| 926 | printf("version %3d: %s\n", i+1, ann.azVers[i]); |
| 927 | } |
| 928 | printf("---------------------------------------------------\n"); |
| 929 |