Check-in [b7f32a71ab]
Not logged in
Overview

SHA1 Hash:b7f32a71ab78f3e9813e685fda37c0fc5937b05a
Date: 2009-01-20 22:21:24
User: drh
Comment:Add web-based branch color changer. Add the "branch list" command. Simplifications to color propagation logic.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/branch.c from [85e459979d] to [6b0cfa07af].

@@ -204,11 +204,20 @@
   }
   n = strlen(g.argv[2]);
   if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
     branch_new();
   }else if( n>=2 && strncmp(g.argv[2],"list",n)==0 ){
-    fossil_panic("branch list is not yet completed");
+    Stmt q;
+    db_prepare(&q,
+      "%s"
+      "   AND blob.rid IN (SELECT rid FROM tagxref"
+      "                     WHERE tagid=%d AND tagtype==1)"
+      " ORDER BY event.mtime DESC",
+      timeline_query_for_tty(), TAG_NEWBRANCH
+    );
+    print_timeline(&q, 2000);
+    db_finalize(&q);
   }else{
     fossil_panic("branch subcommand should be one of: "
                  "new list");
   }
 }

Modified src/checkin.c from [b983c3b208] to [58cd8b89db].

@@ -346,16 +346,16 @@
     g.aCommitFile[ii-2] = 0;
   }
 }
 
 /*
-** Return true if the check-in with RID=rid has one or more child
+** Return true if the check-in with RID=rid has no child
 ** check-ins which are not tagged with "newbranch".  In other words,
-** return true if the check-in is not a leaf.
+** return true if the check-in is a leaf.
 */
-int is_not_a_leaf(int rid){
-  return db_exists(
+int is_a_leaf(int rid){
+  return !db_exists(
     "SELECT 1 FROM plink"
     " WHERE pid=%d"
       " AND NOT EXIST("
                      "SELECT 1 FROM tagxref"
                      " WHERE tagxref.rid=plink.cid"
@@ -459,11 +459,11 @@
       fossil_panic("file %s has not changed", blob_str(&unmodified));
     }
   }
 
   vid = db_lget_int("checkout", 0);
-  if( is_not_a_leaf(vid) ){
+  if( !is_a_leaf(vid) ){
     wouldFork=1;
     if( forceFlag==0 ){
       fossil_fatal("would fork.  \"update\" first or use -f or --force.");
     }
   }

Modified src/descendants.c from [a19ebf91b9] to [6edb8b041e].

@@ -273,10 +273,21 @@
     style_submenu_element("Open", "Open", "leaves");
   }
   style_header("Leaves");
   login_anonymous_available();
   compute_leaves(0, showAll ? 0 : showClosed ? 2 : 1);
+  @ <table width="33%%" align="right" border="1">
+  @ <tr><td>
+  @ <b>Nomenclature:</b>
+  @ <ol>
+  @ <li> A <b>leaf</b> is a check-in with no descendants.</li>
+  @ <li> An <b>open leaf</b> is a leaf that does not have a "closed" tag
+  @ and is thus assumed to still be in use.</li>
+  @ <li> A <b>closed leaf</b> has a "closed" tag and is thus assumed to
+  @ be historical and no longer in active use.</li>
+  @ </ol>
+  @ </td></tr></table>
   if( showAll ){
     @ <h1>All leaves, both open and closed</h1>
   }else if( showClosed ){
     @ <h1>Closed leaves only</h1>
   }else{
@@ -288,13 +299,14 @@
     " ORDER BY event.mtime DESC",
     timeline_query_for_www()
   );
   www_print_timeline(&q);
   db_finalize(&q);
+  @ <br clear="both">
   @ <script>
   @ function xin(id){
   @ }
   @ function xout(id){
   @ }
   @ </script>
   style_footer();
 }

Modified src/info.c from [6aacb697cc] to [3249a68164].

@@ -1127,12 +1127,30 @@
   int rid;
   const char *zComment;
   const char *zNewComment;
   const char *zUser;
   const char *zNewUser;
+  const char *zColor;
+  const char *zNewColor;
+  int fPropagateColor;
   char *zUuid;
   Blob comment;
+  static const struct SampleColors {
+     const char *zCName;
+     const char *zColor;
+  } aColor[] = {
+     { "(none)",  "" },
+     { "#c0ffc0", "#c0ffc0" },
+     { "#c0fff0", "#c0fff0" },
+     { "#c0f0ff", "#c0f0ff" },
+     { "#d0c0ff", "#d0c0ff" },
+     { "#ffc0ff", "#ffc0ff" },
+     { "#ffc0d0", "#ffc0d0" },
+     { "#fff0c0", "#fff0c0" },
+     { "#f0ffc0", "#f0ffc0" },
+  };
+  int i;
 
   login_check_credentials();
   if( !g.okWrite ){ login_needed(); return; }
   rid = atoi(PD("r","0"));
   zComment = db_text(0, "SELECT coalesce(ecomment,comment)"
@@ -1141,10 +1159,14 @@
   zNewComment = PD("c",zComment);
   zUser = db_text(0, "SELECT coalesce(euser,user)"
                      "  FROM event WHERE objid=%d", rid);
   if( zUser==0 ) fossil_redirect_home();
   zNewUser = PD("u",zUser);
+  zColor = db_text("", "SELECT bgcolor"
+                        "  FROM event WHERE objid=%d", rid);
+  zNewColor = PD("clr",zColor);
+  fPropagateColor = P("pclr")!=0;
   zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
   if( P("cancel") ){
     cgi_redirectf("vinfo?name=%d", rid);
   }
   if( P("apply") ){
@@ -1155,17 +1177,29 @@
     login_verify_csrf_secret();
     blob_zero(&ctrl);
     zDate = db_text(0, "SELECT datetime('now')");
     zDate[10] = 'T';
     blob_appendf(&ctrl, "D %s\n", zDate);
+    if( zNewColor[0] && strcmp(zColor,zNewColor)!=0 ){
+      nChng++;
+      if( fPropagateColor ){
+        blob_appendf(&ctrl, "T *bgcolor %s %F\n", zUuid, zNewColor);
+      }else{
+        blob_appendf(&ctrl, "T +bgcolor %s %F\n", zUuid, zNewColor);
+      }
+    }
     if( strcmp(zComment,zNewComment)!=0 ){
       nChng++;
       blob_appendf(&ctrl, "T +comment %s %F\n", zUuid, zNewComment);
     }
     if( strcmp(zUser,zNewUser)!=0 ){
       nChng++;
       blob_appendf(&ctrl, "T +user %s %F\n", zUuid, zNewUser);
+    }
+    if( zNewColor[0]==0 && zColor[0]!=0 ){
+      nChng++;
+      blob_appendf(&ctrl, "T -bgcolor %s\n", zUuid);
     }
     if( nChng>0 ){
       int nrid;
       Blob cksum;
       blob_appendf(&ctrl, "U %F\n", g.zLogin);
@@ -1180,25 +1214,73 @@
   }
   blob_zero(&comment);
   blob_append(&comment, zNewComment, -1);
   zUuid[10] = 0;
   style_header("Edit Baseline [%s]", zUuid);
-  @ <p>Make changes to the User and Comment for baseline
-  @ [<a href="vinfo?name=%d(rid)">%s(zUuid)</a>] then press the
-  @ "Apply Changes" button.</p>
+  if( P("preview") ){
+    @ <b>Preview:</b>
+    @ <blockquote>
+    @ <table border=0>
+    if( zNewColor && zNewColor[0] ){
+      @ <tr><td bgcolor="%h(zNewColor)">
+    }else{
+      @ <tr><td>
+    }
+    wiki_convert(&comment, 0, WIKI_INLINE);
+    @ (user: %h(zNewUser))
+    @ </td></tr></table>
+    @ </blockquote>
+    @ <hr>
+  }
+  @ <p>Make changes to attributes of check-in
+  @ [<a href="vinfo?name=%d(rid)">%s(zUuid)</a>]:</p>
   @ <form action="%s(g.zBaseURL)/vedit" method="POST">
   login_insert_csrf_secret();
   @ <input type="hidden" name="r" value="%d(rid)">
-  @ <p>
-  @ <b>User:</b> <input type="text" name="u" size="20" value="%h(zNewUser)">
-  @ </p>
-  @ <p><b>Comment:</b></b><br />
-  wiki_convert(&comment, 0, WIKI_INLINE);
-  @ <br /><textarea name="c" rows="10" cols="80">%h(zNewComment)</textarea></p>
-  @ <blockquote>
+  @ <table border="0" cellspacing="10">
+
+  @ <tr><td align="right" valign="top"><b>User:</b></td>
+  @ <td valign="top">
+  @   <input type="text" name="u" size="20" value="%h(zNewUser)">
+  @ </td></tr>
+
+  @ <tr><td align="right" valign="top"><b>Comment:</b></td>
+  @ <td valign="top">
+  @ <textarea name="c" rows="10" cols="80">%h(zNewComment)</textarea>
+  @ </td></tr>
+
+  @ <tr><td align="right" valign="top"><b>Background Color:</b></td>
+  @ <td valign="top">
+  @ <table border=0 cellpadding=0 cellspacing=1>
+  @ <tr>
+  for(i=0; i<sizeof(aColor)/sizeof(aColor[0]); i++){
+    if( aColor[i].zColor[0] ){
+      @ <td bgcolor="%h(aColor[i].zColor)">
+    }else{
+      @ <td>
+    }
+    if( strcmp(zNewColor, aColor[i].zColor)==0 ){
+      @ <input type="radio" name="clr" value="%h(aColor[i].zColor)" checked>
+    }else{
+      @ <input type="radio" name="clr" value="%h(aColor[i].zColor)">
+    }
+    @ %h(aColor[i].zCName)</input></td>
+  }
+  @ </tr><tr><td colspan="9" align="left">
+  if( fPropagateColor ){
+    @ <input type="checkbox" name="pclr" checked>
+  }else{
+    @ <input type="checkbox" name="pclr">
+  }
+  @ Propagate color to descendants</input></td></tr>
+  @ </table>
+  @ </td></tr>
+
+  @ <tr><td colspan="2">
   @ <input type="submit" name="preview" value="Preview">
   @ <input type="submit" name="apply" value="Apply Changes">
   @ <input type="submit" name="cancel" value="Cancel">
-  @ </blockquote>
+  @ </td></tr>
+  @ </table>
   @ </form>
   style_footer();
 }

Modified src/manifest.c from [5a2927ef5a] to [632069e321].

@@ -915,19 +915,18 @@
         add_mlink(rid, &m, cid, 0);
       }
       db_finalize(&q);
       db_multi_exec(
         "REPLACE INTO event(type,mtime,objid,user,comment,"
-        "                  bgcolor,brbgcolor,euser,ecomment)"
+        "                  bgcolor,euser,ecomment)"
         "VALUES('ci',%.17g,%d,%Q,%Q,"
-        " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype=1),"
-        "(SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype!=1),"
+        " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>0),"
         "  (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),"
         "  (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));",
         m.rDate, rid, m.zUser, m.zComment,
         TAG_BGCOLOR, rid,
-        TAG_BGCOLOR, rid,
+        TAG_BRBGCOLOR, rid,
         TAG_USER, rid,
         TAG_COMMENT, rid
       );
     }
   }
@@ -984,14 +983,13 @@
       content_deltify(prior, rid, 0);
     }
     zComment = mprintf("Changes to wiki page [%h]", m.zWikiTitle);
     db_multi_exec(
       "REPLACE INTO event(type,mtime,objid,user,comment,"
-      "                  bgcolor,brbgcolor,euser,ecomment)"
+      "                  bgcolor,euser,ecomment)"
       "VALUES('w',%.17g,%d,%Q,%Q,"
-      "  (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype=1),"
-      "  (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype!=1),"
+      "  (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>1),"
       "  (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),"
       "  (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));",
       m.rDate, rid, m.zUser, zComment,
       TAG_BGCOLOR, rid,
       TAG_BGCOLOR, rid,

Modified src/schema.c from [aef0575363] to [8049a3c05c].

@@ -225,11 +225,10 @@
 @   type TEXT,                      -- Type of event
 @   mtime DATETIME,                 -- Date and time when the event occurs
 @   objid INTEGER PRIMARY KEY,      -- Associated record ID
 @   uid INTEGER REFERENCES user,    -- User who caused the event
 @   bgcolor TEXT,                   -- Color set by 'bgcolor' property
-@   brbgcolor TEXT,                 -- Color set by 'br-bgcolor' property
 @   euser TEXT,                     -- User set by 'user' property
 @   user TEXT,                      -- Name of the user
 @   ecomment TEXT,                  -- Comment set by 'comment' property
 @   comment TEXT                    -- Comment describing the event
 @ );
@@ -328,20 +327,21 @@
 /*
 ** Predefined tagid values
 */
 #if INTERFACE
 # define TAG_BGCOLOR    1     /* Set the background color for display */
-# define TAG_COMMENT    2     /* The check-in comment */
-# define TAG_USER       3     /* User who made a checking */
-# define TAG_HIDDEN     4     /* Do not display or sync */
-# define TAG_PRIVATE    5     /* Display but do not sync */
-# define TAG_CLUSTER    6     /* A cluster */
-# define TAG_NEWBRANCH  7     /* First check-in of a new named branch */
-# define TAG_CLOSED     8     /* Do not display this check-in as a leaf */
+# define TAG_BRBGCOLOR  2     /* Background color for branches */
+# define TAG_COMMENT    3     /* The check-in comment */
+# define TAG_USER       4     /* User who made a checking */
+# define TAG_HIDDEN     5     /* Do not display or sync */
+# define TAG_PRIVATE    6     /* Display but do not sync */
+# define TAG_CLUSTER    7     /* A cluster */
+# define TAG_NEWBRANCH  8     /* First check-in of a new named branch */
+# define TAG_CLOSED     9     /* Do not display this check-in as a leaf */
 #endif
 #if EXPORT_INTERFACE
-# define MAX_INT_TAG    8     /* The largest pre-assigned tag id */
+# define MAX_INT_TAG    9     /* The largest pre-assigned tag id */
 #endif
 
 /*
 ** The schema for the locate FOSSIL database file found at the root
 ** of very check-out.  This database contains the complete state of

Modified src/tag.c from [6980217297] to [4892a40848].

@@ -71,11 +71,11 @@
        "DELETE FROM tagxref WHERE tagid=%d AND rid=:rid", tagid
     );
   }
   if( tagid==TAG_BGCOLOR ){
     db_prepare(&eventupdate,
-      "UPDATE event SET brbgcolor=%Q WHERE objid=:rid", zValue
+      "UPDATE event SET bgcolor=%Q WHERE objid=:rid", zValue
     );
   }
   while( (pid = pqueue_extract(&queue))!=0 ){
     db_bind_int(&s, ":pid", pid);
     while( db_step(&s)==SQLITE_ROW ){
@@ -184,15 +184,11 @@
     zValue = 0;
   }
   zCol = 0;
   switch( tagid ){
     case TAG_BGCOLOR: {
-      if( tagtype==1 ){
-        zCol = "bgcolor";
-      }else{
-        zCol = "brbgcolor";
-      }
+      zCol = "bgcolor";
       break;
     }
     case TAG_COMMENT: {
       zCol = "ecomment";
       break;

Modified src/tagview.c from [748f6b35d4] to [3ccdf1ea64].

@@ -168,21 +168,23 @@
 #undef TAGVIEW_DEFAULT_FILTER
 
 /*
 ** Generate a timeline for the chosen tag
 */
-void tagview_print_timeline(char const *pName, char const *pPrefix){
+void tagview_print_timeline(char const *zName, char const *zPrefix){
   char *zSql;
   Stmt q;
+  int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='%q%q'",
+                        zPrefix, zName);
   zSql = mprintf("%s AND EXISTS (SELECT 1"
          " FROM tagxref"
          "  WHERE tagxref.rid = event.objid"
          "  AND tagxref.tagtype > 0"
-         "  AND tagxref.tagid = (SELECT tagid FROM tag"
-         "      WHERE tagname = %Q||%Q))"
+         "  AND tagxref.tagid = %d"
          " ORDER BY 3 desc",
-         timeline_query_for_www(), pPrefix, pName);
+         timeline_query_for_www(), tagid
+  );
   db_prepare(&q, zSql);
   free(zSql);
   www_print_timeline(&q);
   db_finalize(&q);
 }

Modified src/timeline.c from [79dd0c4340] to [c3f7f3d73d].

@@ -111,11 +111,11 @@
 **    8.  background color
 **    9.  type ("ci", "w")
 **   10.  list of symbolic tags.
 */
 void www_print_timeline(
-  Stmt *pQuery
+  Stmt *pQuery          /* Query to implement the timeline */
 ){
   int wikiFlags;
   int mxWikiLen;
   Blob comment;
   char zPrevDate[20];
@@ -235,11 +235,11 @@
     @   coalesce(ecomment, comment),
     @   coalesce(euser, user),
     @   (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim=1),
     @   (SELECT count(*) FROM plink WHERE cid=blob.rid),
     @   NOT EXISTS (SELECT 1 FROM plink WHERE pid=blob.rid),
-    @   coalesce(bgcolor, brbgcolor),
+    @   bgcolor,
     @   event.type,
     @   (SELECT group_concat(substr(tagname,5), ', ') FROM tag, tagxref
     @     WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid
     @       AND tagxref.rid=blob.rid AND tagxref.tagtype>0)
     @  FROM event JOIN blob