Fossil SCM

Fix a bug in the "leaves" page when the repository is empty. Begin adding support for the ability to erase tags.

drh 2009-01-21 13:50 trunk
Commit 432d4391b9b64e3cc556832db60d5c51fc24e98b
--- src/descendants.c
+++ src/descendants.c
@@ -76,10 +76,11 @@
7676
bag_init(&seen);
7777
bag_init(&pending);
7878
if( iBase<=0 ){
7979
iBase = db_int(0, "SELECT objid FROM event WHERE type='ci'"
8080
" ORDER BY mtime LIMIT 1");
81
+ if( iBase==0 ) return;
8182
}
8283
bag_insert(&pending, iBase);
8384
db_prepare(&q, "SELECT cid FROM plink WHERE pid=:rid");
8485
db_prepare(&isBr,
8586
"SELECT 1 FROM tagxref WHERE rid=:rid AND tagid=%d AND tagtype=1",
8687
--- src/descendants.c
+++ src/descendants.c
@@ -76,10 +76,11 @@
76 bag_init(&seen);
77 bag_init(&pending);
78 if( iBase<=0 ){
79 iBase = db_int(0, "SELECT objid FROM event WHERE type='ci'"
80 " ORDER BY mtime LIMIT 1");
 
81 }
82 bag_insert(&pending, iBase);
83 db_prepare(&q, "SELECT cid FROM plink WHERE pid=:rid");
84 db_prepare(&isBr,
85 "SELECT 1 FROM tagxref WHERE rid=:rid AND tagid=%d AND tagtype=1",
86
--- src/descendants.c
+++ src/descendants.c
@@ -76,10 +76,11 @@
76 bag_init(&seen);
77 bag_init(&pending);
78 if( iBase<=0 ){
79 iBase = db_int(0, "SELECT objid FROM event WHERE type='ci'"
80 " ORDER BY mtime LIMIT 1");
81 if( iBase==0 ) return;
82 }
83 bag_insert(&pending, iBase);
84 db_prepare(&q, "SELECT cid FROM plink WHERE pid=:rid");
85 db_prepare(&isBr,
86 "SELECT 1 FROM tagxref WHERE rid=:rid AND tagid=%d AND tagtype=1",
87
+5 -4
--- src/manifest.c
+++ src/manifest.c
@@ -501,11 +501,11 @@
501501
zUuid = 0;
502502
}else{
503503
goto manifest_syntax_error;
504504
}
505505
defossilize(zName);
506
- if( zName[0]!='-' && zName[0]!='+' && zName[0]!='*' ){
506
+ if( zName[0]!='-' && zName[0]!='+' && zName[0]!='*' && zName[0]!='0' ){
507507
goto manifest_syntax_error;
508508
}
509509
if( validate16(&zName[1], strlen(&zName[1])) ){
510510
/* Do not allow tags whose names look like UUIDs */
511511
goto manifest_syntax_error;
@@ -948,13 +948,14 @@
948948
}else{
949949
tid = rid;
950950
}
951951
if( tid ){
952952
switch( m.aTag[i].zName[0] ){
953
- case '+': type = 1; break;
954
- case '*': type = 2; break;
955
- case '-': type = 0; break;
953
+ case '+': type = 1; break;
954
+ case '*': type = 2; break;
955
+ case '-': type = 0; break;
956
+ case '0': type = -1; break;
956957
default:
957958
fossil_fatal("unknown tag type in manifest: %s", m.aTag);
958959
return 0;
959960
}
960961
tag_insert(&m.aTag[i].zName[1], type, m.aTag[i].zValue,
961962
--- src/manifest.c
+++ src/manifest.c
@@ -501,11 +501,11 @@
501 zUuid = 0;
502 }else{
503 goto manifest_syntax_error;
504 }
505 defossilize(zName);
506 if( zName[0]!='-' && zName[0]!='+' && zName[0]!='*' ){
507 goto manifest_syntax_error;
508 }
509 if( validate16(&zName[1], strlen(&zName[1])) ){
510 /* Do not allow tags whose names look like UUIDs */
511 goto manifest_syntax_error;
@@ -948,13 +948,14 @@
948 }else{
949 tid = rid;
950 }
951 if( tid ){
952 switch( m.aTag[i].zName[0] ){
953 case '+': type = 1; break;
954 case '*': type = 2; break;
955 case '-': type = 0; break;
 
956 default:
957 fossil_fatal("unknown tag type in manifest: %s", m.aTag);
958 return 0;
959 }
960 tag_insert(&m.aTag[i].zName[1], type, m.aTag[i].zValue,
961
--- src/manifest.c
+++ src/manifest.c
@@ -501,11 +501,11 @@
501 zUuid = 0;
502 }else{
503 goto manifest_syntax_error;
504 }
505 defossilize(zName);
506 if( zName[0]!='-' && zName[0]!='+' && zName[0]!='*' && zName[0]!='0' ){
507 goto manifest_syntax_error;
508 }
509 if( validate16(&zName[1], strlen(&zName[1])) ){
510 /* Do not allow tags whose names look like UUIDs */
511 goto manifest_syntax_error;
@@ -948,13 +948,14 @@
948 }else{
949 tid = rid;
950 }
951 if( tid ){
952 switch( m.aTag[i].zName[0] ){
953 case '+': type = 1; break;
954 case '*': type = 2; break;
955 case '-': type = 0; break;
956 case '0': type = -1; break;
957 default:
958 fossil_fatal("unknown tag type in manifest: %s", m.aTag);
959 return 0;
960 }
961 tag_insert(&m.aTag[i].zName[1], type, m.aTag[i].zValue,
962
+6 -2
--- src/tag.c
+++ src/tag.c
@@ -142,11 +142,11 @@
142142
/*
143143
** Insert a tag into the database.
144144
*/
145145
void tag_insert(
146146
const char *zTag, /* Name of the tag (w/o the "+" or "-" prefix */
147
- int tagtype, /* 0:cancel 1:singleton 2:propagated */
147
+ int tagtype, /* 0:cancel 1:singleton 2:propagated -1:erase */
148148
const char *zValue, /* Value if the tag is really a property */
149149
int srcId, /* Artifact that contains this tag */
150150
double mtime, /* Timestamp. Use default if <=0.0 */
151151
int rid /* Artifact to which the tag is to attached */
152152
){
@@ -167,12 +167,16 @@
167167
);
168168
db_bind_double(&s, ":mtime", mtime);
169169
rc = db_step(&s);
170170
db_finalize(&s);
171171
if( rc==SQLITE_ROW ){
172
- /* Another entry this is more recent already exists. Do nothing */
172
+ /* Another entry that is more recent already exists. Do nothing */
173
+ return;
174
+ }
175
+ if( tagtype<0 ){
173176
return;
177
+ /* TBD: erase tags */
174178
}
175179
db_prepare(&s,
176180
"REPLACE INTO tagxref(tagid,tagtype,srcId,value,mtime,rid)"
177181
" VALUES(%d,%d,%d,%Q,:mtime,%d)",
178182
tagid, tagtype, srcId, zValue, rid
179183
--- src/tag.c
+++ src/tag.c
@@ -142,11 +142,11 @@
142 /*
143 ** Insert a tag into the database.
144 */
145 void tag_insert(
146 const char *zTag, /* Name of the tag (w/o the "+" or "-" prefix */
147 int tagtype, /* 0:cancel 1:singleton 2:propagated */
148 const char *zValue, /* Value if the tag is really a property */
149 int srcId, /* Artifact that contains this tag */
150 double mtime, /* Timestamp. Use default if <=0.0 */
151 int rid /* Artifact to which the tag is to attached */
152 ){
@@ -167,12 +167,16 @@
167 );
168 db_bind_double(&s, ":mtime", mtime);
169 rc = db_step(&s);
170 db_finalize(&s);
171 if( rc==SQLITE_ROW ){
172 /* Another entry this is more recent already exists. Do nothing */
 
 
 
173 return;
 
174 }
175 db_prepare(&s,
176 "REPLACE INTO tagxref(tagid,tagtype,srcId,value,mtime,rid)"
177 " VALUES(%d,%d,%d,%Q,:mtime,%d)",
178 tagid, tagtype, srcId, zValue, rid
179
--- src/tag.c
+++ src/tag.c
@@ -142,11 +142,11 @@
142 /*
143 ** Insert a tag into the database.
144 */
145 void tag_insert(
146 const char *zTag, /* Name of the tag (w/o the "+" or "-" prefix */
147 int tagtype, /* 0:cancel 1:singleton 2:propagated -1:erase */
148 const char *zValue, /* Value if the tag is really a property */
149 int srcId, /* Artifact that contains this tag */
150 double mtime, /* Timestamp. Use default if <=0.0 */
151 int rid /* Artifact to which the tag is to attached */
152 ){
@@ -167,12 +167,16 @@
167 );
168 db_bind_double(&s, ":mtime", mtime);
169 rc = db_step(&s);
170 db_finalize(&s);
171 if( rc==SQLITE_ROW ){
172 /* Another entry that is more recent already exists. Do nothing */
173 return;
174 }
175 if( tagtype<0 ){
176 return;
177 /* TBD: erase tags */
178 }
179 db_prepare(&s,
180 "REPLACE INTO tagxref(tagid,tagtype,srcId,value,mtime,rid)"
181 " VALUES(%d,%d,%d,%Q,:mtime,%d)",
182 tagid, tagtype, srcId, zValue, rid
183

Keyboard Shortcuts

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