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.

drh 2007-08-25 19:31 trunk
Commit 95e17f4e3f12b5a674e86dd827fc564bef6dc9da
+2 -2
--- src/checkin.c
+++ src/checkin.c
@@ -152,11 +152,11 @@
152152
chdir(g.zLocalRoot);
153153
blob_zero(&path);
154154
vfile_scan(0, &path);
155155
db_prepare(&q,
156156
"SELECT x FROM sfile"
157
- " WHERE x NOT IN ('manifest','_FOSSIL_')"
157
+ " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')"
158158
" ORDER BY 1");
159159
while( db_step(&q)==SQLITE_ROW ){
160160
printf("%s\n", db_column_text(&q, 0));
161161
}
162162
db_finalize(&q);
@@ -177,11 +177,11 @@
177177
chdir(g.zLocalRoot);
178178
blob_zero(&path);
179179
vfile_scan(0, &path);
180180
db_prepare(&q,
181181
"SELECT %Q || x FROM sfile"
182
- " WHERE x NOT IN ('manifest','_FOSSIL_')"
182
+ " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')"
183183
" ORDER BY 1", g.zLocalRoot);
184184
while( db_step(&q)==SQLITE_ROW ){
185185
unlink(db_column_text(&q, 0));
186186
}
187187
db_finalize(&q);
188188
--- 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
--- src/checkout.c
+++ src/checkout.c
@@ -97,17 +97,25 @@
9797
** and store it in the root of the local check-out.
9898
*/
9999
void manifest_to_disk(int vid){
100100
char *zManFile;
101101
Blob manifest;
102
+ Blob hash;
102103
103104
blob_zero(&manifest);
104105
zManFile = mprintf("%smanifest", g.zLocalRoot);
105106
content_get(vid, &manifest);
106107
blob_write_to_file(&manifest, zManFile);
107108
free(zManFile);
109
+ blob_zero(&hash);
110
+ sha1sum_blob(&manifest, &hash);
108111
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);
109117
}
110118
111119
/*
112120
** COMMAND: checkout
113121
**
114122
--- 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 @@
267267
** If the RID object does not exist in the repository, then
268268
** pZip is zeroed.
269269
*/
270270
void zip_of_baseline(int rid, Blob *pZip){
271271
int i;
272
- Blob mfile, file;
272
+ Blob mfile, file, hash;
273273
Manifest m;
274274
275275
content_get(rid, &mfile);
276276
if( blob_size(&mfile)==0 ){
277277
blob_zero(pZip);
278278
return;
279279
}
280280
blob_zero(&file);
281
+ blob_zero(&hash);
281282
blob_copy(&file, &mfile);
282283
zip_open();
283284
if( manifest_parse(&m, &mfile) ){
284285
zip_set_timedate(m.rDate);
285286
zip_add_file("manifest", &file);
287
+ sha1sum_blob(&file, &hash);
286288
blob_reset(&file);
289
+ blob_append(&hash, "\n", 1);
290
+ zip_add_file("manifest.uuid", &hash);
291
+ blob_reset(&hash);
287292
for(i=0; i<m.nFile; i++){
288293
int fid = uuid_to_rid(m.aFile[i].zUuid, 0);
289294
if( fid ){
290295
content_get(fid, &file);
291296
zip_add_file(m.aFile[i].zName, &file);
292297
--- 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

Keyboard Shortcuts

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