Fossil SCM
Generate the "manifest.uuid" file containing the SHA1 hash of the "manifest" file whenever the manifest is generated. Makefiles can used the "manifest.uuid" to insert the version number into the executable.
Commit
95e17f4e3f12b5a674e86dd827fc564bef6dc9da
Parent
b0ad3f90bc4f389…
3 files changed
+2
-2
+8
+6
-1
+2
-2
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -152,11 +152,11 @@ | ||
| 152 | 152 | chdir(g.zLocalRoot); |
| 153 | 153 | blob_zero(&path); |
| 154 | 154 | vfile_scan(0, &path); |
| 155 | 155 | db_prepare(&q, |
| 156 | 156 | "SELECT x FROM sfile" |
| 157 | - " WHERE x NOT IN ('manifest','_FOSSIL_')" | |
| 157 | + " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" | |
| 158 | 158 | " ORDER BY 1"); |
| 159 | 159 | while( db_step(&q)==SQLITE_ROW ){ |
| 160 | 160 | printf("%s\n", db_column_text(&q, 0)); |
| 161 | 161 | } |
| 162 | 162 | db_finalize(&q); |
| @@ -177,11 +177,11 @@ | ||
| 177 | 177 | chdir(g.zLocalRoot); |
| 178 | 178 | blob_zero(&path); |
| 179 | 179 | vfile_scan(0, &path); |
| 180 | 180 | db_prepare(&q, |
| 181 | 181 | "SELECT %Q || x FROM sfile" |
| 182 | - " WHERE x NOT IN ('manifest','_FOSSIL_')" | |
| 182 | + " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" | |
| 183 | 183 | " ORDER BY 1", g.zLocalRoot); |
| 184 | 184 | while( db_step(&q)==SQLITE_ROW ){ |
| 185 | 185 | unlink(db_column_text(&q, 0)); |
| 186 | 186 | } |
| 187 | 187 | db_finalize(&q); |
| 188 | 188 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -152,11 +152,11 @@ | |
| 152 | chdir(g.zLocalRoot); |
| 153 | blob_zero(&path); |
| 154 | vfile_scan(0, &path); |
| 155 | db_prepare(&q, |
| 156 | "SELECT x FROM sfile" |
| 157 | " WHERE x NOT IN ('manifest','_FOSSIL_')" |
| 158 | " ORDER BY 1"); |
| 159 | while( db_step(&q)==SQLITE_ROW ){ |
| 160 | printf("%s\n", db_column_text(&q, 0)); |
| 161 | } |
| 162 | db_finalize(&q); |
| @@ -177,11 +177,11 @@ | |
| 177 | chdir(g.zLocalRoot); |
| 178 | blob_zero(&path); |
| 179 | vfile_scan(0, &path); |
| 180 | db_prepare(&q, |
| 181 | "SELECT %Q || x FROM sfile" |
| 182 | " WHERE x NOT IN ('manifest','_FOSSIL_')" |
| 183 | " ORDER BY 1", g.zLocalRoot); |
| 184 | while( db_step(&q)==SQLITE_ROW ){ |
| 185 | unlink(db_column_text(&q, 0)); |
| 186 | } |
| 187 | db_finalize(&q); |
| 188 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -152,11 +152,11 @@ | |
| 152 | chdir(g.zLocalRoot); |
| 153 | blob_zero(&path); |
| 154 | vfile_scan(0, &path); |
| 155 | db_prepare(&q, |
| 156 | "SELECT x FROM sfile" |
| 157 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 158 | " ORDER BY 1"); |
| 159 | while( db_step(&q)==SQLITE_ROW ){ |
| 160 | printf("%s\n", db_column_text(&q, 0)); |
| 161 | } |
| 162 | db_finalize(&q); |
| @@ -177,11 +177,11 @@ | |
| 177 | chdir(g.zLocalRoot); |
| 178 | blob_zero(&path); |
| 179 | vfile_scan(0, &path); |
| 180 | db_prepare(&q, |
| 181 | "SELECT %Q || x FROM sfile" |
| 182 | " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" |
| 183 | " ORDER BY 1", g.zLocalRoot); |
| 184 | while( db_step(&q)==SQLITE_ROW ){ |
| 185 | unlink(db_column_text(&q, 0)); |
| 186 | } |
| 187 | db_finalize(&q); |
| 188 |
+8
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -97,17 +97,25 @@ | ||
| 97 | 97 | ** and store it in the root of the local check-out. |
| 98 | 98 | */ |
| 99 | 99 | void manifest_to_disk(int vid){ |
| 100 | 100 | char *zManFile; |
| 101 | 101 | Blob manifest; |
| 102 | + Blob hash; | |
| 102 | 103 | |
| 103 | 104 | blob_zero(&manifest); |
| 104 | 105 | zManFile = mprintf("%smanifest", g.zLocalRoot); |
| 105 | 106 | content_get(vid, &manifest); |
| 106 | 107 | blob_write_to_file(&manifest, zManFile); |
| 107 | 108 | free(zManFile); |
| 109 | + blob_zero(&hash); | |
| 110 | + sha1sum_blob(&manifest, &hash); | |
| 108 | 111 | blob_reset(&manifest); |
| 112 | + zManFile = mprintf("%smanifest.uuid", g.zLocalRoot); | |
| 113 | + blob_append(&hash, "\n", 1); | |
| 114 | + blob_write_to_file(&hash, zManFile); | |
| 115 | + free(zManFile); | |
| 116 | + blob_reset(&hash); | |
| 109 | 117 | } |
| 110 | 118 | |
| 111 | 119 | /* |
| 112 | 120 | ** COMMAND: checkout |
| 113 | 121 | ** |
| 114 | 122 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -97,17 +97,25 @@ | |
| 97 | ** and store it in the root of the local check-out. |
| 98 | */ |
| 99 | void manifest_to_disk(int vid){ |
| 100 | char *zManFile; |
| 101 | Blob manifest; |
| 102 | |
| 103 | blob_zero(&manifest); |
| 104 | zManFile = mprintf("%smanifest", g.zLocalRoot); |
| 105 | content_get(vid, &manifest); |
| 106 | blob_write_to_file(&manifest, zManFile); |
| 107 | free(zManFile); |
| 108 | blob_reset(&manifest); |
| 109 | } |
| 110 | |
| 111 | /* |
| 112 | ** COMMAND: checkout |
| 113 | ** |
| 114 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -97,17 +97,25 @@ | |
| 97 | ** and store it in the root of the local check-out. |
| 98 | */ |
| 99 | void manifest_to_disk(int vid){ |
| 100 | char *zManFile; |
| 101 | Blob manifest; |
| 102 | Blob hash; |
| 103 | |
| 104 | blob_zero(&manifest); |
| 105 | zManFile = mprintf("%smanifest", g.zLocalRoot); |
| 106 | content_get(vid, &manifest); |
| 107 | blob_write_to_file(&manifest, zManFile); |
| 108 | free(zManFile); |
| 109 | blob_zero(&hash); |
| 110 | sha1sum_blob(&manifest, &hash); |
| 111 | blob_reset(&manifest); |
| 112 | zManFile = mprintf("%smanifest.uuid", g.zLocalRoot); |
| 113 | blob_append(&hash, "\n", 1); |
| 114 | blob_write_to_file(&hash, zManFile); |
| 115 | free(zManFile); |
| 116 | blob_reset(&hash); |
| 117 | } |
| 118 | |
| 119 | /* |
| 120 | ** COMMAND: checkout |
| 121 | ** |
| 122 |
+6
-1
| --- src/zip.c | ||
| +++ src/zip.c | ||
| @@ -267,25 +267,30 @@ | ||
| 267 | 267 | ** If the RID object does not exist in the repository, then |
| 268 | 268 | ** pZip is zeroed. |
| 269 | 269 | */ |
| 270 | 270 | void zip_of_baseline(int rid, Blob *pZip){ |
| 271 | 271 | int i; |
| 272 | - Blob mfile, file; | |
| 272 | + Blob mfile, file, hash; | |
| 273 | 273 | Manifest m; |
| 274 | 274 | |
| 275 | 275 | content_get(rid, &mfile); |
| 276 | 276 | if( blob_size(&mfile)==0 ){ |
| 277 | 277 | blob_zero(pZip); |
| 278 | 278 | return; |
| 279 | 279 | } |
| 280 | 280 | blob_zero(&file); |
| 281 | + blob_zero(&hash); | |
| 281 | 282 | blob_copy(&file, &mfile); |
| 282 | 283 | zip_open(); |
| 283 | 284 | if( manifest_parse(&m, &mfile) ){ |
| 284 | 285 | zip_set_timedate(m.rDate); |
| 285 | 286 | zip_add_file("manifest", &file); |
| 287 | + sha1sum_blob(&file, &hash); | |
| 286 | 288 | blob_reset(&file); |
| 289 | + blob_append(&hash, "\n", 1); | |
| 290 | + zip_add_file("manifest.uuid", &hash); | |
| 291 | + blob_reset(&hash); | |
| 287 | 292 | for(i=0; i<m.nFile; i++){ |
| 288 | 293 | int fid = uuid_to_rid(m.aFile[i].zUuid, 0); |
| 289 | 294 | if( fid ){ |
| 290 | 295 | content_get(fid, &file); |
| 291 | 296 | zip_add_file(m.aFile[i].zName, &file); |
| 292 | 297 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -267,25 +267,30 @@ | |
| 267 | ** If the RID object does not exist in the repository, then |
| 268 | ** pZip is zeroed. |
| 269 | */ |
| 270 | void zip_of_baseline(int rid, Blob *pZip){ |
| 271 | int i; |
| 272 | Blob mfile, file; |
| 273 | Manifest m; |
| 274 | |
| 275 | content_get(rid, &mfile); |
| 276 | if( blob_size(&mfile)==0 ){ |
| 277 | blob_zero(pZip); |
| 278 | return; |
| 279 | } |
| 280 | blob_zero(&file); |
| 281 | blob_copy(&file, &mfile); |
| 282 | zip_open(); |
| 283 | if( manifest_parse(&m, &mfile) ){ |
| 284 | zip_set_timedate(m.rDate); |
| 285 | zip_add_file("manifest", &file); |
| 286 | blob_reset(&file); |
| 287 | for(i=0; i<m.nFile; i++){ |
| 288 | int fid = uuid_to_rid(m.aFile[i].zUuid, 0); |
| 289 | if( fid ){ |
| 290 | content_get(fid, &file); |
| 291 | zip_add_file(m.aFile[i].zName, &file); |
| 292 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -267,25 +267,30 @@ | |
| 267 | ** If the RID object does not exist in the repository, then |
| 268 | ** pZip is zeroed. |
| 269 | */ |
| 270 | void zip_of_baseline(int rid, Blob *pZip){ |
| 271 | int i; |
| 272 | Blob mfile, file, hash; |
| 273 | Manifest m; |
| 274 | |
| 275 | content_get(rid, &mfile); |
| 276 | if( blob_size(&mfile)==0 ){ |
| 277 | blob_zero(pZip); |
| 278 | return; |
| 279 | } |
| 280 | blob_zero(&file); |
| 281 | blob_zero(&hash); |
| 282 | blob_copy(&file, &mfile); |
| 283 | zip_open(); |
| 284 | if( manifest_parse(&m, &mfile) ){ |
| 285 | zip_set_timedate(m.rDate); |
| 286 | zip_add_file("manifest", &file); |
| 287 | sha1sum_blob(&file, &hash); |
| 288 | blob_reset(&file); |
| 289 | blob_append(&hash, "\n", 1); |
| 290 | zip_add_file("manifest.uuid", &hash); |
| 291 | blob_reset(&hash); |
| 292 | for(i=0; i<m.nFile; i++){ |
| 293 | int fid = uuid_to_rid(m.aFile[i].zUuid, 0); |
| 294 | if( fid ){ |
| 295 | content_get(fid, &file); |
| 296 | zip_add_file(m.aFile[i].zName, &file); |
| 297 |