Check-in [5c3e87171a]
Not logged in
Overview

SHA1 Hash:5c3e87171a336b076e87377b786fa9a1de711016
Date: 2007-08-01 12:17:14
User: drh
Comment:Fix a problem in the commit logic that caused it to ignore merge changes. Add another test to the commit to detect future problems of a similar nature.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/checkin.c from [f97001dc6f] to [5e2184d9ad].

@@ -270,11 +270,11 @@
   blob_appendf(&manifest, "C %F\n", blob_str(&comment));
   zDate = db_text(0, "SELECT datetime('now')");
   zDate[10] = 'T';
   blob_appendf(&manifest, "D %s\n", zDate);
   db_prepare(&q,
-    "SELECT pathname, uuid FROM vfile JOIN blob USING (rid)"
+    "SELECT pathname, uuid FROM vfile JOIN blob ON vfile.mrid=blob.rid"
     " WHERE NOT deleted AND vfile.vid=%d"
     " ORDER BY 1", vid);
   while( db_step(&q)==SQLITE_ROW ){
     const char *zName = db_column_text(&q, 0);
     const char *zUuid = db_column_text(&q, 1);
@@ -321,14 +321,18 @@
 
   /* Verify that the tree checksum is unchanged */
   vfile_aggregate_checksum_repository(nvid, &cksum2);
   if( blob_compare(&cksum1, &cksum2) ){
     fossil_panic("tree checksum does not match repository after commit");
+  }
+  vfile_aggregate_checksum_manifest(nvid, &cksum2);
+  if( blob_compare(&cksum1, &cksum2) ){
+    fossil_panic("tree checksum does not match manifest after commit");
   }
   vfile_aggregate_checksum_disk(nvid, &cksum2);
   if( blob_compare(&cksum1, &cksum2) ){
     fossil_panic("tree checksums before and after commit do not match");
   }
 
   /* Commit */
   db_end_transaction(0);
 }

Modified src/vfile.c from [e0efe29333] to [d4b9c4a1e5].

@@ -303,10 +303,11 @@
   Blob file;
   Stmt q;
   char zBuf[100];
 
   db_must_be_within_tree();
+
   db_prepare(&q, "SELECT pathname, rid FROM vfile"
                  " WHERE NOT deleted AND rid>0 AND vid=%d"
                  " ORDER BY pathname",
                  vid);
   blob_zero(&file);
@@ -324,18 +325,52 @@
   db_finalize(&q);
   md5sum_finish(pOut);
 }
 
 /*
+** Compute an aggregate MD5 checksum over the repository image of every
+** file in manifest vid.  The file names are part of the checksum.
+**
+** Return the resulting checksum in blob pOut.
+*/
+void vfile_aggregate_checksum_manifest(int vid, Blob *pOut){
+  int i, fid;
+  Blob file, mfile;
+  Manifest m;
+  char zBuf[100];
+
+  db_must_be_within_tree();
+  content_get(vid, &mfile);
+  if( manifest_parse(&m, &mfile)==0 ){
+    blob_zero(pOut);
+    return;
+  }
+  for(i=0; i<m.nFile; i++){
+    fid = uuid_to_rid(m.aFile[i].zUuid, 0);
+    md5sum_step_text(m.aFile[i].zName, -1);
+    content_get(fid, &file);
+    sprintf(zBuf, " %d\n", blob_size(&file));
+    md5sum_step_text(zBuf, -1);
+    md5sum_step_blob(&file);
+    blob_reset(&file);
+  }
+  manifest_clear(&m);
+  md5sum_finish(pOut);
+}
+
+/*
 ** COMMAND: test-agg-cksum
 */
 void test_agg_cksum_cmd(void){
   int vid;
   Blob hash;
   db_must_be_within_tree();
   vid = db_lget_int("checkout", 0);
   vfile_aggregate_checksum_disk(vid, &hash);
-  printf("disk:    %s\n", blob_str(&hash));
+  printf("disk:     %s\n", blob_str(&hash));
   blob_reset(&hash);
   vfile_aggregate_checksum_repository(vid, &hash);
-  printf("archive: %s\n", blob_str(&hash));
+  printf("archive:  %s\n", blob_str(&hash));
+  blob_reset(&hash);
+  vfile_aggregate_checksum_manifest(vid, &hash);
+  printf("manifest: %s\n", blob_str(&hash));
 }