Diff
Not logged in

Differences From:

File src/timeline.c part of check-in [6458f020fc] - Change the spelling of "descendant" to use the -ant suffix everywhere, including in the filename "descendant.c". The adjective form can be spelled either -ant or -ent, but the noun form requires -ant, or so says American Heritage. by drh on 2008-05-14 02:03:45. [view]

To:

File src/timeline.c part of check-in [c1e85e4da5] - Fix the timeline command so that it work with --repository and -R. by drh on 2008-07-13 12:08:47. [view]

@@ -488,18 +488,13 @@
 void print_timeline(Stmt *q, int mxLine){
   int nLine = 0;
   char zPrevDate[20];
   const char *zCurrentUuid=0;
-  Stmt currentQ;
-  int rid = db_lget_int("checkout", 0);
   zPrevDate[0] = 0;
 
-  db_prepare(&currentQ,
-    "SELECT uuid"
-    "  FROM blob WHERE rid=%d", rid
-  );
-  if( db_step(&currentQ)==SQLITE_ROW ){
-    zCurrentUuid = db_column_text(&currentQ, 0);
+  if( g.localOpen ){
+    int rid = db_lget_int("checkout", 0);
+    zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
   }
 
   while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){
     const char *zId = db_column_text(q, 1);
@@ -528,17 +523,16 @@
     if( nChild>1 ){
       sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*FORK* ");
       n = strlen(zPrefix);
     }
-    if( strcmp(zCurrentUuid,zId)==0 ){
+    if( zCurrentUuid && strcmp(zCurrentUuid,zId)==0 ){
       sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
       n += strlen(zPrefix);
     }
     zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
     nLine += comment_print(zFree, 9, 79);
     sqlite3_free(zFree);
   }
-  db_finalize(&currentQ);
 }
 
 /*
 ** Return a pointer to a static string that forms the basis for
@@ -628,8 +622,11 @@
       fossil_fatal("cannot compute descendants or ancestors of a date");
     }
     zDate = mprintf("(SELECT datetime('now'))");
   }else if( strncmp(zOrigin, "current", k)==0 ){
+    if( !g.localOpen ){
+      fossil_fatal("must be within a local checkout to use 'current'");
+    }
     objid = db_lget_int("checkout",0);
     zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid);
   }else if( name_to_uuid(&uuid, 0)==0 ){
     objid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &uuid);