Differences From:
File
src/checkin.c
part of check-in
[8d5ab7913e]
- Do not print a warning about "a fork has occurred" when checking in to
a leaf that is also the basis of a branch.
by
drh on
2009-01-21 03:12:14.
[view]
To:
File
src/checkin.c
part of check-in
[faf09dc7ae]
- Define a "leaf" as a check-in with no children in the same branch. The
is_a_leaf() function does some complicated SQL to figure this out.
by
drh on
2009-01-22 01:53:04.
[view]
@@ -347,24 +347,43 @@
}
}
/*
-** 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 a leaf.
+** Return true if the check-in with RID=rid is a leaf.
+**
+** A leaf has no children in the same branch. For the purposes of
+** this definition, a two check-ins are in same branch they have the
+** same set of propagated symbolic tags.
*/
int is_a_leaf(int rid){
- return !db_exists(
- "SELECT 1 FROM plink"
- " WHERE pid=%d"
- " AND NOT EXISTS("
- "SELECT 1 FROM tagxref"
- " WHERE tagxref.rid=plink.cid"
- " AND tagxref.tagid=%d"
- " AND tagxref.tagtype=1"
- ")",
- rid, TAG_NEWBRANCH
- );
+
+ /* This query selects all children in the same branch as rid */
+ static const char zSql[] =
+ @ SELECT cid FROM plink
+ @ WHERE pid=:rid
+ @ AND (SELECT group_concat(x) FROM (
+ @ SELECT tag.tagid AS x FROM tagxref, tag
+ @ WHERE tagxref.rid=:rid AND tagxref.tagtype=2
+ @ AND tag.tagid=tagxref.tagid AND tagxref.srcid=0
+ @ AND tag.tagname GLOB 'sym-*'
+ @ ORDER BY 1)
+ @ ) ==
+ @ (SELECT group_concat(x) FROM (
+ @ SELECT tag.tagid AS x FROM tagxref, tag
+ @ WHERE tagxref.rid=plink.cid AND tagxref.tagtype=2
+ @ AND tag.tagid=tagxref.tagid
+ @ AND tag.tagname GLOB 'sym-*'
+ @ ORDER BY 1)
+ @ )
+ ;
+ Stmt q; /* The prepared statement */
+ int rc; /* Return code from stepping the prepared statement */
+
+ db_prepare(&q, zSql);
+ db_bind_int(&q, ":rid", rid);
+ rc = db_step(&q);
+ db_finalize(&q);
+ return rc==SQLITE_DONE;
}
/*
** COMMAND: ci