Check-in [c1e85e4da5]
Not logged in
Overview

SHA1 Hash:c1e85e4da5d2bc81a8ddd533ce3101969750ea03
Date: 2008-07-13 12:08:47
User: drh
Comment:Fix the timeline command so that it work with --repository and -R.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/timeline.c from [3666af55b7] to [1f648196fc].

@@ -487,20 +487,15 @@
 */
 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);
     const char *zDate = db_column_text(q, 2);
@@ -527,19 +522,18 @@
     }
     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
 ** a timeline query for display on a TTY.
@@ -627,10 +621,13 @@
     if( mode==3 || mode==4 ){
       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);
     zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid);