Fossil SCM
Add button to annotate/blame pages. Also minor bug fix for annotate/blame pages url rendering.
Commit
f1e99a5a408c42a70e9c811f35f6ad8e459bdbc6
Parent
0ec153a2a7b9452…
1 file changed
+29
-10
+29
-10
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -1994,16 +1994,16 @@ | ||
| 1994 | 1994 | /* |
| 1995 | 1995 | ** Initialize the annotation process by specifying the file that is |
| 1996 | 1996 | ** to be annotated. The annotator takes control of the input Blob and |
| 1997 | 1997 | ** will release it when it is finished with it. |
| 1998 | 1998 | */ |
| 1999 | -static int annotation_start(Annotator *p, Blob *pInput){ | |
| 1999 | +static int annotation_start(Annotator *p, Blob *pInput, u64 diffFlags){ | |
| 2000 | 2000 | int i; |
| 2001 | 2001 | |
| 2002 | 2002 | memset(p, 0, sizeof(*p)); |
| 2003 | 2003 | p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo, |
| 2004 | - DIFF_IGNORE_SOLWS|DIFF_IGNORE_EOLWS); | |
| 2004 | + diffFlags); | |
| 2005 | 2005 | if( p->c.aTo==0 ){ |
| 2006 | 2006 | return 1; |
| 2007 | 2007 | } |
| 2008 | 2008 | p->aOrig = fossil_malloc( sizeof(p->aOrig[0])*p->c.nTo ); |
| 2009 | 2009 | for(i=0; i<p->c.nTo; i++){ |
| @@ -2020,17 +2020,17 @@ | ||
| 2020 | 2020 | ** being annotated. Do another step of the annotation. Return true |
| 2021 | 2021 | ** if additional annotation is required. zPName is the tag to insert |
| 2022 | 2022 | ** on each line of the file being annotated that was contributed by |
| 2023 | 2023 | ** pParent. Memory to hold zPName is leaked. |
| 2024 | 2024 | */ |
| 2025 | -static int annotation_step(Annotator *p, Blob *pParent, int iVers){ | |
| 2025 | +static int annotation_step(Annotator *p, Blob *pParent, int iVers, u64 diffFlags){ | |
| 2026 | 2026 | int i, j; |
| 2027 | 2027 | int lnTo; |
| 2028 | 2028 | |
| 2029 | 2029 | /* Prepare the parent file to be diffed */ |
| 2030 | 2030 | p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent), |
| 2031 | - &p->c.nFrom, DIFF_IGNORE_SOLWS|DIFF_IGNORE_EOLWS); | |
| 2031 | + &p->c.nFrom, diffFlags); | |
| 2032 | 2032 | if( p->c.aFrom==0 ){ |
| 2033 | 2033 | return 1; |
| 2034 | 2034 | } |
| 2035 | 2035 | |
| 2036 | 2036 | /* Compute the differences going from pParent to the file being |
| @@ -2077,11 +2077,12 @@ | ||
| 2077 | 2077 | static void annotate_file( |
| 2078 | 2078 | Annotator *p, /* The annotator */ |
| 2079 | 2079 | int fnid, /* The name of the file to be annotated */ |
| 2080 | 2080 | int mid, /* Use the version of the file in this check-in */ |
| 2081 | 2081 | int iLimit, /* Limit the number of levels if greater than zero */ |
| 2082 | - int annFlags /* Flags to alter the annotation */ | |
| 2082 | + int annFlags, /* Flags to alter the annotation */ | |
| 2083 | + u64 diffFlags /* Flags to alter the whitespace handling */ | |
| 2083 | 2084 | ){ |
| 2084 | 2085 | Blob toAnnotate; /* Text of the final (mid) version of the file */ |
| 2085 | 2086 | Blob step; /* Text of previous revision */ |
| 2086 | 2087 | int rid; /* Artifact ID of the file being annotated */ |
| 2087 | 2088 | Stmt q; /* Query returning all ancestor versions */ |
| @@ -2095,11 +2096,11 @@ | ||
| 2095 | 2096 | } |
| 2096 | 2097 | if( !content_get(rid, &toAnnotate) ){ |
| 2097 | 2098 | fossil_fatal("unable to retrieve content of artifact #%d", rid); |
| 2098 | 2099 | } |
| 2099 | 2100 | if( iLimit<=0 ) iLimit = 1000000000; |
| 2100 | - annotation_start(p, &toAnnotate); | |
| 2101 | + annotation_start(p, &toAnnotate, diffFlags); | |
| 2101 | 2102 | db_begin_transaction(); |
| 2102 | 2103 | db_multi_exec( |
| 2103 | 2104 | "CREATE TEMP TABLE IF NOT EXISTS vseen(rid INTEGER PRIMARY KEY);" |
| 2104 | 2105 | "DELETE FROM vseen;" |
| 2105 | 2106 | ); |
| @@ -2129,11 +2130,11 @@ | ||
| 2129 | 2130 | p->aVers[p->nVers].zMUuid = fossil_strdup(db_column_text(&q, 1)); |
| 2130 | 2131 | p->aVers[p->nVers].zDate = fossil_strdup(db_column_text(&q, 2)); |
| 2131 | 2132 | p->aVers[p->nVers].zUser = fossil_strdup(db_column_text(&q, 3)); |
| 2132 | 2133 | if( p->nVers ){ |
| 2133 | 2134 | content_get(rid, &step); |
| 2134 | - annotation_step(p, &step, p->nVers-1); | |
| 2135 | + annotation_step(p, &step, p->nVers-1, diffFlags); | |
| 2135 | 2136 | blob_reset(&step); |
| 2136 | 2137 | } |
| 2137 | 2138 | p->nVers++; |
| 2138 | 2139 | db_bind_int(&ins, ":rid", rid); |
| 2139 | 2140 | db_step(&ins); |
| @@ -2185,10 +2186,12 @@ | ||
| 2185 | 2186 | int fnid; |
| 2186 | 2187 | int i; |
| 2187 | 2188 | int iLimit; /* Depth limit */ |
| 2188 | 2189 | int annFlags = ANN_FILE_ANCEST; |
| 2189 | 2190 | int showLog = 0; /* True to display the log */ |
| 2191 | + int ignoreWs = 0; /* Ignore whitespace */ | |
| 2192 | + u64 diffFlags = 0; /* diff flags for ignore whitespace */ | |
| 2190 | 2193 | const char *zFilename; /* Name of file to annotate */ |
| 2191 | 2194 | const char *zCI; /* The check-in containing zFilename */ |
| 2192 | 2195 | Annotator ann; |
| 2193 | 2196 | HQuery url; |
| 2194 | 2197 | struct AnnVers *p; |
| @@ -2204,26 +2207,40 @@ | ||
| 2204 | 2207 | zFilename = P("filename"); |
| 2205 | 2208 | fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename); |
| 2206 | 2209 | if( mid==0 || fnid==0 ){ fossil_redirect_home(); } |
| 2207 | 2210 | iLimit = atoi(PD("limit","20")); |
| 2208 | 2211 | if( P("filevers") ) annFlags |= ANN_FILE_VERS; |
| 2212 | + ignoreWs = atoi(PD("w","0"))!=0; | |
| 2213 | + if( ignoreWs ) diffFlags |= (DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS); | |
| 2209 | 2214 | if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){ |
| 2210 | 2215 | fossil_redirect_home(); |
| 2211 | 2216 | } |
| 2212 | 2217 | |
| 2213 | 2218 | /* compute the annotation */ |
| 2214 | 2219 | compute_direct_ancestors(mid, 10000000); |
| 2215 | - annotate_file(&ann, fnid, mid, iLimit, annFlags); | |
| 2220 | + annotate_file(&ann, fnid, mid, iLimit, annFlags, diffFlags); | |
| 2216 | 2221 | zCI = ann.aVers[0].zMUuid; |
| 2217 | 2222 | |
| 2218 | 2223 | /* generate the web page */ |
| 2219 | 2224 | style_header("Annotation For %h", zFilename); |
| 2220 | - url_initialize(&url, "annotate"); | |
| 2225 | + if( bBlame ){ | |
| 2226 | + url_initialize(&url, "blame"); | |
| 2227 | + }else{ | |
| 2228 | + url_initialize(&url, "annotate"); | |
| 2229 | + } | |
| 2221 | 2230 | url_add_parameter(&url, "checkin", P("checkin")); |
| 2222 | 2231 | url_add_parameter(&url, "filename", zFilename); |
| 2223 | 2232 | if( iLimit!=20 ){ |
| 2224 | 2233 | url_add_parameter(&url, "limit", sqlite3_mprintf("%d", iLimit)); |
| 2234 | + } | |
| 2235 | + url_add_parameter(&url, "w", ignoreWs ? "1" : "0"); | |
| 2236 | + if( ignoreWs ){ | |
| 2237 | + style_submenu_element("Show Whitespace Changes", "Show Whitespace Changes", | |
| 2238 | + "%s", url_render(&url, "w", "0", 0, 0)); | |
| 2239 | + }else{ | |
| 2240 | + style_submenu_element("Ignore Whitespace", "Ignore Whitespace", | |
| 2241 | + "%s", url_render(&url, "w", "1", 0, 0)); | |
| 2225 | 2242 | } |
| 2226 | 2243 | url_add_parameter(&url, "log", showLog ? "1" : "0"); |
| 2227 | 2244 | if( showLog ){ |
| 2228 | 2245 | style_submenu_element("Hide Log", "Hide Log", |
| 2229 | 2246 | "%s", url_render(&url, "log", "0", 0, 0)); |
| @@ -2361,19 +2378,21 @@ | ||
| 2361 | 2378 | Annotator ann; /* The annotation of the file */ |
| 2362 | 2379 | int i; /* Loop counter */ |
| 2363 | 2380 | const char *zLimit; /* The value to the -n|--limit option */ |
| 2364 | 2381 | int iLimit; /* How far back in time to look */ |
| 2365 | 2382 | int showLog; /* True to show the log */ |
| 2383 | + u64 diffFlags = 0;/* Flags to control whitespace handling */ | |
| 2366 | 2384 | int fileVers; /* Show file version instead of check-in versions */ |
| 2367 | 2385 | int annFlags = 0; /* Flags to control annotation properties */ |
| 2368 | 2386 | int bBlame = 0; /* True for BLAME output. False for ANNOTATE. */ |
| 2369 | 2387 | |
| 2370 | 2388 | bBlame = g.argv[1][0]=='b'; |
| 2371 | 2389 | zLimit = find_option("limit","n",1); |
| 2372 | 2390 | if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1"; |
| 2373 | 2391 | iLimit = atoi(zLimit); |
| 2374 | 2392 | showLog = find_option("log","l",0)!=0; |
| 2393 | + if( find_option("w",0,0)!=0 ) diffFlags |= (DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS); | |
| 2375 | 2394 | fileVers = find_option("filevers",0,0)!=0; |
| 2376 | 2395 | db_must_be_within_tree(); |
| 2377 | 2396 | if( g.argc<3 ) { |
| 2378 | 2397 | usage("FILENAME"); |
| 2379 | 2398 | } |
| @@ -2399,11 +2418,11 @@ | ||
| 2399 | 2418 | fid, fnid); |
| 2400 | 2419 | if( mid==0 ){ |
| 2401 | 2420 | fossil_fatal("unable to find manifest"); |
| 2402 | 2421 | } |
| 2403 | 2422 | annFlags |= ANN_FILE_ANCEST; |
| 2404 | - annotate_file(&ann, fnid, mid, iLimit, annFlags); | |
| 2423 | + annotate_file(&ann, fnid, mid, iLimit, annFlags, diffFlags); | |
| 2405 | 2424 | if( showLog ){ |
| 2406 | 2425 | struct AnnVers *p; |
| 2407 | 2426 | for(p=ann.aVers, i=0; i<ann.nVers; i++, p++){ |
| 2408 | 2427 | fossil_print("version %3d: %s %.10s file %.10s\n", |
| 2409 | 2428 | i+1, p->zDate, p->zMUuid, p->zFUuid); |
| 2410 | 2429 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -1994,16 +1994,16 @@ | |
| 1994 | /* |
| 1995 | ** Initialize the annotation process by specifying the file that is |
| 1996 | ** to be annotated. The annotator takes control of the input Blob and |
| 1997 | ** will release it when it is finished with it. |
| 1998 | */ |
| 1999 | static int annotation_start(Annotator *p, Blob *pInput){ |
| 2000 | int i; |
| 2001 | |
| 2002 | memset(p, 0, sizeof(*p)); |
| 2003 | p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo, |
| 2004 | DIFF_IGNORE_SOLWS|DIFF_IGNORE_EOLWS); |
| 2005 | if( p->c.aTo==0 ){ |
| 2006 | return 1; |
| 2007 | } |
| 2008 | p->aOrig = fossil_malloc( sizeof(p->aOrig[0])*p->c.nTo ); |
| 2009 | for(i=0; i<p->c.nTo; i++){ |
| @@ -2020,17 +2020,17 @@ | |
| 2020 | ** being annotated. Do another step of the annotation. Return true |
| 2021 | ** if additional annotation is required. zPName is the tag to insert |
| 2022 | ** on each line of the file being annotated that was contributed by |
| 2023 | ** pParent. Memory to hold zPName is leaked. |
| 2024 | */ |
| 2025 | static int annotation_step(Annotator *p, Blob *pParent, int iVers){ |
| 2026 | int i, j; |
| 2027 | int lnTo; |
| 2028 | |
| 2029 | /* Prepare the parent file to be diffed */ |
| 2030 | p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent), |
| 2031 | &p->c.nFrom, DIFF_IGNORE_SOLWS|DIFF_IGNORE_EOLWS); |
| 2032 | if( p->c.aFrom==0 ){ |
| 2033 | return 1; |
| 2034 | } |
| 2035 | |
| 2036 | /* Compute the differences going from pParent to the file being |
| @@ -2077,11 +2077,12 @@ | |
| 2077 | static void annotate_file( |
| 2078 | Annotator *p, /* The annotator */ |
| 2079 | int fnid, /* The name of the file to be annotated */ |
| 2080 | int mid, /* Use the version of the file in this check-in */ |
| 2081 | int iLimit, /* Limit the number of levels if greater than zero */ |
| 2082 | int annFlags /* Flags to alter the annotation */ |
| 2083 | ){ |
| 2084 | Blob toAnnotate; /* Text of the final (mid) version of the file */ |
| 2085 | Blob step; /* Text of previous revision */ |
| 2086 | int rid; /* Artifact ID of the file being annotated */ |
| 2087 | Stmt q; /* Query returning all ancestor versions */ |
| @@ -2095,11 +2096,11 @@ | |
| 2095 | } |
| 2096 | if( !content_get(rid, &toAnnotate) ){ |
| 2097 | fossil_fatal("unable to retrieve content of artifact #%d", rid); |
| 2098 | } |
| 2099 | if( iLimit<=0 ) iLimit = 1000000000; |
| 2100 | annotation_start(p, &toAnnotate); |
| 2101 | db_begin_transaction(); |
| 2102 | db_multi_exec( |
| 2103 | "CREATE TEMP TABLE IF NOT EXISTS vseen(rid INTEGER PRIMARY KEY);" |
| 2104 | "DELETE FROM vseen;" |
| 2105 | ); |
| @@ -2129,11 +2130,11 @@ | |
| 2129 | p->aVers[p->nVers].zMUuid = fossil_strdup(db_column_text(&q, 1)); |
| 2130 | p->aVers[p->nVers].zDate = fossil_strdup(db_column_text(&q, 2)); |
| 2131 | p->aVers[p->nVers].zUser = fossil_strdup(db_column_text(&q, 3)); |
| 2132 | if( p->nVers ){ |
| 2133 | content_get(rid, &step); |
| 2134 | annotation_step(p, &step, p->nVers-1); |
| 2135 | blob_reset(&step); |
| 2136 | } |
| 2137 | p->nVers++; |
| 2138 | db_bind_int(&ins, ":rid", rid); |
| 2139 | db_step(&ins); |
| @@ -2185,10 +2186,12 @@ | |
| 2185 | int fnid; |
| 2186 | int i; |
| 2187 | int iLimit; /* Depth limit */ |
| 2188 | int annFlags = ANN_FILE_ANCEST; |
| 2189 | int showLog = 0; /* True to display the log */ |
| 2190 | const char *zFilename; /* Name of file to annotate */ |
| 2191 | const char *zCI; /* The check-in containing zFilename */ |
| 2192 | Annotator ann; |
| 2193 | HQuery url; |
| 2194 | struct AnnVers *p; |
| @@ -2204,26 +2207,40 @@ | |
| 2204 | zFilename = P("filename"); |
| 2205 | fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename); |
| 2206 | if( mid==0 || fnid==0 ){ fossil_redirect_home(); } |
| 2207 | iLimit = atoi(PD("limit","20")); |
| 2208 | if( P("filevers") ) annFlags |= ANN_FILE_VERS; |
| 2209 | if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){ |
| 2210 | fossil_redirect_home(); |
| 2211 | } |
| 2212 | |
| 2213 | /* compute the annotation */ |
| 2214 | compute_direct_ancestors(mid, 10000000); |
| 2215 | annotate_file(&ann, fnid, mid, iLimit, annFlags); |
| 2216 | zCI = ann.aVers[0].zMUuid; |
| 2217 | |
| 2218 | /* generate the web page */ |
| 2219 | style_header("Annotation For %h", zFilename); |
| 2220 | url_initialize(&url, "annotate"); |
| 2221 | url_add_parameter(&url, "checkin", P("checkin")); |
| 2222 | url_add_parameter(&url, "filename", zFilename); |
| 2223 | if( iLimit!=20 ){ |
| 2224 | url_add_parameter(&url, "limit", sqlite3_mprintf("%d", iLimit)); |
| 2225 | } |
| 2226 | url_add_parameter(&url, "log", showLog ? "1" : "0"); |
| 2227 | if( showLog ){ |
| 2228 | style_submenu_element("Hide Log", "Hide Log", |
| 2229 | "%s", url_render(&url, "log", "0", 0, 0)); |
| @@ -2361,19 +2378,21 @@ | |
| 2361 | Annotator ann; /* The annotation of the file */ |
| 2362 | int i; /* Loop counter */ |
| 2363 | const char *zLimit; /* The value to the -n|--limit option */ |
| 2364 | int iLimit; /* How far back in time to look */ |
| 2365 | int showLog; /* True to show the log */ |
| 2366 | int fileVers; /* Show file version instead of check-in versions */ |
| 2367 | int annFlags = 0; /* Flags to control annotation properties */ |
| 2368 | int bBlame = 0; /* True for BLAME output. False for ANNOTATE. */ |
| 2369 | |
| 2370 | bBlame = g.argv[1][0]=='b'; |
| 2371 | zLimit = find_option("limit","n",1); |
| 2372 | if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1"; |
| 2373 | iLimit = atoi(zLimit); |
| 2374 | showLog = find_option("log","l",0)!=0; |
| 2375 | fileVers = find_option("filevers",0,0)!=0; |
| 2376 | db_must_be_within_tree(); |
| 2377 | if( g.argc<3 ) { |
| 2378 | usage("FILENAME"); |
| 2379 | } |
| @@ -2399,11 +2418,11 @@ | |
| 2399 | fid, fnid); |
| 2400 | if( mid==0 ){ |
| 2401 | fossil_fatal("unable to find manifest"); |
| 2402 | } |
| 2403 | annFlags |= ANN_FILE_ANCEST; |
| 2404 | annotate_file(&ann, fnid, mid, iLimit, annFlags); |
| 2405 | if( showLog ){ |
| 2406 | struct AnnVers *p; |
| 2407 | for(p=ann.aVers, i=0; i<ann.nVers; i++, p++){ |
| 2408 | fossil_print("version %3d: %s %.10s file %.10s\n", |
| 2409 | i+1, p->zDate, p->zMUuid, p->zFUuid); |
| 2410 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -1994,16 +1994,16 @@ | |
| 1994 | /* |
| 1995 | ** Initialize the annotation process by specifying the file that is |
| 1996 | ** to be annotated. The annotator takes control of the input Blob and |
| 1997 | ** will release it when it is finished with it. |
| 1998 | */ |
| 1999 | static int annotation_start(Annotator *p, Blob *pInput, u64 diffFlags){ |
| 2000 | int i; |
| 2001 | |
| 2002 | memset(p, 0, sizeof(*p)); |
| 2003 | p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo, |
| 2004 | diffFlags); |
| 2005 | if( p->c.aTo==0 ){ |
| 2006 | return 1; |
| 2007 | } |
| 2008 | p->aOrig = fossil_malloc( sizeof(p->aOrig[0])*p->c.nTo ); |
| 2009 | for(i=0; i<p->c.nTo; i++){ |
| @@ -2020,17 +2020,17 @@ | |
| 2020 | ** being annotated. Do another step of the annotation. Return true |
| 2021 | ** if additional annotation is required. zPName is the tag to insert |
| 2022 | ** on each line of the file being annotated that was contributed by |
| 2023 | ** pParent. Memory to hold zPName is leaked. |
| 2024 | */ |
| 2025 | static int annotation_step(Annotator *p, Blob *pParent, int iVers, u64 diffFlags){ |
| 2026 | int i, j; |
| 2027 | int lnTo; |
| 2028 | |
| 2029 | /* Prepare the parent file to be diffed */ |
| 2030 | p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent), |
| 2031 | &p->c.nFrom, diffFlags); |
| 2032 | if( p->c.aFrom==0 ){ |
| 2033 | return 1; |
| 2034 | } |
| 2035 | |
| 2036 | /* Compute the differences going from pParent to the file being |
| @@ -2077,11 +2077,12 @@ | |
| 2077 | static void annotate_file( |
| 2078 | Annotator *p, /* The annotator */ |
| 2079 | int fnid, /* The name of the file to be annotated */ |
| 2080 | int mid, /* Use the version of the file in this check-in */ |
| 2081 | int iLimit, /* Limit the number of levels if greater than zero */ |
| 2082 | int annFlags, /* Flags to alter the annotation */ |
| 2083 | u64 diffFlags /* Flags to alter the whitespace handling */ |
| 2084 | ){ |
| 2085 | Blob toAnnotate; /* Text of the final (mid) version of the file */ |
| 2086 | Blob step; /* Text of previous revision */ |
| 2087 | int rid; /* Artifact ID of the file being annotated */ |
| 2088 | Stmt q; /* Query returning all ancestor versions */ |
| @@ -2095,11 +2096,11 @@ | |
| 2096 | } |
| 2097 | if( !content_get(rid, &toAnnotate) ){ |
| 2098 | fossil_fatal("unable to retrieve content of artifact #%d", rid); |
| 2099 | } |
| 2100 | if( iLimit<=0 ) iLimit = 1000000000; |
| 2101 | annotation_start(p, &toAnnotate, diffFlags); |
| 2102 | db_begin_transaction(); |
| 2103 | db_multi_exec( |
| 2104 | "CREATE TEMP TABLE IF NOT EXISTS vseen(rid INTEGER PRIMARY KEY);" |
| 2105 | "DELETE FROM vseen;" |
| 2106 | ); |
| @@ -2129,11 +2130,11 @@ | |
| 2130 | p->aVers[p->nVers].zMUuid = fossil_strdup(db_column_text(&q, 1)); |
| 2131 | p->aVers[p->nVers].zDate = fossil_strdup(db_column_text(&q, 2)); |
| 2132 | p->aVers[p->nVers].zUser = fossil_strdup(db_column_text(&q, 3)); |
| 2133 | if( p->nVers ){ |
| 2134 | content_get(rid, &step); |
| 2135 | annotation_step(p, &step, p->nVers-1, diffFlags); |
| 2136 | blob_reset(&step); |
| 2137 | } |
| 2138 | p->nVers++; |
| 2139 | db_bind_int(&ins, ":rid", rid); |
| 2140 | db_step(&ins); |
| @@ -2185,10 +2186,12 @@ | |
| 2186 | int fnid; |
| 2187 | int i; |
| 2188 | int iLimit; /* Depth limit */ |
| 2189 | int annFlags = ANN_FILE_ANCEST; |
| 2190 | int showLog = 0; /* True to display the log */ |
| 2191 | int ignoreWs = 0; /* Ignore whitespace */ |
| 2192 | u64 diffFlags = 0; /* diff flags for ignore whitespace */ |
| 2193 | const char *zFilename; /* Name of file to annotate */ |
| 2194 | const char *zCI; /* The check-in containing zFilename */ |
| 2195 | Annotator ann; |
| 2196 | HQuery url; |
| 2197 | struct AnnVers *p; |
| @@ -2204,26 +2207,40 @@ | |
| 2207 | zFilename = P("filename"); |
| 2208 | fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename); |
| 2209 | if( mid==0 || fnid==0 ){ fossil_redirect_home(); } |
| 2210 | iLimit = atoi(PD("limit","20")); |
| 2211 | if( P("filevers") ) annFlags |= ANN_FILE_VERS; |
| 2212 | ignoreWs = atoi(PD("w","0"))!=0; |
| 2213 | if( ignoreWs ) diffFlags |= (DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS); |
| 2214 | if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){ |
| 2215 | fossil_redirect_home(); |
| 2216 | } |
| 2217 | |
| 2218 | /* compute the annotation */ |
| 2219 | compute_direct_ancestors(mid, 10000000); |
| 2220 | annotate_file(&ann, fnid, mid, iLimit, annFlags, diffFlags); |
| 2221 | zCI = ann.aVers[0].zMUuid; |
| 2222 | |
| 2223 | /* generate the web page */ |
| 2224 | style_header("Annotation For %h", zFilename); |
| 2225 | if( bBlame ){ |
| 2226 | url_initialize(&url, "blame"); |
| 2227 | }else{ |
| 2228 | url_initialize(&url, "annotate"); |
| 2229 | } |
| 2230 | url_add_parameter(&url, "checkin", P("checkin")); |
| 2231 | url_add_parameter(&url, "filename", zFilename); |
| 2232 | if( iLimit!=20 ){ |
| 2233 | url_add_parameter(&url, "limit", sqlite3_mprintf("%d", iLimit)); |
| 2234 | } |
| 2235 | url_add_parameter(&url, "w", ignoreWs ? "1" : "0"); |
| 2236 | if( ignoreWs ){ |
| 2237 | style_submenu_element("Show Whitespace Changes", "Show Whitespace Changes", |
| 2238 | "%s", url_render(&url, "w", "0", 0, 0)); |
| 2239 | }else{ |
| 2240 | style_submenu_element("Ignore Whitespace", "Ignore Whitespace", |
| 2241 | "%s", url_render(&url, "w", "1", 0, 0)); |
| 2242 | } |
| 2243 | url_add_parameter(&url, "log", showLog ? "1" : "0"); |
| 2244 | if( showLog ){ |
| 2245 | style_submenu_element("Hide Log", "Hide Log", |
| 2246 | "%s", url_render(&url, "log", "0", 0, 0)); |
| @@ -2361,19 +2378,21 @@ | |
| 2378 | Annotator ann; /* The annotation of the file */ |
| 2379 | int i; /* Loop counter */ |
| 2380 | const char *zLimit; /* The value to the -n|--limit option */ |
| 2381 | int iLimit; /* How far back in time to look */ |
| 2382 | int showLog; /* True to show the log */ |
| 2383 | u64 diffFlags = 0;/* Flags to control whitespace handling */ |
| 2384 | int fileVers; /* Show file version instead of check-in versions */ |
| 2385 | int annFlags = 0; /* Flags to control annotation properties */ |
| 2386 | int bBlame = 0; /* True for BLAME output. False for ANNOTATE. */ |
| 2387 | |
| 2388 | bBlame = g.argv[1][0]=='b'; |
| 2389 | zLimit = find_option("limit","n",1); |
| 2390 | if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1"; |
| 2391 | iLimit = atoi(zLimit); |
| 2392 | showLog = find_option("log","l",0)!=0; |
| 2393 | if( find_option("w",0,0)!=0 ) diffFlags |= (DIFF_IGNORE_EOLWS|DIFF_IGNORE_SOLWS); |
| 2394 | fileVers = find_option("filevers",0,0)!=0; |
| 2395 | db_must_be_within_tree(); |
| 2396 | if( g.argc<3 ) { |
| 2397 | usage("FILENAME"); |
| 2398 | } |
| @@ -2399,11 +2418,11 @@ | |
| 2418 | fid, fnid); |
| 2419 | if( mid==0 ){ |
| 2420 | fossil_fatal("unable to find manifest"); |
| 2421 | } |
| 2422 | annFlags |= ANN_FILE_ANCEST; |
| 2423 | annotate_file(&ann, fnid, mid, iLimit, annFlags, diffFlags); |
| 2424 | if( showLog ){ |
| 2425 | struct AnnVers *p; |
| 2426 | for(p=ann.aVers, i=0; i<ann.nVers; i++, p++){ |
| 2427 | fossil_print("version %3d: %s %.10s file %.10s\n", |
| 2428 | i+1, p->zDate, p->zMUuid, p->zFUuid); |
| 2429 |