Fossil SCM

Store "fingerprint" and "checkout-hash" in the VVAR table whenever the working checkout changes.

drh 2019-01-10 21:07 repo-fingerprint
Commit e07139a05a361ed6c7619e50826bf3b0194fe3104d99fa53dbcac72eb59b7b5c
+1 -1
--- src/checkin.c
+++ src/checkin.c
@@ -2539,11 +2539,11 @@
25392539
"UPDATE vfile SET vid=%d;"
25402540
"UPDATE vfile SET rid=mrid, chnged=0, deleted=0, origname=NULL"
25412541
" WHERE is_selected(id);"
25422542
, vid, nvid
25432543
);
2544
- db_lset_int("checkout", nvid);
2544
+ db_set_checkout(nvid);
25452545
25462546
/* Update the isexe and islink columns of the vfile table */
25472547
db_prepare(&q,
25482548
"UPDATE vfile SET isexe=:exec, islink=:link"
25492549
" WHERE vid=:vid AND pathname=:path AND (isexe!=:exec OR islink!=:link)"
25502550
--- src/checkin.c
+++ src/checkin.c
@@ -2539,11 +2539,11 @@
2539 "UPDATE vfile SET vid=%d;"
2540 "UPDATE vfile SET rid=mrid, chnged=0, deleted=0, origname=NULL"
2541 " WHERE is_selected(id);"
2542 , vid, nvid
2543 );
2544 db_lset_int("checkout", nvid);
2545
2546 /* Update the isexe and islink columns of the vfile table */
2547 db_prepare(&q,
2548 "UPDATE vfile SET isexe=:exec, islink=:link"
2549 " WHERE vid=:vid AND pathname=:path AND (isexe!=:exec OR islink!=:link)"
2550
--- src/checkin.c
+++ src/checkin.c
@@ -2539,11 +2539,11 @@
2539 "UPDATE vfile SET vid=%d;"
2540 "UPDATE vfile SET rid=mrid, chnged=0, deleted=0, origname=NULL"
2541 " WHERE is_selected(id);"
2542 , vid, nvid
2543 );
2544 db_set_checkout(nvid);
2545
2546 /* Update the isexe and islink columns of the vfile table */
2547 db_prepare(&q,
2548 "UPDATE vfile SET isexe=:exec, islink=:link"
2549 " WHERE vid=:vid AND pathname=:path AND (isexe!=:exec OR islink!=:link)"
2550
+1 -1
--- src/checkout.c
+++ src/checkout.c
@@ -304,11 +304,11 @@
304304
vfile_to_disk(vid, 0, !g.fQuiet, promptFlag);
305305
}
306306
checkout_set_all_exe(vid);
307307
manifest_to_disk(vid);
308308
ensure_empty_dirs_created();
309
- db_lset_int("checkout", vid);
309
+ db_set_checkout(vid);
310310
undo_reset();
311311
db_multi_exec("DELETE FROM vmerge");
312312
if( !keepFlag && db_get_boolean("repo-cksum",1) ){
313313
vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
314314
vfile_aggregate_checksum_disk(vid, &cksum2);
315315
--- src/checkout.c
+++ src/checkout.c
@@ -304,11 +304,11 @@
304 vfile_to_disk(vid, 0, !g.fQuiet, promptFlag);
305 }
306 checkout_set_all_exe(vid);
307 manifest_to_disk(vid);
308 ensure_empty_dirs_created();
309 db_lset_int("checkout", vid);
310 undo_reset();
311 db_multi_exec("DELETE FROM vmerge");
312 if( !keepFlag && db_get_boolean("repo-cksum",1) ){
313 vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
314 vfile_aggregate_checksum_disk(vid, &cksum2);
315
--- src/checkout.c
+++ src/checkout.c
@@ -304,11 +304,11 @@
304 vfile_to_disk(vid, 0, !g.fQuiet, promptFlag);
305 }
306 checkout_set_all_exe(vid);
307 manifest_to_disk(vid);
308 ensure_empty_dirs_created();
309 db_set_checkout(vid);
310 undo_reset();
311 db_multi_exec("DELETE FROM vmerge");
312 if( !keepFlag && db_get_boolean("repo-cksum",1) ){
313 vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
314 vfile_aggregate_checksum_disk(vid, &cksum2);
315
+21 -2
--- src/db.c
+++ src/db.c
@@ -2872,11 +2872,11 @@
28722872
g.allowSymlinks = db_get_boolean("allow-symlinks",
28732873
db_allow_symlinks_by_default());
28742874
}
28752875
db_lset("repository", g.argv[2]);
28762876
db_record_repository_filename(g.argv[2]);
2877
- db_lset_int("checkout", 0);
2877
+ db_set_checkout(0);
28782878
azNewArgv[0] = g.argv[0];
28792879
g.argv = azNewArgv;
28802880
if( !emptyFlag ){
28812881
g.argc = 3;
28822882
if( g.zOpenRevision ){
@@ -3723,11 +3723,14 @@
37233723
** new fingerprint, use the most recent RCVFROM entry. (Set rcvid==0 to
37243724
** accomplish this.) When verifying an old fingerprint, use the same
37253725
** RCVFROM entry that generated the fingerprint in the first place.
37263726
**
37273727
** The fingerprint consists of the rcvid, a "/", and the MD5 checksum of
3728
-** the remaining fields of the RCVFROM table entry.
3728
+** the remaining fields of the RCVFROM table entry. MD5 is used for this
3729
+** because it is 4x faster than SHA3 and 5x faster than SHA1, and there
3730
+** are no security concerns - this is just a checksum, not a security
3731
+** token.
37293732
*/
37303733
char *db_fingerprint(int rcvid){
37313734
char *z = 0;
37323735
Blob sql = BLOB_INITIALIZER;
37333736
Stmt q;
@@ -3769,5 +3772,21 @@
37693772
}else if( g.argc!=2 ){
37703773
fossil_fatal("wrong number of arguments");
37713774
}
37723775
fossil_print("%z\n", db_fingerprint(rcvid));
37733776
}
3777
+
3778
+/*
3779
+** Set the value of the "checkout" entry in the VVAR table.
3780
+**
3781
+** Also set "fingerprint" and "checkout-hash".
3782
+*/
3783
+void db_set_checkout(int rid){
3784
+ char *z;
3785
+ db_lset_int("checkout", rid);
3786
+ z = db_text(0,"SELECT uuid FROM blob WHERE rid=%d",rid);
3787
+ db_lset("checkout-hash", z);
3788
+ fossil_free(z);
3789
+ z = db_fingerprint(0);
3790
+ db_lset("fingerprint", z);
3791
+ fossil_free(z);
3792
+}
37743793
--- src/db.c
+++ src/db.c
@@ -2872,11 +2872,11 @@
2872 g.allowSymlinks = db_get_boolean("allow-symlinks",
2873 db_allow_symlinks_by_default());
2874 }
2875 db_lset("repository", g.argv[2]);
2876 db_record_repository_filename(g.argv[2]);
2877 db_lset_int("checkout", 0);
2878 azNewArgv[0] = g.argv[0];
2879 g.argv = azNewArgv;
2880 if( !emptyFlag ){
2881 g.argc = 3;
2882 if( g.zOpenRevision ){
@@ -3723,11 +3723,14 @@
3723 ** new fingerprint, use the most recent RCVFROM entry. (Set rcvid==0 to
3724 ** accomplish this.) When verifying an old fingerprint, use the same
3725 ** RCVFROM entry that generated the fingerprint in the first place.
3726 **
3727 ** The fingerprint consists of the rcvid, a "/", and the MD5 checksum of
3728 ** the remaining fields of the RCVFROM table entry.
 
 
 
3729 */
3730 char *db_fingerprint(int rcvid){
3731 char *z = 0;
3732 Blob sql = BLOB_INITIALIZER;
3733 Stmt q;
@@ -3769,5 +3772,21 @@
3769 }else if( g.argc!=2 ){
3770 fossil_fatal("wrong number of arguments");
3771 }
3772 fossil_print("%z\n", db_fingerprint(rcvid));
3773 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3774
--- src/db.c
+++ src/db.c
@@ -2872,11 +2872,11 @@
2872 g.allowSymlinks = db_get_boolean("allow-symlinks",
2873 db_allow_symlinks_by_default());
2874 }
2875 db_lset("repository", g.argv[2]);
2876 db_record_repository_filename(g.argv[2]);
2877 db_set_checkout(0);
2878 azNewArgv[0] = g.argv[0];
2879 g.argv = azNewArgv;
2880 if( !emptyFlag ){
2881 g.argc = 3;
2882 if( g.zOpenRevision ){
@@ -3723,11 +3723,14 @@
3723 ** new fingerprint, use the most recent RCVFROM entry. (Set rcvid==0 to
3724 ** accomplish this.) When verifying an old fingerprint, use the same
3725 ** RCVFROM entry that generated the fingerprint in the first place.
3726 **
3727 ** The fingerprint consists of the rcvid, a "/", and the MD5 checksum of
3728 ** the remaining fields of the RCVFROM table entry. MD5 is used for this
3729 ** because it is 4x faster than SHA3 and 5x faster than SHA1, and there
3730 ** are no security concerns - this is just a checksum, not a security
3731 ** token.
3732 */
3733 char *db_fingerprint(int rcvid){
3734 char *z = 0;
3735 Blob sql = BLOB_INITIALIZER;
3736 Stmt q;
@@ -3769,5 +3772,21 @@
3772 }else if( g.argc!=2 ){
3773 fossil_fatal("wrong number of arguments");
3774 }
3775 fossil_print("%z\n", db_fingerprint(rcvid));
3776 }
3777
3778 /*
3779 ** Set the value of the "checkout" entry in the VVAR table.
3780 **
3781 ** Also set "fingerprint" and "checkout-hash".
3782 */
3783 void db_set_checkout(int rid){
3784 char *z;
3785 db_lset_int("checkout", rid);
3786 z = db_text(0,"SELECT uuid FROM blob WHERE rid=%d",rid);
3787 db_lset("checkout-hash", z);
3788 fossil_free(z);
3789 z = db_fingerprint(0);
3790 db_lset("fingerprint", z);
3791 fossil_free(z);
3792 }
3793
+1 -1
--- src/undo.c
+++ src/undo.c
@@ -164,11 +164,11 @@
164164
}
165165
}
166166
ncid = db_lget_int("undo_checkout", 0);
167167
ucid = db_lget_int("checkout", 0);
168168
db_lset_int("undo_checkout", ucid);
169
- db_lset_int("checkout", ncid);
169
+ db_set_checkout(ncid);
170170
}
171171
172172
/*
173173
** Reset the undo memory.
174174
*/
175175
--- src/undo.c
+++ src/undo.c
@@ -164,11 +164,11 @@
164 }
165 }
166 ncid = db_lget_int("undo_checkout", 0);
167 ucid = db_lget_int("checkout", 0);
168 db_lset_int("undo_checkout", ucid);
169 db_lset_int("checkout", ncid);
170 }
171
172 /*
173 ** Reset the undo memory.
174 */
175
--- src/undo.c
+++ src/undo.c
@@ -164,11 +164,11 @@
164 }
165 }
166 ncid = db_lget_int("undo_checkout", 0);
167 ucid = db_lget_int("checkout", 0);
168 db_lset_int("undo_checkout", ucid);
169 db_set_checkout(ncid);
170 }
171
172 /*
173 ** Reset the undo memory.
174 */
175
+1 -1
--- src/update.c
+++ src/update.c
@@ -573,11 +573,11 @@
573573
if( g.argc<=3 ){
574574
/* All files updated. Shift the current checkout to the target. */
575575
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
576576
checkout_set_all_exe(tid);
577577
manifest_to_disk(tid);
578
- db_lset_int("checkout", tid);
578
+ db_set_checkout(tid);
579579
}else{
580580
/* A subset of files have been checked out. Keep the current
581581
** checkout unchanged. */
582582
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
583583
}
584584
--- src/update.c
+++ src/update.c
@@ -573,11 +573,11 @@
573 if( g.argc<=3 ){
574 /* All files updated. Shift the current checkout to the target. */
575 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
576 checkout_set_all_exe(tid);
577 manifest_to_disk(tid);
578 db_lset_int("checkout", tid);
579 }else{
580 /* A subset of files have been checked out. Keep the current
581 ** checkout unchanged. */
582 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
583 }
584
--- src/update.c
+++ src/update.c
@@ -573,11 +573,11 @@
573 if( g.argc<=3 ){
574 /* All files updated. Shift the current checkout to the target. */
575 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
576 checkout_set_all_exe(tid);
577 manifest_to_disk(tid);
578 db_set_checkout(tid);
579 }else{
580 /* A subset of files have been checked out. Keep the current
581 ** checkout unchanged. */
582 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
583 }
584

Keyboard Shortcuts

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