Fossil SCM
Merge in the annotatecmd_fix branch.
Commit
e161670939b93ec9610b00404b9b44569a2f1711
Parent
4a296c0b1ca85a3…
2 files changed
+2
-1
+11
-1
+2
-1
| --- src/descendants.c | ||
| +++ src/descendants.c | ||
| @@ -202,11 +202,12 @@ | ||
| 202 | 202 | void compute_direct_ancestors(int rid, int N){ |
| 203 | 203 | Stmt ins; |
| 204 | 204 | Stmt q; |
| 205 | 205 | int gen = 0; |
| 206 | 206 | db_multi_exec( |
| 207 | - "CREATE TEMP TABLE ancestor(rid INTEGER, generation INTEGER PRIMARY KEY);" | |
| 207 | + "CREATE TEMP TABLE IF NOT EXISTS ancestor(rid INTEGER, generation INTEGER PRIMARY KEY);" | |
| 208 | + "DELETE FROM ancestor;" | |
| 208 | 209 | "INSERT INTO ancestor VALUES(%d, 0);", rid |
| 209 | 210 | ); |
| 210 | 211 | db_prepare(&ins, "INSERT INTO ancestor VALUES(:rid, :gen)"); |
| 211 | 212 | db_prepare(&q, |
| 212 | 213 | "SELECT pid FROM plink" |
| 213 | 214 |
| --- src/descendants.c | |
| +++ src/descendants.c | |
| @@ -202,11 +202,12 @@ | |
| 202 | void compute_direct_ancestors(int rid, int N){ |
| 203 | Stmt ins; |
| 204 | Stmt q; |
| 205 | int gen = 0; |
| 206 | db_multi_exec( |
| 207 | "CREATE TEMP TABLE ancestor(rid INTEGER, generation INTEGER PRIMARY KEY);" |
| 208 | "INSERT INTO ancestor VALUES(%d, 0);", rid |
| 209 | ); |
| 210 | db_prepare(&ins, "INSERT INTO ancestor VALUES(:rid, :gen)"); |
| 211 | db_prepare(&q, |
| 212 | "SELECT pid FROM plink" |
| 213 |
| --- src/descendants.c | |
| +++ src/descendants.c | |
| @@ -202,11 +202,12 @@ | |
| 202 | void compute_direct_ancestors(int rid, int N){ |
| 203 | Stmt ins; |
| 204 | Stmt q; |
| 205 | int gen = 0; |
| 206 | db_multi_exec( |
| 207 | "CREATE TEMP TABLE IF NOT EXISTS ancestor(rid INTEGER, generation INTEGER PRIMARY KEY);" |
| 208 | "DELETE FROM ancestor;" |
| 209 | "INSERT INTO ancestor VALUES(%d, 0);", rid |
| 210 | ); |
| 211 | db_prepare(&ins, "INSERT INTO ancestor VALUES(:rid, :gen)"); |
| 212 | db_prepare(&q, |
| 213 | "SELECT pid FROM plink" |
| 214 |
+11
-1
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -1068,10 +1068,11 @@ | ||
| 1068 | 1068 | */ |
| 1069 | 1069 | void annotate_cmd(void){ |
| 1070 | 1070 | int fnid; /* Filename ID */ |
| 1071 | 1071 | int fid; /* File instance ID */ |
| 1072 | 1072 | int mid; /* Manifest where file was checked in */ |
| 1073 | + int cid; /* Checkout ID */ | |
| 1073 | 1074 | Blob treename; /* FILENAME translated to canonical form */ |
| 1074 | 1075 | char *zFilename; /* Cannonical filename */ |
| 1075 | 1076 | Annotator ann; /* The annotation of the file */ |
| 1076 | 1077 | int i; /* Loop counter */ |
| 1077 | 1078 | const char *zLimit; /* The value to the --limit option */ |
| @@ -1097,11 +1098,20 @@ | ||
| 1097 | 1098 | } |
| 1098 | 1099 | fid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFilename); |
| 1099 | 1100 | if( fid==0 ){ |
| 1100 | 1101 | fossil_fatal("not part of current checkout: %s", zFilename); |
| 1101 | 1102 | } |
| 1102 | - mid = db_int(0, "SELECT mid FROM mlink WHERE fid=%d AND fnid=%d", fid, fnid); | |
| 1103 | + cid = db_lget_int("checkout", 0); | |
| 1104 | + if (cid == 0){ | |
| 1105 | + fossil_fatal("Not in a checkout"); | |
| 1106 | + } | |
| 1107 | + if( iLimit<=0 ) iLimit = 1000000000; | |
| 1108 | + compute_direct_ancestors(cid, iLimit); | |
| 1109 | + mid = db_int(0, "SELECT mlink.mid FROM mlink, ancestor " | |
| 1110 | + " WHERE mlink.fid=%d AND mlink.fnid=%d AND mlink.mid=ancestor.rid" | |
| 1111 | + " ORDER BY ancestor.generation ASC LIMIT 1", | |
| 1112 | + fid, fnid); | |
| 1103 | 1113 | if( mid==0 ){ |
| 1104 | 1114 | fossil_panic("unable to find manifest"); |
| 1105 | 1115 | } |
| 1106 | 1116 | if( fileVers ) annFlags |= ANN_FILE_VERS; |
| 1107 | 1117 | annotate_file(&ann, fnid, mid, 0, iLimit, annFlags); |
| 1108 | 1118 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -1068,10 +1068,11 @@ | |
| 1068 | */ |
| 1069 | void annotate_cmd(void){ |
| 1070 | int fnid; /* Filename ID */ |
| 1071 | int fid; /* File instance ID */ |
| 1072 | int mid; /* Manifest where file was checked in */ |
| 1073 | Blob treename; /* FILENAME translated to canonical form */ |
| 1074 | char *zFilename; /* Cannonical filename */ |
| 1075 | Annotator ann; /* The annotation of the file */ |
| 1076 | int i; /* Loop counter */ |
| 1077 | const char *zLimit; /* The value to the --limit option */ |
| @@ -1097,11 +1098,20 @@ | |
| 1097 | } |
| 1098 | fid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFilename); |
| 1099 | if( fid==0 ){ |
| 1100 | fossil_fatal("not part of current checkout: %s", zFilename); |
| 1101 | } |
| 1102 | mid = db_int(0, "SELECT mid FROM mlink WHERE fid=%d AND fnid=%d", fid, fnid); |
| 1103 | if( mid==0 ){ |
| 1104 | fossil_panic("unable to find manifest"); |
| 1105 | } |
| 1106 | if( fileVers ) annFlags |= ANN_FILE_VERS; |
| 1107 | annotate_file(&ann, fnid, mid, 0, iLimit, annFlags); |
| 1108 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -1068,10 +1068,11 @@ | |
| 1068 | */ |
| 1069 | void annotate_cmd(void){ |
| 1070 | int fnid; /* Filename ID */ |
| 1071 | int fid; /* File instance ID */ |
| 1072 | int mid; /* Manifest where file was checked in */ |
| 1073 | int cid; /* Checkout ID */ |
| 1074 | Blob treename; /* FILENAME translated to canonical form */ |
| 1075 | char *zFilename; /* Cannonical filename */ |
| 1076 | Annotator ann; /* The annotation of the file */ |
| 1077 | int i; /* Loop counter */ |
| 1078 | const char *zLimit; /* The value to the --limit option */ |
| @@ -1097,11 +1098,20 @@ | |
| 1098 | } |
| 1099 | fid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFilename); |
| 1100 | if( fid==0 ){ |
| 1101 | fossil_fatal("not part of current checkout: %s", zFilename); |
| 1102 | } |
| 1103 | cid = db_lget_int("checkout", 0); |
| 1104 | if (cid == 0){ |
| 1105 | fossil_fatal("Not in a checkout"); |
| 1106 | } |
| 1107 | if( iLimit<=0 ) iLimit = 1000000000; |
| 1108 | compute_direct_ancestors(cid, iLimit); |
| 1109 | mid = db_int(0, "SELECT mlink.mid FROM mlink, ancestor " |
| 1110 | " WHERE mlink.fid=%d AND mlink.fnid=%d AND mlink.mid=ancestor.rid" |
| 1111 | " ORDER BY ancestor.generation ASC LIMIT 1", |
| 1112 | fid, fnid); |
| 1113 | if( mid==0 ){ |
| 1114 | fossil_panic("unable to find manifest"); |
| 1115 | } |
| 1116 | if( fileVers ) annFlags |= ANN_FILE_VERS; |
| 1117 | annotate_file(&ann, fnid, mid, 0, iLimit, annFlags); |
| 1118 |