Fossil SCM

Comment and documentation updates on the tagging mechanism. No substantive code changes.

drh 2011-02-25 14:20 trunk
Commit 80f89e3feb07d85d8bdadf70dbec150178987e87
+1 -1
--- src/schema.c
+++ src/schema.c
@@ -314,11 +314,11 @@
314314
@ -- tags here. These are really properties. But we are going to
315315
@ -- keep calling them tags because in many cases the value is ignored.
316316
@ --
317317
@ CREATE TABLE tagxref(
318318
@ tagid INTEGER REFERENCES tag, -- The tag that added or removed
319
-@ tagtype INTEGER, -- 0:cancel 1:single 2:branch
319
+@ tagtype INTEGER, -- 0:-,cancel 1:+,single 2:*,propagate
320320
@ srcid INTEGER REFERENCES blob, -- Artifact of tag. 0 for propagated tags
321321
@ origid INTEGER REFERENCES blob, -- check-in holding propagated tag
322322
@ value TEXT, -- Value of the tag. Might be NULL.
323323
@ mtime TIMESTAMP, -- Time of addition or removal
324324
@ rid INTEGER REFERENCE blob, -- Artifact tag is applied to
325325
--- src/schema.c
+++ src/schema.c
@@ -314,11 +314,11 @@
314 @ -- tags here. These are really properties. But we are going to
315 @ -- keep calling them tags because in many cases the value is ignored.
316 @ --
317 @ CREATE TABLE tagxref(
318 @ tagid INTEGER REFERENCES tag, -- The tag that added or removed
319 @ tagtype INTEGER, -- 0:cancel 1:single 2:branch
320 @ srcid INTEGER REFERENCES blob, -- Artifact of tag. 0 for propagated tags
321 @ origid INTEGER REFERENCES blob, -- check-in holding propagated tag
322 @ value TEXT, -- Value of the tag. Might be NULL.
323 @ mtime TIMESTAMP, -- Time of addition or removal
324 @ rid INTEGER REFERENCE blob, -- Artifact tag is applied to
325
--- src/schema.c
+++ src/schema.c
@@ -314,11 +314,11 @@
314 @ -- tags here. These are really properties. But we are going to
315 @ -- keep calling them tags because in many cases the value is ignored.
316 @ --
317 @ CREATE TABLE tagxref(
318 @ tagid INTEGER REFERENCES tag, -- The tag that added or removed
319 @ tagtype INTEGER, -- 0:-,cancel 1:+,single 2:*,propagate
320 @ srcid INTEGER REFERENCES blob, -- Artifact of tag. 0 for propagated tags
321 @ origid INTEGER REFERENCES blob, -- check-in holding propagated tag
322 @ value TEXT, -- Value of the tag. Might be NULL.
323 @ mtime TIMESTAMP, -- Time of addition or removal
324 @ rid INTEGER REFERENCE blob, -- Artifact tag is applied to
325
+15 -5
--- src/tag.c
+++ src/tag.c
@@ -26,43 +26,53 @@
2626
**
2727
** This routine assumes that tagid is a tag that should be
2828
** propagated and that the tag is already present in pid.
2929
**
3030
** If tagtype is 2 then the tag is being propagated from an
31
-** ancestor node. If tagtype is 0 it means a branch tag is
32
-** being cancelled.
31
+** ancestor node. If tagtype is 0 it means a propagating tag is
32
+** being blocked.
3333
*/
3434
static void tag_propagate(
3535
int pid, /* Propagate the tag to children of this node */
3636
int tagid, /* Tag to propagate */
3737
int tagType, /* 2 for a propagating tag. 0 for an antitag */
3838
int origId, /* Artifact of tag, when tagType==2 */
3939
const char *zValue, /* Value of the tag. Might be NULL */
4040
double mtime /* Timestamp on the tag */
4141
){
42
- PQueue queue;
43
- Stmt s, ins, eventupdate;
42
+ PQueue queue; /* Queue of check-ins to be tagged */
43
+ Stmt s; /* Query the children of :pid to which to propagate */
44
+ Stmt ins; /* INSERT INTO tagxref */
45
+ Stmt eventupdate; /* UPDATE event */
4446
4547
assert( tagType==0 || tagType==2 );
4648
pqueue_init(&queue);
4749
pqueue_insert(&queue, pid, 0.0);
50
+
51
+ /* Query for children of :pid to which to propagate the tag.
52
+ ** Three returns: (1) rid of the child. (2) timestamp of child.
53
+ ** (3) True to propagate or false to block.
54
+ */
4855
db_prepare(&s,
4956
"SELECT cid, plink.mtime,"
5057
" coalesce(srcid=0 AND tagxref.mtime<:mtime, %d) AS doit"
5158
" FROM plink LEFT JOIN tagxref ON cid=rid AND tagid=%d"
5259
" WHERE pid=:pid AND isprim",
53
- tagType!=0, tagid
60
+ tagType==2, tagid
5461
);
5562
db_bind_double(&s, ":mtime", mtime);
63
+
5664
if( tagType==2 ){
65
+ /* Set the propagated tag marker on checkin :rid */
5766
db_prepare(&ins,
5867
"REPLACE INTO tagxref(tagid, tagtype, srcid, origid, value, mtime, rid)"
5968
"VALUES(%d,2,0,%d,%Q,:mtime,:rid)",
6069
tagid, origId, zValue
6170
);
6271
db_bind_double(&ins, ":mtime", mtime);
6372
}else{
73
+ /* Remove all references to the tag from checkin :rid */
6474
zValue = 0;
6575
db_prepare(&ins,
6676
"DELETE FROM tagxref WHERE tagid=%d AND rid=:rid", tagid
6777
);
6878
}
6979
--- src/tag.c
+++ src/tag.c
@@ -26,43 +26,53 @@
26 **
27 ** This routine assumes that tagid is a tag that should be
28 ** propagated and that the tag is already present in pid.
29 **
30 ** If tagtype is 2 then the tag is being propagated from an
31 ** ancestor node. If tagtype is 0 it means a branch tag is
32 ** being cancelled.
33 */
34 static void tag_propagate(
35 int pid, /* Propagate the tag to children of this node */
36 int tagid, /* Tag to propagate */
37 int tagType, /* 2 for a propagating tag. 0 for an antitag */
38 int origId, /* Artifact of tag, when tagType==2 */
39 const char *zValue, /* Value of the tag. Might be NULL */
40 double mtime /* Timestamp on the tag */
41 ){
42 PQueue queue;
43 Stmt s, ins, eventupdate;
 
 
44
45 assert( tagType==0 || tagType==2 );
46 pqueue_init(&queue);
47 pqueue_insert(&queue, pid, 0.0);
 
 
 
 
 
48 db_prepare(&s,
49 "SELECT cid, plink.mtime,"
50 " coalesce(srcid=0 AND tagxref.mtime<:mtime, %d) AS doit"
51 " FROM plink LEFT JOIN tagxref ON cid=rid AND tagid=%d"
52 " WHERE pid=:pid AND isprim",
53 tagType!=0, tagid
54 );
55 db_bind_double(&s, ":mtime", mtime);
 
56 if( tagType==2 ){
 
57 db_prepare(&ins,
58 "REPLACE INTO tagxref(tagid, tagtype, srcid, origid, value, mtime, rid)"
59 "VALUES(%d,2,0,%d,%Q,:mtime,:rid)",
60 tagid, origId, zValue
61 );
62 db_bind_double(&ins, ":mtime", mtime);
63 }else{
 
64 zValue = 0;
65 db_prepare(&ins,
66 "DELETE FROM tagxref WHERE tagid=%d AND rid=:rid", tagid
67 );
68 }
69
--- src/tag.c
+++ src/tag.c
@@ -26,43 +26,53 @@
26 **
27 ** This routine assumes that tagid is a tag that should be
28 ** propagated and that the tag is already present in pid.
29 **
30 ** If tagtype is 2 then the tag is being propagated from an
31 ** ancestor node. If tagtype is 0 it means a propagating tag is
32 ** being blocked.
33 */
34 static void tag_propagate(
35 int pid, /* Propagate the tag to children of this node */
36 int tagid, /* Tag to propagate */
37 int tagType, /* 2 for a propagating tag. 0 for an antitag */
38 int origId, /* Artifact of tag, when tagType==2 */
39 const char *zValue, /* Value of the tag. Might be NULL */
40 double mtime /* Timestamp on the tag */
41 ){
42 PQueue queue; /* Queue of check-ins to be tagged */
43 Stmt s; /* Query the children of :pid to which to propagate */
44 Stmt ins; /* INSERT INTO tagxref */
45 Stmt eventupdate; /* UPDATE event */
46
47 assert( tagType==0 || tagType==2 );
48 pqueue_init(&queue);
49 pqueue_insert(&queue, pid, 0.0);
50
51 /* Query for children of :pid to which to propagate the tag.
52 ** Three returns: (1) rid of the child. (2) timestamp of child.
53 ** (3) True to propagate or false to block.
54 */
55 db_prepare(&s,
56 "SELECT cid, plink.mtime,"
57 " coalesce(srcid=0 AND tagxref.mtime<:mtime, %d) AS doit"
58 " FROM plink LEFT JOIN tagxref ON cid=rid AND tagid=%d"
59 " WHERE pid=:pid AND isprim",
60 tagType==2, tagid
61 );
62 db_bind_double(&s, ":mtime", mtime);
63
64 if( tagType==2 ){
65 /* Set the propagated tag marker on checkin :rid */
66 db_prepare(&ins,
67 "REPLACE INTO tagxref(tagid, tagtype, srcid, origid, value, mtime, rid)"
68 "VALUES(%d,2,0,%d,%Q,:mtime,:rid)",
69 tagid, origId, zValue
70 );
71 db_bind_double(&ins, ":mtime", mtime);
72 }else{
73 /* Remove all references to the tag from checkin :rid */
74 zValue = 0;
75 db_prepare(&ins,
76 "DELETE FROM tagxref WHERE tagid=%d AND rid=:rid", tagid
77 );
78 }
79
--- www/fileformat.wiki
+++ www/fileformat.wiki
@@ -286,16 +286,16 @@
286286
that is applied to
287287
some other artifact. The T card has two or three values. The
288288
second argument is the 40 character lowercase artifact ID of the artifact
289289
to which the tag is to be applied. The
290290
first value is the tag name. The first character of the tag
291
-is either "+", "-", or "*". A "+" means the tag should be added
291
+is either "+", "-", or "*". The "+" means the tag should be added
292292
to the artifact. The "-" means the tag should be removed.
293293
The "*" character means the tag should be added to the artifact
294
-and all direct descendants (but not branches) of the artifact down
294
+and all direct descendants (but not descendents through a merge) down
295295
to but not including the first descendant that contains a
296
-more recent "-" tag with the same name.
296
+more recent "-" or "+" tag with the same name.
297297
The optional third argument is the value of the tag. A tag
298298
without a value is a boolean.
299299
300300
When two or more tags with the same name are applied to the
301301
same artifact, the tag with the latest (most recent) date is
302302
--- www/fileformat.wiki
+++ www/fileformat.wiki
@@ -286,16 +286,16 @@
286 that is applied to
287 some other artifact. The T card has two or three values. The
288 second argument is the 40 character lowercase artifact ID of the artifact
289 to which the tag is to be applied. The
290 first value is the tag name. The first character of the tag
291 is either "+", "-", or "*". A "+" means the tag should be added
292 to the artifact. The "-" means the tag should be removed.
293 The "*" character means the tag should be added to the artifact
294 and all direct descendants (but not branches) of the artifact down
295 to but not including the first descendant that contains a
296 more recent "-" tag with the same name.
297 The optional third argument is the value of the tag. A tag
298 without a value is a boolean.
299
300 When two or more tags with the same name are applied to the
301 same artifact, the tag with the latest (most recent) date is
302
--- www/fileformat.wiki
+++ www/fileformat.wiki
@@ -286,16 +286,16 @@
286 that is applied to
287 some other artifact. The T card has two or three values. The
288 second argument is the 40 character lowercase artifact ID of the artifact
289 to which the tag is to be applied. The
290 first value is the tag name. The first character of the tag
291 is either "+", "-", or "*". The "+" means the tag should be added
292 to the artifact. The "-" means the tag should be removed.
293 The "*" character means the tag should be added to the artifact
294 and all direct descendants (but not descendents through a merge) down
295 to but not including the first descendant that contains a
296 more recent "-" or "+" tag with the same name.
297 The optional third argument is the value of the tag. A tag
298 without a value is a boolean.
299
300 When two or more tags with the same name are applied to the
301 same artifact, the tag with the latest (most recent) date is
302

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button