Index: src/branch.c
==================================================================
--- src/branch.c
+++ src/branch.c
@@ -205,16 +205,17 @@
if( g.localOpen ){
vid = db_lget_int("checkout", 0);
zCurrent = db_text(0, "SELECT value FROM tagxref"
" WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH);
}
- compute_leaves(0, 1);
db_prepare(&q,
"SELECT DISTINCT value FROM tagxref"
- " WHERE tagid=%d AND value NOT NULL AND rid IN leaves"
+ " WHERE tagid=%d AND value NOT NULL"
+ " AND rid IN leaf"
+ " AND NOT %z"
" ORDER BY value /*sort*/",
- TAG_BRANCH
+ TAG_BRANCH, leaf_is_closed_sql("tagxref.rid")
);
while( db_step(&q)==SQLITE_ROW ){
const char *zBr = db_column_text(&q, 0);
int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
printf("%s%s\n", (isCur ? "* " : " "), zBr);
@@ -245,11 +246,10 @@
style_submenu_element("Open","Open","brlist");
}else{
style_submenu_element("Closed","Closed","brlist?closed");
}
login_anonymous_available();
- compute_leaves(0, 1);
style_sidebox_begin("Nomenclature:", "33%");
@
@ - An is a branch that has one or
@ more open leaves.
@@ -263,30 +263,18 @@
@ reopened)
@
style_sidebox_end();
cnt = 0;
- if( !showClosed ){
- db_prepare(&q,
- "SELECT DISTINCT value FROM tagxref"
- " WHERE tagid=%d AND value NOT NULL"
- " AND rid IN leaves"
- " ORDER BY value /*sort*/",
- TAG_BRANCH
- );
- }else{
- db_prepare(&q,
- "SELECT value FROM tagxref"
- " WHERE tagid=%d AND value NOT NULL"
- " EXCEPT "
- "SELECT value FROM tagxref"
- " WHERE tagid=%d AND value NOT NULL"
- " AND rid IN leaves"
- " ORDER BY value /*sort*/",
- TAG_BRANCH, TAG_BRANCH
- );
- }
+ db_prepare(&q,
+ "SELECT DISTINCT value FROM tagxref"
+ " WHERE tagid=%d AND value NOT NULL"
+ " AND rid IN leaf"
+ " AND %s %z"
+ " ORDER BY value /*sort*/",
+ TAG_BRANCH, showClosed ? "" : "NOT", leaf_is_closed_sql("tagxref.rid")
+ );
while( db_step(&q)==SQLITE_ROW ){
const char *zBr = db_column_text(&q, 0);
if( cnt==0 ){
if( showClosed ){
@ Closed Branches:
Index: src/db.c
==================================================================
--- src/db.c
+++ src/db.c
@@ -123,10 +123,11 @@
if( nBegin<=0 ) return;
if( rollbackFlag ) doRollback = 1;
nBegin--;
if( nBegin==0 ){
int i;
+ if( doRollback==0 ) leaf_do_pending_checks();
for(i=0; doRollback==0 && i0 ){
Bag seen; /* Descendants seen */
Bag pending; /* Unpropagated descendants */
Stmt q1; /* Query to find children of a check-in */
Stmt isBr; /* Query to check to see if a check-in starts a new branch */
Stmt ins; /* INSERT statement for a new record */
@@ -262,24 +249,33 @@
** Usage: %fossil leaves ?--all? ?--closed?
**
** Find leaves of all branches. By default show only open leaves.
** The --all flag causes all leaves (closed and open) to be shown.
** The --closed flag shows only closed leaves.
+**
+** The --recompute flag causes the content of the "leaf" table in the
+** repository database to be recomputed.
*/
void leaves_cmd(void){
Stmt q;
+ Blob sql;
int showAll = find_option("all", 0, 0)!=0;
int showClosed = find_option("closed", 0, 0)!=0;
+ int recomputeFlag = find_option("recompute",0,0)!=0;
db_must_be_within_tree();
- compute_leaves(0, showAll ? 0 : showClosed ? 2 : 1);
- db_prepare(&q,
- "%s"
- " AND blob.rid IN leaves"
- " ORDER BY event.mtime DESC",
- timeline_query_for_tty()
- );
+ if( recomputeFlag ) leaf_rebuild();
+ blob_zero(&sql);
+ blob_append(&sql, timeline_query_for_tty(), -1);
+ blob_appendf(&sql, " AND blob.rid IN leaf");
+ if( showClosed ){
+ blob_appendf(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
+ }else if( !showAll ){
+ blob_appendf(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
+ }
+ db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_str(&sql));
+ blob_reset(&sql);
print_timeline(&q, 2000);
db_finalize(&q);
}
/*
@@ -297,10 +293,11 @@
** WEBPAGE: leaves
**
** Find leaves of all branches.
*/
void leaves_page(void){
+ Blob sql;
Stmt q;
int showAll = P("all")!=0;
int showClosed = P("closed")!=0;
login_check_credentials();
@@ -315,11 +312,10 @@
if( showClosed || showAll ){
style_submenu_element("Open", "Open", "leaves");
}
style_header("Leaves");
login_anonymous_available();
- compute_leaves(0, showAll ? 0 : showClosed ? 2 : 1);
style_sidebox_begin("Nomenclature:", "33%");
@
@ - A
leaf
@ is a check-in with no descendants in the same branch.
@ - An
open leaf
@@ -336,16 +332,20 @@
}else if( showClosed ){
@ Closed leaves:
}else{
@ Open leaves:
}
- db_prepare(&q,
- "%s"
- " AND blob.rid IN leaves"
- " ORDER BY event.mtime DESC",
- timeline_query_for_www()
- );
+ blob_zero(&sql);
+ blob_append(&sql, timeline_query_for_www(), -1);
+ blob_appendf(&sql, " AND blob.rid IN leaf");
+ if( showClosed ){
+ blob_appendf(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
+ }else if( !showAll ){
+ blob_appendf(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
+ }
+ db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_str(&sql));
+ blob_reset(&sql);
www_print_timeline(&q, TIMELINE_LEAFONLY, 0, 0, leaves_extra);
db_finalize(&q);
@
@