Diff
Not logged in

Differences From:

File src/info.c part of check-in [d5695157d0] - Deal with windows filename aliasing in the "all" command. Ticket 974618fe5a8. Also display the home directory for windows users with the "info" command since the home directory is non-obvious in windows. by drh on 2009-11-11 16:21:19. [view]

To:

File src/info.c part of check-in [9d3fe01ae3] - Fix an invalid free() call that could occur when the "info" command was used with an invalid artifact ID. Ticket aa8ba0fffa. by drh on 2009-12-27 18:19:38. Also file src/info.c part of check-in [76bc05d739] - merge with trunk by btheado on 2009-12-30 20:33:59. [view]

@@ -28,8 +28,26 @@
 #include "config.h"
 #include "info.h"
 #include <assert.h>
 
+/*
+** Return a string (in memory obtained from malloc) holding a
+** comma-separated list of tags that apply to check-in with
+** record-id rid.
+**
+** Return NULL if there are no such tags.
+*/
+char *info_tags_of_checkin(int rid){
+  char *zTags;
+  zTags = db_text(0, "SELECT group_concat(substr(tagname, 5), ', ')"
+                     "  FROM tagxref, tag"
+                     " WHERE tagxref.rid=%d AND tagxref.tagtype>0"
+                     "   AND tag.tagid=tagxref.tagid"
+                     "   AND tag.tagname GLOB 'sym-*'",
+                     rid);
+  return zTags;
+}
+
 
 /*
 ** Print common information about a particular record.
 **
@@ -45,14 +63,14 @@
   char *zDate;
   char *zUuid;
   zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
   if( zUuid ){
-    zDate = db_text("",
+    zDate = db_text(0,
       "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
       rid
     );
          /* 01234567890123 */
-    printf("%-13s %s %s\n", zUuidName, zUuid, zDate);
+    printf("%-13s %s %s\n", zUuidName, zUuid, zDate ? zDate : "");
     free(zUuid);
     free(zDate);
   }
   db_prepare(&q, "SELECT uuid, pid FROM plink JOIN blob ON pid=rid "
@@ -78,14 +96,9 @@
     printf("child:        %s %s\n", zUuid, zDate);
     free(zDate);
   }
   db_finalize(&q);
-  zTags = db_text(0, "SELECT group_concat(substr(tagname, 5), ', ')"
-                     "  FROM tagxref, tag"
-                     " WHERE tagxref.rid=%d AND tagxref.tagtype>0"
-                     "   AND tag.tagid=tagxref.tagid"
-                     "   AND tag.tagname GLOB 'sym-*'",
-                     rid);
+  zTags = info_tags_of_checkin(rid);
   if( zTags && zTags[0] ){
     printf("tags:         %s\n", zTags);
   }
   free(zTags);
@@ -234,17 +247,28 @@
 ** WEBPAGE: ci
 ** URL:  /ci?name=RID|ARTIFACTID
 **
 ** Display information about a particular check-in.
+**
+** We also jump here from /info if the name is a version.
+**
+** If the /ci page is used (instead of /vinfo or /info) then the
+** default behavior is to show unified diffs of all file changes.
+** With /vinfo and /info, only a list of the changed files are
+** shown, without diffs.  This behavior is inverted if the
+** "show-version-diffs" setting is turned on.
 */
 void ci_page(void){
   Stmt q;
   int rid;
   int isLeaf;
+  int showDiff;
+  const char *zName;
 
   login_check_credentials();
   if( !g.okRead ){ login_needed(); return; }
-  rid = name_to_rid(PD("name","0"));
+  zName = PD("name","0");
+  rid = name_to_rid(zName);
   if( rid==0 ){
     style_header("Check-in Information Error");
     @ No such object: %h(g.argv[2])
     style_footer();
@@ -286,14 +310,14 @@
     @ </td></tr>
     @ <tr><th>Date:</th><td>
     hyperlink_to_date(zDate, "</td></tr>");
     if( zEUser ){
-      @ <tr><th>Edited&nbsp;User:</td><td>
+      @ <tr><th>Edited&nbsp;User:</th><td>
       hyperlink_to_user(zEUser,zDate,"</td></tr>");
       @ <tr><th>Original&nbsp;User:</th><td>
       hyperlink_to_user(zUser,zDate,"</td></tr>");
     }else{
-      @ <tr><th>User:</td><td>
+      @ <tr><th>User:</th><td>
       hyperlink_to_user(zUser,zDate,"</td></tr>");
     }
     if( zEComment ){
       @ <tr><th>Edited&nbsp;Comment:</th><td>%w(zEComment)</td></tr>
@@ -300,9 +324,8 @@
       @ <tr><th>Original&nbsp;Comment:</th><td>%w(zComment)</td></tr>
     }else{
       @ <tr><th>Comment:</th><td>%w(zComment)</td></tr>
     }
-    @ </td></tr>
     if( g.okAdmin ){
       db_prepare(&q,
          "SELECT rcvfrom.ipaddr, user.login, datetime(rcvfrom.mtime)"
          "  FROM blob JOIN rcvfrom USING(rcvid) LEFT JOIN user USING(uid)"
@@ -356,8 +379,23 @@
   }
   db_finalize(&q);
   showTags(rid, "");
   @ <div class="section">Changes</div>
+  showDiff = g.zPath[0]!='c';
+  if( db_get_boolean("show-version-diffs", 0)==0 ){
+    showDiff = !showDiff;
+    if( showDiff ){
+      @ <a href="%s(g.zBaseURL)/vinfo/%T(zName)">[hide&nbsp;diffs]</a><br/>
+    }else{
+      @ <a href="%s(g.zBaseURL)/ci/%T(zName)">[show&nbsp;diffs]</a><br/>
+    }
+  }else{
+    if( showDiff ){
+      @ <a href="%s(g.zBaseURL)/ci/%T(zName)">[hide&nbsp;diffs]</a><br/>
+    }else{
+      @ <a href="%s(g.zBaseURL)/vinfo/%T(zName)">[show&nbsp;diffs]</a><br/>
+    }
+  }
   db_prepare(&q,
      "SELECT pid, fid, name, substr(a.uuid,1,10), substr(b.uuid,1,10)"
      "  FROM mlink JOIN filename ON filename.fnid=mlink.fnid"
      "         LEFT JOIN blob a ON a.rid=pid"
@@ -381,9 +419,13 @@
       }
     }else if( zOld && zNew ){
       @ <p>Modified <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
       @ from <a href="%s(g.zBaseURL)/artifact/%s(zOld)">[%s(zOld)]</a>
-      @ to <a href="%s(g.zBaseURL)/artifact/%s(zNew)">[%s(zNew)]</a></p>
+      @ to <a href="%s(g.zBaseURL)/artifact/%s(zNew)">[%s(zNew)].</a>
+      if( !showDiff ){
+        @ &nbsp;&nbsp;
+        @ <a href="%s(g.zBaseURL)/fdiff?v1=%d(pid)&v2=%d(fid)">[diff]</a>
+      }
     }else if( zOld ){
       @ <p>Deleted <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
       @ version <a href="%s(g.zBaseURL)/artifact/%s(zOld)">[%s(zOld)]</a></p>
       continue;
@@ -390,11 +432,13 @@
     }else{
       @ <p>Added <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
       @ version <a href="%s(g.zBaseURL)/artifact/%s(zNew)">[%s(zNew)]</a></p>
     }
-    @ <blockquote><pre>
-    append_diff(pid, fid);
-    @ </pre></blockquote>
+    if( showDiff ){
+      @ <blockquote><pre>
+      append_diff(pid, fid);
+      @ </pre></blockquote>
+    }
   }
   db_finalize(&q);
   style_footer();
 }