Diff
Not logged in

Differences From:

File src/timeline.c part of check-in [e319e8e870] - Improvements to timeline formatting. Added the "concepts.html" document. by drh on 2007-08-25 03:30:15. Also file src/timeline.c part of check-in [424d47e453] - Attempting the same merge that aku tried and got empty files with. by drh on 2007-08-25 18:58:16. [view]

To:

File src/timeline.c part of check-in [b846db063c] - 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. by drh on 2007-08-25 18:51:54. Also file src/timeline.c part of check-in [b0ad3f90bc] - Merging aku's changes into the head. by drh on 2007-08-25 19:00:33. [view]

@@ -164,11 +164,14 @@
   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) ){
@@ -177,9 +180,23 @@
       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);
   }
 }
 
 
@@ -198,9 +215,9 @@
 */
 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 ){
@@ -216,10 +233,12 @@
   }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