Check-in [b846db063c]
Not logged in
Overview

SHA1 Hash:b846db063c4caeed23b15d84b13be7f2e2c2f17d
Date: 2007-08-25 18:51:54
User: drh
Comment:Changes to the CLI version of the timeline command to show places where forks occur in the tree and where content is merged. Lots more work is needed to show the structure of a tree well. This is definitely a work in progress.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/descendents.c from [6273899c23] to [5d5c8b9dec].

@@ -82,11 +82,12 @@
     base = name_to_rid(g.argv[2]);
   }
   if( base==0 ) return;
   compute_leaves(base);
   db_prepare(&q,
-    "SELECT uuid, datetime(event.mtime,'localtime'), comment"
+    "SELECT blob.rid, uuid, datetime(event.mtime,'localtime'), comment, 0,"
+    "       (SELECT count(*) FROM plink WHERE cid=blob.rid)"
     "  FROM leaves, blob, event"
     " WHERE blob.rid=leaves.rid"
     "   AND event.objid=leaves.rid"
     " ORDER BY event.mtime DESC"
   );
@@ -103,11 +104,13 @@
 void branches_cmd(void){
   Stmt q;
 
   db_must_be_within_tree();
   db_prepare(&q,
-    "SELECT blob.uuid, datetime(event.mtime,'localtime'), event.comment"
+    "SELECT blob.rid, blob.uuid, datetime(event.mtime,'localtime'),"
+    "       event.comment, 0,"
+    "       (SELECT count(*) FROM plink WHERE cid=blob.rid)"
     "  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"

Modified src/timeline.c from [f946387177] to [7640f70a07].

@@ -163,13 +163,16 @@
   int nLine = 0;
   char zPrevDate[20];
   zPrevDate[0] = 0;
 
   while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){
-    const char *zId = db_column_text(q, 0);
-    const char *zDate = db_column_text(q, 1);
-    const char *zCom = db_column_text(q, 2);
+    const char *zId = db_column_text(q, 1);
+    const char *zDate = db_column_text(q, 2);
+    const char *zCom = db_column_text(q, 3);
+    int nChild = db_column_int(q, 4);
+    int nParent = db_column_int(q, 5);
+    char *zFree = 0;
     char zUuid[UUID_SIZE+1];
 
     sprintf(zUuid, "%.10s", zId);
     if( memcmp(zDate, zPrevDate, 10) ){
       printf("=== %.10s ===\n", zDate);
@@ -176,11 +179,25 @@
       memcpy(zPrevDate, zDate, 10);
       nLine++;
     }
     if( zCom==0 ) zCom = "";
     printf("%.5s [%.10s] ", &zDate[11], zUuid);
+    if( nChild>1 || nParent>1 ){
+      int n = 0;
+      char zPrefix[50];
+      if( nParent>1 ){
+        sqlite3_snprintf(sizeof(zPrefix), zPrefix, "*MERGE* ");
+        n = strlen(zPrefix);
+      }
+      if( nChild>1 ){
+        sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*FORK* ");
+        n = strlen(zPrefix);
+      }
+      zCom = zFree = sqlite3_mprintf("%s%s", zPrefix, zCom);
+    }
     nLine += comment_print(zCom, 19, 79);
+    sqlite3_free(zFree);
   }
 }
 
 
 /*
@@ -197,11 +214,11 @@
 ** Times are according to the local timezone.
 */
 void timeline_cmd(void){
   Stmt q;
   int n;
-  char *zCount;
+  const char *zCount;
   char *zDate;
   db_find_and_open_repository();
   zCount = find_option("n","count",1);
   if( zCount ){
     n = atoi(zCount);
@@ -215,15 +232,17 @@
     zDate = g.argv[2];
   }else{
     zDate = "now";
   }
   db_prepare(&q,
-    "SELECT uuid, datetime(event.mtime,'localtime'),"
-    "       comment || ' (by ' || user || ')'"
+    "SELECT blob.rid, uuid, datetime(event.mtime,'localtime'),"
+    "       comment || ' (by ' || user || ')',"
+    "       (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim),"
+    "       (SELECT count(*) FROM plink WHERE cid=blob.rid)"
     "  FROM event, blob"
     " WHERE event.type='ci' AND blob.rid=event.objid"
     "   AND event.mtime<=(SELECT julianday(%Q,'utc'))"
     " ORDER BY event.mtime DESC", zDate
   );
   print_timeline(&q, n);
   db_finalize(&q);
 }