Diff
Not logged in

Differences From:

File src/descendents.c part of check-in [dbda8d6ce9] - Initial check-in of m1 sources. by drh on 2007-07-21 14:10:57. [view]

To:

File src/descendents.c part of check-in [afcdc7ec97] - Add the "leaves" webpage and the "branches" CLI command. We need to work on the nomenclature. by drh on 2007-08-01 12:49:41. [view]

@@ -66,9 +66,10 @@
 
 /*
 ** COMMAND:  leaves
 **
-** Find all leaf versions
+** Find all leaf descendents of the current version or of the
+** specified version.
 */
 void leaves_cmd(void){
   Stmt q;
   int base;
@@ -89,5 +90,59 @@
     " ORDER BY event.mtime DESC"
   );
   print_timeline(&q, 20);
   db_finalize(&q);
+}
+
+/*
+** COMMAND:  branches
+**
+** Find leaves of all branches.
+*/
+void branches_cmd(void){
+  Stmt q;
+  int base;
+
+  db_must_be_within_tree();
+  if( g.argc==2 ){
+    base = db_lget_int("checkout", 0);
+  }else{
+    base = name_to_rid(g.argv[2]);
+  }
+  if( base==0 ) return;
+  db_prepare(&q,
+    "SELECT blob.uuid, datetime(event.mtime,'localtime'), event.comment"
+    "  FROM blob, event"
+    " WHERE blob.rid IN"
+    "       (SELECT cid FROM plink EXCEPT SELECT pid FROM plink)"
+    "   AND event.objid=blob.rid"
+    " ORDER BY event.mtime DESC"
+  );
+  print_timeline(&q, 20);
+  db_finalize(&q);
+}
+
+/*
+** WEBPAGE:  leaves
+**
+** Find leaves of all branches.
+*/
+void branches_page(void){
+  Stmt q;
+
+  login_check_credentials();
+  if( !g.okRead ){ login_needed(); return; }
+
+  style_header("Leaves");
+  db_prepare(&q,
+    "SELECT blob.uuid, datetime(event.mtime,'localtime'),"
+    "       event.comment, event.user"
+    "  FROM blob, event"
+    " WHERE blob.rid IN"
+    "       (SELECT cid FROM plink EXCEPT SELECT pid FROM plink)"
+    "   AND event.objid=blob.rid"
+    " ORDER BY event.mtime DESC"
+  );
+  www_print_timeline(&q);
+  db_finalize(&q);
+  style_footer();
 }