Fossil SCM
Fix a bug in the "leaves" page when the repository is empty. Begin adding support for the ability to erase tags.
Commit
432d4391b9b64e3cc556832db60d5c51fc24e98b
Parent
bdcac6293748bd3…
3 files changed
+1
+5
-4
+6
-2
+1
| --- src/descendants.c | ||
| +++ src/descendants.c | ||
| @@ -76,10 +76,11 @@ | ||
| 76 | 76 | bag_init(&seen); |
| 77 | 77 | bag_init(&pending); |
| 78 | 78 | if( iBase<=0 ){ |
| 79 | 79 | iBase = db_int(0, "SELECT objid FROM event WHERE type='ci'" |
| 80 | 80 | " ORDER BY mtime LIMIT 1"); |
| 81 | + if( iBase==0 ) return; | |
| 81 | 82 | } |
| 82 | 83 | bag_insert(&pending, iBase); |
| 83 | 84 | db_prepare(&q, "SELECT cid FROM plink WHERE pid=:rid"); |
| 84 | 85 | db_prepare(&isBr, |
| 85 | 86 | "SELECT 1 FROM tagxref WHERE rid=:rid AND tagid=%d AND tagtype=1", |
| 86 | 87 |
| --- 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 @@ | ||
| 501 | 501 | zUuid = 0; |
| 502 | 502 | }else{ |
| 503 | 503 | goto manifest_syntax_error; |
| 504 | 504 | } |
| 505 | 505 | defossilize(zName); |
| 506 | - if( zName[0]!='-' && zName[0]!='+' && zName[0]!='*' ){ | |
| 506 | + if( zName[0]!='-' && zName[0]!='+' && zName[0]!='*' && zName[0]!='0' ){ | |
| 507 | 507 | goto manifest_syntax_error; |
| 508 | 508 | } |
| 509 | 509 | if( validate16(&zName[1], strlen(&zName[1])) ){ |
| 510 | 510 | /* Do not allow tags whose names look like UUIDs */ |
| 511 | 511 | goto manifest_syntax_error; |
| @@ -948,13 +948,14 @@ | ||
| 948 | 948 | }else{ |
| 949 | 949 | tid = rid; |
| 950 | 950 | } |
| 951 | 951 | if( tid ){ |
| 952 | 952 | 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; | |
| 956 | 957 | default: |
| 957 | 958 | fossil_fatal("unknown tag type in manifest: %s", m.aTag); |
| 958 | 959 | return 0; |
| 959 | 960 | } |
| 960 | 961 | tag_insert(&m.aTag[i].zName[1], type, m.aTag[i].zValue, |
| 961 | 962 |
| --- 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 @@ | ||
| 142 | 142 | /* |
| 143 | 143 | ** Insert a tag into the database. |
| 144 | 144 | */ |
| 145 | 145 | void tag_insert( |
| 146 | 146 | 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 */ | |
| 148 | 148 | const char *zValue, /* Value if the tag is really a property */ |
| 149 | 149 | int srcId, /* Artifact that contains this tag */ |
| 150 | 150 | double mtime, /* Timestamp. Use default if <=0.0 */ |
| 151 | 151 | int rid /* Artifact to which the tag is to attached */ |
| 152 | 152 | ){ |
| @@ -167,12 +167,16 @@ | ||
| 167 | 167 | ); |
| 168 | 168 | db_bind_double(&s, ":mtime", mtime); |
| 169 | 169 | rc = db_step(&s); |
| 170 | 170 | db_finalize(&s); |
| 171 | 171 | 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 ){ | |
| 173 | 176 | return; |
| 177 | + /* TBD: erase tags */ | |
| 174 | 178 | } |
| 175 | 179 | db_prepare(&s, |
| 176 | 180 | "REPLACE INTO tagxref(tagid,tagtype,srcId,value,mtime,rid)" |
| 177 | 181 | " VALUES(%d,%d,%d,%Q,:mtime,%d)", |
| 178 | 182 | tagid, tagtype, srcId, zValue, rid |
| 179 | 183 |
| --- 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 |