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]

drh 2011-05-11 21:43 trunk
Commit c8f10e551ec413b63bf44ae9a9b1b17315645988
1 file changed +19 -6
+19 -6
--- src/diff.c
+++ src/diff.c
@@ -747,10 +747,13 @@
747747
if( zSrc==0 ) zSrc = g.argv[g.argc-1];
748748
printf("%10s: %.*s\n", zSrc, x.aOrig[i].n, x.aOrig[i].z);
749749
}
750750
}
751751
752
+/* Annotation flags */
753
+#define ANN_FILE_VERS 0x001 /* Show file version rather than commit version */
754
+
752755
/*
753756
** Compute a complete annotation on a file. The file is identified
754757
** by its filename number (filename.fnid) and the baseline in which
755758
** it was checked in (mlink.mid).
756759
*/
@@ -757,11 +760,12 @@
757760
static void annotate_file(
758761
Annotator *p, /* The annotator */
759762
int fnid, /* The name of the file to be annotated */
760763
int mid, /* The specific version of the file for this step */
761764
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 */
763767
){
764768
Blob toAnnotate; /* Text of the final version of the file */
765769
Blob step; /* Text of previous revision */
766770
int rid; /* Artifact ID of the file being annotated */
767771
char *zLabel; /* Label to apply to a line */
@@ -778,19 +782,21 @@
778782
db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
779783
compute_ancestors(mid, 1000000000);
780784
annotation_start(p, &toAnnotate);
781785
782786
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), "
784790
" coalesce(event.euser,event.user) "
785
- " FROM mlink, blob, event"
791
+ " FROM mlink, event"
786792
" WHERE mlink.fnid=%d"
787793
" AND mlink.mid IN ok"
788
- " AND blob.rid=mlink.mid"
789794
" AND event.objid=mlink.mid"
790795
" ORDER BY event.mtime DESC"
791796
" LIMIT %d",
797
+ (annFlags & ANN_FILE_VERS)!=0 ? "fid" : "mid",
792798
fnid,
793799
iLimit>0 ? iLimit : 10000000
794800
);
795801
while( db_step(&q)==SQLITE_ROW ){
796802
int pid = db_column_int(&q, 0);
@@ -826,10 +832,11 @@
826832
void annotation_page(void){
827833
int mid;
828834
int fnid;
829835
int i;
830836
int iLimit;
837
+ int annFlags = 0;
831838
Annotator ann;
832839
833840
login_check_credentials();
834841
if( !g.okRead ){ login_needed(); return; }
835842
mid = name_to_rid(PD("checkin","0"));
@@ -838,11 +845,12 @@
838845
iLimit = atoi(PD("limit","-1"));
839846
if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){
840847
fossil_redirect_home();
841848
}
842849
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);
844852
if( P("log") ){
845853
int i;
846854
@ <h2>Versions analyzed:</h2>
847855
@ <ol>
848856
for(i=0; i<ann.nVers; i++){
@@ -870,10 +878,11 @@
870878
** the file was last modified.
871879
**
872880
** Options:
873881
** --limit N Only look backwards in time by N versions
874882
** --log List all versions analyzed
883
+** --filevers Show file version numbers rather than check-in versions
875884
*/
876885
void annotate_cmd(void){
877886
int fnid; /* Filename ID */
878887
int fid; /* File instance ID */
879888
int mid; /* Manifest where file was checked in */
@@ -882,15 +891,18 @@
882891
Annotator ann; /* The annotation of the file */
883892
int i; /* Loop counter */
884893
const char *zLimit; /* The value to the --limit option */
885894
int iLimit; /* How far back in time to look */
886895
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 */
887898
888899
zLimit = find_option("limit",0,1);
889900
if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1";
890901
iLimit = atoi(zLimit);
891902
showLog = find_option("log",0,0)!=0;
903
+ fileVers = find_option("filevers",0,0)!=0;
892904
db_must_be_within_tree();
893905
if (g.argc<3) {
894906
usage("FILENAME");
895907
}
896908
file_tree_name(g.argv[2], &treename, 1);
@@ -905,11 +917,12 @@
905917
}
906918
mid = db_int(0, "SELECT mid FROM mlink WHERE fid=%d AND fnid=%d", fid, fnid);
907919
if( mid==0 ){
908920
fossil_panic("unable to find manifest");
909921
}
910
- annotate_file(&ann, fnid, mid, 0, iLimit);
922
+ if( fileVers ) annFlags |= ANN_FILE_VERS;
923
+ annotate_file(&ann, fnid, mid, 0, iLimit, annFlags);
911924
if( showLog ){
912925
for(i=0; i<ann.nVers; i++){
913926
printf("version %3d: %s\n", i+1, ann.azVers[i]);
914927
}
915928
printf("---------------------------------------------------\n");
916929
--- 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

Keyboard Shortcuts

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