Diff
Not logged in

Differences From:

File src/timeline.c part of check-in [2fa4df1e47] - Add timeline links on the leaves page. Also on the leaves page, do not show Merge labels on check-ins. The second part is the fix for ticket d6bb26f436d8299f95d63f45fa51c92acdc91c5a. by drh on 2009-01-21 18:59:11. [view]

To:

File src/timeline.c part of check-in [42c2a18e73] - Change the way branches are tagged: The value of the "branch" property is used to identify the branch name. Repository rebuild required. Also, branches must be retagged. by drh on 2009-01-22 12:03:51. [view]

@@ -76,24 +76,26 @@
   }
 }
 
 /*
-** Count the number of non-branch children for the given check-in.
-** A non-branch child is a child that omits the "newbranch" tag.
+** Count the number of primary non-branch children for the given check-in.
+**
+** A primary child is one where the parent is the primary parent, not
+** a merge parent.
+**
+** A non-branch child is one which is on the same branch as the parent.
 */
 int count_nonbranch_children(int pid){
   int nNonBranch;
-
-  nNonBranch = db_int(0,
-    "SELECT count(*) FROM plink"
-    " WHERE pid=%d AND isprim"
-    "   AND NOT EXISTS(SELECT 1 FROM tagxref"
-                    "   WHERE tagid=%d"
-                    "     AND rid=cid"
-                    "     AND tagtype>0"
-                    " )",
-    pid, TAG_NEWBRANCH
-  );
+  static const char zSql[] =
+    @ SELECT count(*) FROM plink
+    @  WHERE pid=%d AND isprim
+    @    AND coalesce((SELECT value FROM tagxref
+    @                   WHERE tagid=%d AND rid=plink.pid), 'trunk')
+    @       =coalesce((SELECT value FROM tagxref
+    @                   WHERE tagid=%d AND rid=plink.cid), 'trunk')
+  ;
+  nNonBranch = db_int(0, zSql, pid, TAG_BRANCH, TAG_BRANCH);
   return nNonBranch;
 }
 
 /*
@@ -242,8 +244,9 @@
 ** Return a pointer to a constant string that forms the basis
 ** for a timeline query for the WWW interface.
 */
 const char *timeline_query_for_www(void){
+  static char *zBase = 0;
   static const char zBaseSql[] =
     @ SELECT
     @   blob.rid,
     @   uuid,
@@ -251,13 +254,14 @@
     @   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),
-    @   0==(SELECT count(*) FROM plink
-    @     WHERE pid=blob.rid AND isprim AND NOT EXISTS(
-    @       SELECT 1 FROM tagxref
-    @        WHERE tagid=(SELECT tagid FROM tag WHERE tagname='newbranch')
-    @          AND rid=plink.cid AND tagtype>0)),
+    @   NOT EXISTS(SELECT 1 FROM plink
+    @               WHERE pid=blob.rid
+    @                AND coalesce((SELECT value FROM tagxref
+    @                              WHERE tagid=%d AND rid=plink.pid), 'trunk')
+    @                  = coalesce((SELECT value FROM tagxref
+    @                              WHERE tagid=%d AND rid=plink.cid), 'trunk')),
     @   bgcolor,
     @   event.type,
     @   (SELECT group_concat(substr(tagname,5), ', ') FROM tag, tagxref
     @     WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid
@@ -264,9 +268,12 @@
     @       AND tagxref.rid=blob.rid AND tagxref.tagtype>0)
     @  FROM event JOIN blob
     @ WHERE blob.rid=event.objid
   ;
-  return zBaseSql;
+  if( zBase==0 ){
+    zBase = mprintf(zBaseSql, TAG_BRANCH, TAG_BRANCH);
+  }
+  return zBase;
 }
 
 /*
 ** Generate a submenu element with a single parameter change.