Fossil SCM
Started work on allowing manifest.tags to automatically be created containing the checkout's tags. Repurposed the manifest setting slightly allowing manifest and manifest.uuid to be toggled individually, but keeping backwards compatibility.
Commit
9a2c75fc1cb557fe713d129ae2a8d2e10163f0df
Parent
987a80ef06635a6…
2 files changed
+57
-15
+35
+57
-15
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -127,30 +127,49 @@ | ||
| 127 | 127 | |
| 128 | 128 | /* |
| 129 | 129 | ** If the "manifest" setting is true, then automatically generate |
| 130 | 130 | ** files named "manifest" and "manifest.uuid" containing, respectively, |
| 131 | 131 | ** the text of the manifest and the artifact ID of the manifest. |
| 132 | +** If the manifest setting is set, but is not a boolean value, then treat | |
| 133 | +** each character as a flag to enable writing "manifest", "manifest.uuid" or | |
| 134 | +** "manifest.tags". | |
| 132 | 135 | */ |
| 133 | 136 | void manifest_to_disk(int vid){ |
| 134 | 137 | char *zManFile; |
| 135 | 138 | Blob manifest; |
| 136 | 139 | Blob hash; |
| 137 | - | |
| 138 | - if( db_get_boolean("manifest",0) ){ | |
| 139 | - blob_zero(&manifest); | |
| 140 | - content_get(vid, &manifest); | |
| 141 | - zManFile = mprintf("%smanifest", g.zLocalRoot); | |
| 142 | - blob_zero(&hash); | |
| 143 | - sha1sum_blob(&manifest, &hash); | |
| 144 | - sterilize_manifest(&manifest); | |
| 145 | - blob_write_to_file(&manifest, zManFile); | |
| 146 | - free(zManFile); | |
| 147 | - zManFile = mprintf("%smanifest.uuid", g.zLocalRoot); | |
| 148 | - blob_append(&hash, "\n", 1); | |
| 149 | - blob_write_to_file(&hash, zManFile); | |
| 150 | - free(zManFile); | |
| 151 | - blob_reset(&hash); | |
| 140 | + Blob taglist; | |
| 141 | + int flg; | |
| 142 | + | |
| 143 | + flg = db_get_manifest_setting(); | |
| 144 | + if( flg ){ | |
| 145 | + if( flg & (MFESTFLG_RAW|MFESTFLG_UUID) ){ | |
| 146 | + blob_zero(&manifest); | |
| 147 | + content_get(vid, &manifest); | |
| 148 | + zManFile = mprintf("%smanifest", g.zLocalRoot); | |
| 149 | + blob_zero(&hash); | |
| 150 | + sha1sum_blob(&manifest, &hash); | |
| 151 | + sterilize_manifest(&manifest); | |
| 152 | + if( flg & MFESTFLG_RAW ){ | |
| 153 | + blob_write_to_file(&manifest, zManFile); | |
| 154 | + } | |
| 155 | + free(zManFile); | |
| 156 | + } | |
| 157 | + if( flg & MFESTFLG_UUID ){ | |
| 158 | + zManFile = mprintf("%smanifest.uuid", g.zLocalRoot); | |
| 159 | + blob_append(&hash, "\n", 1); | |
| 160 | + blob_write_to_file(&hash, zManFile); | |
| 161 | + free(zManFile); | |
| 162 | + blob_reset(&hash); | |
| 163 | + } | |
| 164 | + if( flg & MFESTFLG_TAGS ){ | |
| 165 | + blob_zero(&taglist); | |
| 166 | + zManFile = mprintf("%smanifest.tags", g.zLocalRoot); | |
| 167 | + get_checkin_taglist(vid, &taglist); | |
| 168 | + blob_write_to_file(&taglist, zManFile); | |
| 169 | + free(zManFile); | |
| 170 | + } | |
| 152 | 171 | }else{ |
| 153 | 172 | if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest'") ){ |
| 154 | 173 | zManFile = mprintf("%smanifest", g.zLocalRoot); |
| 155 | 174 | file_delete(zManFile); |
| 156 | 175 | free(zManFile); |
| @@ -158,13 +177,36 @@ | ||
| 158 | 177 | if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest.uuid'") ){ |
| 159 | 178 | zManFile = mprintf("%smanifest.uuid", g.zLocalRoot); |
| 160 | 179 | file_delete(zManFile); |
| 161 | 180 | free(zManFile); |
| 162 | 181 | } |
| 182 | + if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest.tags'") ){ | |
| 183 | + zManFile = mprintf("%smanifest.tags", g.zLocalRoot); | |
| 184 | + file_delete(zManFile); | |
| 185 | + free(zManFile); | |
| 186 | + } | |
| 163 | 187 | } |
| 188 | + | |
| 189 | +} | |
| 164 | 190 | |
| 191 | +void get_checkin_taglist(int rid, Blob *pOut){ | |
| 192 | + char *zTags; | |
| 193 | + Stmt stmt; | |
| 194 | + blob_reset(pOut); | |
| 195 | + db_prepare(&stmt, "SELECT substr(tagname, 5)" | |
| 196 | + " FROM tagxref, tag" | |
| 197 | + " WHERE tagxref.rid=%d" | |
| 198 | + " AND tag.tagid=tagxref.tagid" | |
| 199 | + " AND tag.tagname GLOB 'sym-*'", rid); | |
| 200 | + while( db_step(&stmt)==SQLITE_ROW ){ | |
| 201 | + const char *zName; | |
| 202 | + zName = db_column_text(&stmt, 0); | |
| 203 | + blob_appendf(pOut, "%s\n", zName); | |
| 204 | + } | |
| 205 | + db_reset(&stmt); | |
| 165 | 206 | } |
| 207 | + | |
| 166 | 208 | |
| 167 | 209 | /* |
| 168 | 210 | ** COMMAND: checkout* |
| 169 | 211 | ** COMMAND: co* |
| 170 | 212 | ** |
| 171 | 213 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -127,30 +127,49 @@ | |
| 127 | |
| 128 | /* |
| 129 | ** If the "manifest" setting is true, then automatically generate |
| 130 | ** files named "manifest" and "manifest.uuid" containing, respectively, |
| 131 | ** the text of the manifest and the artifact ID of the manifest. |
| 132 | */ |
| 133 | void manifest_to_disk(int vid){ |
| 134 | char *zManFile; |
| 135 | Blob manifest; |
| 136 | Blob hash; |
| 137 | |
| 138 | if( db_get_boolean("manifest",0) ){ |
| 139 | blob_zero(&manifest); |
| 140 | content_get(vid, &manifest); |
| 141 | zManFile = mprintf("%smanifest", g.zLocalRoot); |
| 142 | blob_zero(&hash); |
| 143 | sha1sum_blob(&manifest, &hash); |
| 144 | sterilize_manifest(&manifest); |
| 145 | blob_write_to_file(&manifest, zManFile); |
| 146 | free(zManFile); |
| 147 | zManFile = mprintf("%smanifest.uuid", g.zLocalRoot); |
| 148 | blob_append(&hash, "\n", 1); |
| 149 | blob_write_to_file(&hash, zManFile); |
| 150 | free(zManFile); |
| 151 | blob_reset(&hash); |
| 152 | }else{ |
| 153 | if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest'") ){ |
| 154 | zManFile = mprintf("%smanifest", g.zLocalRoot); |
| 155 | file_delete(zManFile); |
| 156 | free(zManFile); |
| @@ -158,13 +177,36 @@ | |
| 158 | if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest.uuid'") ){ |
| 159 | zManFile = mprintf("%smanifest.uuid", g.zLocalRoot); |
| 160 | file_delete(zManFile); |
| 161 | free(zManFile); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | } |
| 166 | |
| 167 | /* |
| 168 | ** COMMAND: checkout* |
| 169 | ** COMMAND: co* |
| 170 | ** |
| 171 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -127,30 +127,49 @@ | |
| 127 | |
| 128 | /* |
| 129 | ** If the "manifest" setting is true, then automatically generate |
| 130 | ** files named "manifest" and "manifest.uuid" containing, respectively, |
| 131 | ** the text of the manifest and the artifact ID of the manifest. |
| 132 | ** If the manifest setting is set, but is not a boolean value, then treat |
| 133 | ** each character as a flag to enable writing "manifest", "manifest.uuid" or |
| 134 | ** "manifest.tags". |
| 135 | */ |
| 136 | void manifest_to_disk(int vid){ |
| 137 | char *zManFile; |
| 138 | Blob manifest; |
| 139 | Blob hash; |
| 140 | Blob taglist; |
| 141 | int flg; |
| 142 | |
| 143 | flg = db_get_manifest_setting(); |
| 144 | if( flg ){ |
| 145 | if( flg & (MFESTFLG_RAW|MFESTFLG_UUID) ){ |
| 146 | blob_zero(&manifest); |
| 147 | content_get(vid, &manifest); |
| 148 | zManFile = mprintf("%smanifest", g.zLocalRoot); |
| 149 | blob_zero(&hash); |
| 150 | sha1sum_blob(&manifest, &hash); |
| 151 | sterilize_manifest(&manifest); |
| 152 | if( flg & MFESTFLG_RAW ){ |
| 153 | blob_write_to_file(&manifest, zManFile); |
| 154 | } |
| 155 | free(zManFile); |
| 156 | } |
| 157 | if( flg & MFESTFLG_UUID ){ |
| 158 | zManFile = mprintf("%smanifest.uuid", g.zLocalRoot); |
| 159 | blob_append(&hash, "\n", 1); |
| 160 | blob_write_to_file(&hash, zManFile); |
| 161 | free(zManFile); |
| 162 | blob_reset(&hash); |
| 163 | } |
| 164 | if( flg & MFESTFLG_TAGS ){ |
| 165 | blob_zero(&taglist); |
| 166 | zManFile = mprintf("%smanifest.tags", g.zLocalRoot); |
| 167 | get_checkin_taglist(vid, &taglist); |
| 168 | blob_write_to_file(&taglist, zManFile); |
| 169 | free(zManFile); |
| 170 | } |
| 171 | }else{ |
| 172 | if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest'") ){ |
| 173 | zManFile = mprintf("%smanifest", g.zLocalRoot); |
| 174 | file_delete(zManFile); |
| 175 | free(zManFile); |
| @@ -158,13 +177,36 @@ | |
| 177 | if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest.uuid'") ){ |
| 178 | zManFile = mprintf("%smanifest.uuid", g.zLocalRoot); |
| 179 | file_delete(zManFile); |
| 180 | free(zManFile); |
| 181 | } |
| 182 | if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest.tags'") ){ |
| 183 | zManFile = mprintf("%smanifest.tags", g.zLocalRoot); |
| 184 | file_delete(zManFile); |
| 185 | free(zManFile); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | } |
| 190 | |
| 191 | void get_checkin_taglist(int rid, Blob *pOut){ |
| 192 | char *zTags; |
| 193 | Stmt stmt; |
| 194 | blob_reset(pOut); |
| 195 | db_prepare(&stmt, "SELECT substr(tagname, 5)" |
| 196 | " FROM tagxref, tag" |
| 197 | " WHERE tagxref.rid=%d" |
| 198 | " AND tag.tagid=tagxref.tagid" |
| 199 | " AND tag.tagname GLOB 'sym-*'", rid); |
| 200 | while( db_step(&stmt)==SQLITE_ROW ){ |
| 201 | const char *zName; |
| 202 | zName = db_column_text(&stmt, 0); |
| 203 | blob_appendf(pOut, "%s\n", zName); |
| 204 | } |
| 205 | db_reset(&stmt); |
| 206 | } |
| 207 | |
| 208 | |
| 209 | /* |
| 210 | ** COMMAND: checkout* |
| 211 | ** COMMAND: co* |
| 212 | ** |
| 213 |
M
src/db.c
+35
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -2206,10 +2206,45 @@ | ||
| 2206 | 2206 | return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName); |
| 2207 | 2207 | } |
| 2208 | 2208 | void db_lset_int(const char *zName, int value){ |
| 2209 | 2209 | db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value); |
| 2210 | 2210 | } |
| 2211 | + | |
| 2212 | +#if INTERFACE | |
| 2213 | +/* Manifest generation flags */ | |
| 2214 | +#define MFESTFLG_RAW 0x01 | |
| 2215 | +#define MFESTFLG_UUID 0x02 | |
| 2216 | +#define MFESTFLG_TAGS 0x04 | |
| 2217 | +#endif /* INTERFACE */ | |
| 2218 | + | |
| 2219 | +/* | |
| 2220 | +** Get the manifest setting. For backwards compatibility first check if the | |
| 2221 | +** value is a boolean. If it's not a boolean, treat each character as a flag | |
| 2222 | +** to enable a manifest type. This system puts certain boundary conditions on | |
| 2223 | +** which letters can be used to represent flags (any permutation fo flags must | |
| 2224 | +** not be able to fully form one of the boolean values). | |
| 2225 | +*/ | |
| 2226 | +int db_get_manifest_setting(void){ | |
| 2227 | + int flg; | |
| 2228 | + char *zVal = db_get("manifest", "off"); | |
| 2229 | + if( is_false(zVal) ){ | |
| 2230 | + return 0; | |
| 2231 | + }else if( is_truth(zVal) ) { | |
| 2232 | + return MFESTFLG_RAW|MFESTFLG_UUID; | |
| 2233 | + } | |
| 2234 | + flg = 0; | |
| 2235 | + while( *zVal ){ | |
| 2236 | + switch( *zVal ){ | |
| 2237 | + case 'r': flg |= MFESTFLG_RAW; break; | |
| 2238 | + case 'u': flg |= MFESTFLG_UUID; break; | |
| 2239 | + case 't': flg |= MFESTFLG_TAGS; break; | |
| 2240 | + } | |
| 2241 | + zVal++; | |
| 2242 | + } | |
| 2243 | + return flg; | |
| 2244 | +} | |
| 2245 | + | |
| 2211 | 2246 | |
| 2212 | 2247 | /* |
| 2213 | 2248 | ** Record the name of a local repository in the global_config() database. |
| 2214 | 2249 | ** The repository filename %s is recorded as an entry with a "name" field |
| 2215 | 2250 | ** of the following form: |
| 2216 | 2251 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2206,10 +2206,45 @@ | |
| 2206 | return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName); |
| 2207 | } |
| 2208 | void db_lset_int(const char *zName, int value){ |
| 2209 | db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value); |
| 2210 | } |
| 2211 | |
| 2212 | /* |
| 2213 | ** Record the name of a local repository in the global_config() database. |
| 2214 | ** The repository filename %s is recorded as an entry with a "name" field |
| 2215 | ** of the following form: |
| 2216 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -2206,10 +2206,45 @@ | |
| 2206 | return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName); |
| 2207 | } |
| 2208 | void db_lset_int(const char *zName, int value){ |
| 2209 | db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value); |
| 2210 | } |
| 2211 | |
| 2212 | #if INTERFACE |
| 2213 | /* Manifest generation flags */ |
| 2214 | #define MFESTFLG_RAW 0x01 |
| 2215 | #define MFESTFLG_UUID 0x02 |
| 2216 | #define MFESTFLG_TAGS 0x04 |
| 2217 | #endif /* INTERFACE */ |
| 2218 | |
| 2219 | /* |
| 2220 | ** Get the manifest setting. For backwards compatibility first check if the |
| 2221 | ** value is a boolean. If it's not a boolean, treat each character as a flag |
| 2222 | ** to enable a manifest type. This system puts certain boundary conditions on |
| 2223 | ** which letters can be used to represent flags (any permutation fo flags must |
| 2224 | ** not be able to fully form one of the boolean values). |
| 2225 | */ |
| 2226 | int db_get_manifest_setting(void){ |
| 2227 | int flg; |
| 2228 | char *zVal = db_get("manifest", "off"); |
| 2229 | if( is_false(zVal) ){ |
| 2230 | return 0; |
| 2231 | }else if( is_truth(zVal) ) { |
| 2232 | return MFESTFLG_RAW|MFESTFLG_UUID; |
| 2233 | } |
| 2234 | flg = 0; |
| 2235 | while( *zVal ){ |
| 2236 | switch( *zVal ){ |
| 2237 | case 'r': flg |= MFESTFLG_RAW; break; |
| 2238 | case 'u': flg |= MFESTFLG_UUID; break; |
| 2239 | case 't': flg |= MFESTFLG_TAGS; break; |
| 2240 | } |
| 2241 | zVal++; |
| 2242 | } |
| 2243 | return flg; |
| 2244 | } |
| 2245 | |
| 2246 | |
| 2247 | /* |
| 2248 | ** Record the name of a local repository in the global_config() database. |
| 2249 | ** The repository filename %s is recorded as an entry with a "name" field |
| 2250 | ** of the following form: |
| 2251 |