86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
db_begin_transaction();
p = manifest_get(vid, CFTYPE_MANIFEST, 0);
if( p==0 ) {
db_end_transaction(1);
return 0;
}
db_prepare(&ins,
"INSERT INTO vfile(vid,isexe,islink,rid,mrid,pathname) "
" VALUES(:vid,:isexe,:islink,:id,:id,:name)");
db_prepare(&ridq, "SELECT rid,size FROM blob WHERE uuid=:uuid");
db_bind_int(&ins, ":vid", vid);
manifest_file_rewind(p);
nMissing = 0;
while( (pFile = manifest_file_next(p,0))!=0 ){
if( pFile->zUuid==0 || uuid_is_shunned(pFile->zUuid) ) continue;
db_bind_text(&ridq, ":uuid", pFile->zUuid);
|
|
|
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
db_begin_transaction();
p = manifest_get(vid, CFTYPE_MANIFEST, 0);
if( p==0 ) {
db_end_transaction(1);
return 0;
}
db_prepare(&ins,
"INSERT INTO vfile(vid,isexe,islink,rid,mrid,pathname,mhash) "
" VALUES(:vid,:isexe,:islink,:id,:id,:name,NULL)");
db_prepare(&ridq, "SELECT rid,size FROM blob WHERE uuid=:uuid");
db_bind_int(&ins, ":vid", vid);
manifest_file_rewind(p);
nMissing = 0;
while( (pFile = manifest_file_next(p,0))!=0 ){
if( pFile->zUuid==0 || uuid_is_shunned(pFile->zUuid) ) continue;
db_bind_text(&ridq, ":uuid", pFile->zUuid);
|
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
** if --hash is used, check to see if they have been edited by
** looking at their artifact hashes */
const char *zUuid = db_column_text(&q, 5);
int nUuid = db_column_bytes(&q, 5);
assert( origSize==currentSize );
if( !hname_verify_file_hash(zName, zUuid, nUuid) ) chnged = 1;
}
if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2 || chnged==4) ){
i64 desiredMtime;
if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){
if( currentMtime!=desiredMtime ){
file_set_mtime(zName, desiredMtime);
currentMtime = file_mtime(zName, RepoFILE);
}
}
|
|
|
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
** if --hash is used, check to see if they have been edited by
** looking at their artifact hashes */
const char *zUuid = db_column_text(&q, 5);
int nUuid = db_column_bytes(&q, 5);
assert( origSize==currentSize );
if( !hname_verify_file_hash(zName, zUuid, nUuid) ) chnged = 1;
}
if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2 || chnged==4)){
i64 desiredMtime;
if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){
if( currentMtime!=desiredMtime ){
file_set_mtime(zName, desiredMtime);
currentMtime = file_mtime(zName, RepoFILE);
}
}
|
964
965
966
967
968
969
970
|
vfile_aggregate_checksum_repository(vid, &hash);
printf("archive: %s\n", blob_str(&hash));
blob_reset(&hash);
vfile_aggregate_checksum_manifest(vid, &hash, &hash2);
printf("manifest: %s\n", blob_str(&hash));
printf("recorded: %s\n", blob_str(&hash2));
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
|
vfile_aggregate_checksum_repository(vid, &hash);
printf("archive: %s\n", blob_str(&hash));
blob_reset(&hash);
vfile_aggregate_checksum_manifest(vid, &hash, &hash2);
printf("manifest: %s\n", blob_str(&hash));
printf("recorded: %s\n", blob_str(&hash2));
}
/*
** This routine recomputes certain columns of the vfile and vmerge tables
** when the associated repository is swapped out for a clone of the same
** project, and the blob.rid value change. The following columns are
** updated:
**
** vmerge.merge
** vfile.vid
** vfile.rid
** vfile.mrid
**
** Also:
**
** vvar.value WHERE name='checkout'
*/
void vfile_rid_renumbering_event(int dryRun){
int oldVid;
int newVid;
char *zUnresolved;
oldVid = db_lget_int("checkout", 0);
newVid = db_int(0, "SELECT blob.rid FROM blob, vvar"
" WHERE blob.uuid=vvar.value"
" AND vvar.name='checkout-hash'");
/* The idMap table will make old RID values into new ones */
db_multi_exec(
"CREATE TEMP TABLE idMap(oldrid INTEGER PRIMARY KEY, newrid INT);\n"
);
/* Add the RID value for the current check-out */
db_multi_exec(
"INSERT INTO idMap(oldrid, newrid) VALUES(%d,%d)",
oldVid, newVid
);
/* Add the RID values for any other check-ins that have been merged into
** the current check-out. */
db_multi_exec(
"INSERT OR IGNORE INTO idMap(oldrid, newrid)"
" SELECT vmerge.merge, blob.rid FROM vmerge, blob"
" WHERE blob.uuid=vmerge.mhash;"
);
/* Add RID values for files in the current check-out */
db_multi_exec(
"CREATE TEMP TABLE hashoffile(name TEXT PRIMARY KEY, hash TEXT)"
"WITHOUT ROWID;"
"INSERT INTO hashoffile(name,hash)"
" SELECT filename, uuid FROM vvar, files_of_checkin(vvar.value)"
" WHERE vvar.name='checkout-hash';"
"INSERT OR IGNORE INTO idMap(oldrid, newrid)"
" SELECT vfile.rid, blob.rid FROM vfile, hashoffile, blob"
" WHERE hashoffile.name=coalesce(vfile.origname,vfile.pathname)"
" AND blob.uuid=hashoffile.hash;"
);
/* Add RID values for merged-in files */
db_multi_exec(
"INSERT OR IGNORE INTO idMap(oldrid, newrid)"
" SELECT vfile.mrid, blob.rid FROM vfile, blob"
" WHERE blob.uuid=vfile.mhash;"
);
if( dryRun ){
Stmt q;
db_prepare(&q, "SELECT oldrid, newrid, blob.uuid"
" FROM idMap, blob WHERE blob.rid=idMap.newrid");
while( db_step(&q)==SQLITE_ROW ){
fossil_print("%8d -> %8d %.25s\n",
db_column_int(&q,0),
db_column_int(&q,1),
db_column_text(&q,2));
}
db_finalize(&q);
}
/* Verify that all RID values in the VFILE table and VMERGE table have
** been resolved. */
zUnresolved = db_text("",
"WITH allrid(x) AS ("
" SELECT rid FROM vfile"
" UNION SELECT mrid FROM vfile"
" UNION SELECT merge FROM vmerge"
" UNION SELECT %d"
")"
"SELECT group_concat(x,' ') FROM allrid"
" WHERE x NOT IN (SELECT oldrid FROM idMap);",
oldVid
);
if( zUnresolved[0] ){
fossil_fatal("Unresolved RID values: %s\n", zUnresolved);
}
/* Make the changes to the VFILE and VMERGE tables */
if( !dryRun ){
db_multi_exec(
"UPDATE vfile"
" SET rid=(SELECT newrid FROM idMap WHERE oldrid=vfile.rid)"
" WHERE vid=%d AND rid>0;", oldVid);
db_multi_exec(
"UPDATE vfile"
" SET mrid=(SELECT newrid FROM idMap WHERE oldrid=vfile.mrid)"
" WHERE vid=%d AND mrid>0;", oldVid);
db_multi_exec(
"UPDATE vfile"
" SET vid=%d"
" WHERE vid=%d", newVid, oldVid);
db_multi_exec(
"UPDATE vmerge"
" SET merge=(SELECT newrid FROM idMap WHERE oldrid=vmerge.merge);");
db_lset_int("checkout",newVid);
}
/* Clear out the TEMP tables we constructed */
db_multi_exec(
"DROP TABLE idMap;"
"DROP TABLE hashoffile;"
);
}
|