Show More
@@ -57,6 +57,15 dependencies = [ | |||
|
57 | 57 | ] |
|
58 | 58 | |
|
59 | 59 | [[package]] |
|
60 | name = "block-buffer" | |
|
61 | version = "0.9.0" | |
|
62 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
63 | checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" | |
|
64 | dependencies = [ | |
|
65 | "generic-array", | |
|
66 | ] | |
|
67 | ||
|
68 | [[package]] | |
|
60 | 69 | name = "byteorder" |
|
61 | 70 | version = "1.3.4" |
|
62 | 71 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -138,6 +147,15 source = "registry+https://github.com/ru | |||
|
138 | 147 | checksum = "cd51eab21ab4fd6a3bf889e2d0958c0a6e3a61ad04260325e919e652a2a62826" |
|
139 | 148 | |
|
140 | 149 | [[package]] |
|
150 | name = "cpufeatures" | |
|
151 | version = "0.1.4" | |
|
152 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
153 | checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8" | |
|
154 | dependencies = [ | |
|
155 | "libc", | |
|
156 | ] | |
|
157 | ||
|
158 | [[package]] | |
|
141 | 159 | name = "cpython" |
|
142 | 160 | version = "0.5.2" |
|
143 | 161 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -254,6 +272,15 source = "registry+https://github.com/ru | |||
|
254 | 272 | checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" |
|
255 | 273 | |
|
256 | 274 | [[package]] |
|
275 | name = "digest" | |
|
276 | version = "0.9.0" | |
|
277 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
278 | checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" | |
|
279 | dependencies = [ | |
|
280 | "generic-array", | |
|
281 | ] | |
|
282 | ||
|
283 | [[package]] | |
|
257 | 284 | name = "either" |
|
258 | 285 | version = "1.6.1" |
|
259 | 286 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -308,16 +335,14 dependencies = [ | |||
|
308 | 335 | ] |
|
309 | 336 | |
|
310 | 337 | [[package]] |
|
311 | name = "fuchsia-cprng" | |
|
312 |
version = "0.1 |
|
|
338 | name = "generic-array" | |
|
339 | version = "0.14.4" | |
|
313 | 340 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
314 | checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" | |
|
315 | ||
|
316 | [[package]] | |
|
317 | name = "gcc" | |
|
318 | version = "0.3.55" | |
|
319 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
320 | checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" | |
|
341 | checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" | |
|
342 | dependencies = [ | |
|
343 | "typenum", | |
|
344 | "version_check", | |
|
345 | ] | |
|
321 | 346 | |
|
322 | 347 | [[package]] |
|
323 | 348 | name = "getrandom" |
@@ -364,13 +389,13 dependencies = [ | |||
|
364 | 389 | "memmap", |
|
365 | 390 | "micro-timer", |
|
366 | 391 | "pretty_assertions", |
|
367 |
"rand |
|
|
392 | "rand", | |
|
368 | 393 | "rand_distr", |
|
369 | 394 | "rand_pcg", |
|
370 | 395 | "rayon", |
|
371 | 396 | "regex", |
|
372 | "rust-crypto", | |
|
373 | 397 | "same-file", |
|
398 | "sha-1", | |
|
374 | 399 | "tempfile", |
|
375 | 400 | "twox-hash", |
|
376 | 401 | "zstd", |
@@ -413,7 +438,7 source = "registry+https://github.com/ru | |||
|
413 | 438 | checksum = "3ca8957e71f04a205cb162508f9326aea04676c8dfd0711220190d6b83664f3f" |
|
414 | 439 | dependencies = [ |
|
415 | 440 | "bitmaps", |
|
416 |
"rand_core |
|
|
441 | "rand_core", | |
|
417 | 442 | "rand_xoshiro", |
|
418 | 443 | "sized-chunks", |
|
419 | 444 | "typenum", |
@@ -563,6 +588,12 dependencies = [ | |||
|
563 | 588 | ] |
|
564 | 589 | |
|
565 | 590 | [[package]] |
|
591 | name = "opaque-debug" | |
|
592 | version = "0.3.0" | |
|
593 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
594 | checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" | |
|
595 | ||
|
596 | [[package]] | |
|
566 | 597 | name = "output_vt100" |
|
567 | 598 | version = "0.1.2" |
|
568 | 599 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -666,29 +697,6 dependencies = [ | |||
|
666 | 697 | |
|
667 | 698 | [[package]] |
|
668 | 699 | name = "rand" |
|
669 | version = "0.3.23" | |
|
670 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
671 | checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" | |
|
672 | dependencies = [ | |
|
673 | "libc", | |
|
674 | "rand 0.4.6", | |
|
675 | ] | |
|
676 | ||
|
677 | [[package]] | |
|
678 | name = "rand" | |
|
679 | version = "0.4.6" | |
|
680 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
681 | checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" | |
|
682 | dependencies = [ | |
|
683 | "fuchsia-cprng", | |
|
684 | "libc", | |
|
685 | "rand_core 0.3.1", | |
|
686 | "rdrand", | |
|
687 | "winapi", | |
|
688 | ] | |
|
689 | ||
|
690 | [[package]] | |
|
691 | name = "rand" | |
|
692 | 700 | version = "0.7.3" |
|
693 | 701 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
694 | 702 | checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" |
@@ -696,7 +704,7 dependencies = [ | |||
|
696 | 704 | "getrandom", |
|
697 | 705 | "libc", |
|
698 | 706 | "rand_chacha", |
|
699 |
"rand_core |
|
|
707 | "rand_core", | |
|
700 | 708 | "rand_hc", |
|
701 | 709 | ] |
|
702 | 710 | |
@@ -707,26 +715,11 source = "registry+https://github.com/ru | |||
|
707 | 715 | checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" |
|
708 | 716 | dependencies = [ |
|
709 | 717 | "ppv-lite86", |
|
710 |
"rand_core |
|
|
718 | "rand_core", | |
|
711 | 719 | ] |
|
712 | 720 | |
|
713 | 721 | [[package]] |
|
714 | 722 | name = "rand_core" |
|
715 | version = "0.3.1" | |
|
716 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
717 | checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" | |
|
718 | dependencies = [ | |
|
719 | "rand_core 0.4.2", | |
|
720 | ] | |
|
721 | ||
|
722 | [[package]] | |
|
723 | name = "rand_core" | |
|
724 | version = "0.4.2" | |
|
725 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
726 | checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" | |
|
727 | ||
|
728 | [[package]] | |
|
729 | name = "rand_core" | |
|
730 | 723 | version = "0.5.1" |
|
731 | 724 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
732 | 725 | checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" |
@@ -740,7 +733,7 version = "0.2.2" | |||
|
740 | 733 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
741 | 734 | checksum = "96977acbdd3a6576fb1d27391900035bf3863d4a16422973a409b488cf29ffb2" |
|
742 | 735 | dependencies = [ |
|
743 |
"rand |
|
|
736 | "rand", | |
|
744 | 737 | ] |
|
745 | 738 | |
|
746 | 739 | [[package]] |
@@ -749,7 +742,7 version = "0.2.0" | |||
|
749 | 742 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
750 | 743 | checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" |
|
751 | 744 | dependencies = [ |
|
752 |
"rand_core |
|
|
745 | "rand_core", | |
|
753 | 746 | ] |
|
754 | 747 | |
|
755 | 748 | [[package]] |
@@ -758,7 +751,7 version = "0.2.1" | |||
|
758 | 751 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
759 | 752 | checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" |
|
760 | 753 | dependencies = [ |
|
761 |
"rand_core |
|
|
754 | "rand_core", | |
|
762 | 755 | ] |
|
763 | 756 | |
|
764 | 757 | [[package]] |
@@ -767,7 +760,7 version = "0.4.0" | |||
|
767 | 760 | source = "registry+https://github.com/rust-lang/crates.io-index" |
|
768 | 761 | checksum = "a9fcdd2e881d02f1d9390ae47ad8e5696a9e4be7b547a1da2afbc61973217004" |
|
769 | 762 | dependencies = [ |
|
770 |
"rand_core |
|
|
763 | "rand_core", | |
|
771 | 764 | ] |
|
772 | 765 | |
|
773 | 766 | [[package]] |
@@ -796,15 +789,6 dependencies = [ | |||
|
796 | 789 | ] |
|
797 | 790 | |
|
798 | 791 | [[package]] |
|
799 | name = "rdrand" | |
|
800 | version = "0.4.0" | |
|
801 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
802 | checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" | |
|
803 | dependencies = [ | |
|
804 | "rand_core 0.3.1", | |
|
805 | ] | |
|
806 | ||
|
807 | [[package]] | |
|
808 | 792 | name = "redox_syscall" |
|
809 | 793 | version = "0.1.57" |
|
810 | 794 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -855,25 +839,6 dependencies = [ | |||
|
855 | 839 | ] |
|
856 | 840 | |
|
857 | 841 | [[package]] |
|
858 | name = "rust-crypto" | |
|
859 | version = "0.2.36" | |
|
860 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
861 | checksum = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" | |
|
862 | dependencies = [ | |
|
863 | "gcc", | |
|
864 | "libc", | |
|
865 | "rand 0.3.23", | |
|
866 | "rustc-serialize", | |
|
867 | "time", | |
|
868 | ] | |
|
869 | ||
|
870 | [[package]] | |
|
871 | name = "rustc-serialize" | |
|
872 | version = "0.3.24" | |
|
873 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
874 | checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" | |
|
875 | ||
|
876 | [[package]] | |
|
877 | 842 | name = "same-file" |
|
878 | 843 | version = "1.0.6" |
|
879 | 844 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -889,6 +854,19 source = "registry+https://github.com/ru | |||
|
889 | 854 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" |
|
890 | 855 | |
|
891 | 856 | [[package]] |
|
857 | name = "sha-1" | |
|
858 | version = "0.9.6" | |
|
859 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
|
860 | checksum = "8c4cfa741c5832d0ef7fab46cabed29c2aae926db0b11bb2069edd8db5e64e16" | |
|
861 | dependencies = [ | |
|
862 | "block-buffer", | |
|
863 | "cfg-if 1.0.0", | |
|
864 | "cpufeatures", | |
|
865 | "digest", | |
|
866 | "opaque-debug", | |
|
867 | ] | |
|
868 | ||
|
869 | [[package]] | |
|
892 | 870 | name = "sized-chunks" |
|
893 | 871 | version = "0.6.2" |
|
894 | 872 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -929,7 +907,7 checksum = "7a6e24d9338a0a5be79593e2fa15 | |||
|
929 | 907 | dependencies = [ |
|
930 | 908 | "cfg-if 0.1.10", |
|
931 | 909 | "libc", |
|
932 |
"rand |
|
|
910 | "rand", | |
|
933 | 911 | "redox_syscall", |
|
934 | 912 | "remove_dir_all", |
|
935 | 913 | "winapi", |
@@ -980,7 +958,7 source = "registry+https://github.com/ru | |||
|
980 | 958 | checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59" |
|
981 | 959 | dependencies = [ |
|
982 | 960 | "cfg-if 0.1.10", |
|
983 |
"rand |
|
|
961 | "rand", | |
|
984 | 962 | "static_assertions", |
|
985 | 963 | ] |
|
986 | 964 |
@@ -21,6 +21,7 rand_pcg = "0.2.1" | |||
|
21 | 21 | rand_distr = "0.2.2" |
|
22 | 22 | rayon = "1.3.0" |
|
23 | 23 | regex = "1.3.9" |
|
24 | sha-1 = "0.9.6" | |
|
24 | 25 | twox-hash = "1.5.0" |
|
25 | 26 | same-file = "1.0.6" |
|
26 | 27 | tempfile = "3.1.0" |
@@ -29,7 +30,6 micro-timer = "0.3.0" | |||
|
29 | 30 | log = "0.4.8" |
|
30 | 31 | memmap = "0.7.0" |
|
31 | 32 | zstd = "0.5.3" |
|
32 | rust-crypto = "0.2.36" | |
|
33 | 33 | format-bytes = "0.2.2" |
|
34 | 34 | |
|
35 | 35 | # We don't use the `miniz-oxide` backend to not change rhg benchmarks and until |
@@ -1,5 +1,4 | |||
|
1 | use crypto::digest::Digest; | |
|
2 | use crypto::sha1::Sha1; | |
|
1 | use sha1::{Digest, Sha1}; | |
|
3 | 2 | |
|
4 | 3 | #[derive(PartialEq, Debug)] |
|
5 | 4 | #[allow(non_camel_case_types)] |
@@ -621,13 +620,7 fn hash_encode(src: &[u8]) -> Vec<u8> { | |||
|
621 | 620 | panic!("path_encode::hash_encore: string too long: {}", baselen) |
|
622 | 621 | }; |
|
623 | 622 | let dirlen = encode_dir(Some(&mut dired[..]), src); |
|
624 | let sha = { | |
|
625 | let mut hasher = Sha1::new(); | |
|
626 | hasher.input(&dired[..dirlen]); | |
|
627 | let mut hash = vec![0; 20]; | |
|
628 | hasher.result(&mut hash); | |
|
629 | hash | |
|
630 | }; | |
|
623 | let sha = Sha1::digest(&dired[..dirlen]); | |
|
631 | 624 | let lowerlen = lower_encode(Some(&mut lowered[..]), &dired[..dirlen][5..]); |
|
632 | 625 | let auxlen = aux_encode(Some(&mut auxed[..]), &lowered[..lowerlen]); |
|
633 | 626 | hash_mangle(&auxed[..auxlen], &sha) |
@@ -4,10 +4,9 use std::ops::Deref; | |||
|
4 | 4 | use std::path::Path; |
|
5 | 5 | |
|
6 | 6 | use byteorder::{BigEndian, ByteOrder}; |
|
7 | use crypto::digest::Digest; | |
|
8 | use crypto::sha1::Sha1; | |
|
9 | 7 | use flate2::read::ZlibDecoder; |
|
10 | 8 | use micro_timer::timed; |
|
9 | use sha1::{Digest, Sha1}; | |
|
11 | 10 | use zstd; |
|
12 | 11 | |
|
13 | 12 | use super::index::Index; |
@@ -221,7 +220,7 impl Revlog { | |||
|
221 | 220 | None => &NULL_NODE, |
|
222 | 221 | }; |
|
223 | 222 | |
|
224 |
hash(data, h1.as_bytes(), h2.as_bytes()) |
|
|
223 | &hash(data, h1.as_bytes(), h2.as_bytes()) == expected | |
|
225 | 224 | } |
|
226 | 225 | |
|
227 | 226 | /// Build the full data of a revision out its snapshot |
@@ -361,20 +360,22 pub fn get_version(index_bytes: &[u8]) - | |||
|
361 | 360 | } |
|
362 | 361 | |
|
363 | 362 | /// Calculate the hash of a revision given its data and its parents. |
|
364 | fn hash(data: &[u8], p1_hash: &[u8], p2_hash: &[u8]) -> Vec<u8> { | |
|
363 | fn hash( | |
|
364 | data: &[u8], | |
|
365 | p1_hash: &[u8], | |
|
366 | p2_hash: &[u8], | |
|
367 | ) -> [u8; NODE_BYTES_LENGTH] { | |
|
365 | 368 | let mut hasher = Sha1::new(); |
|
366 | 369 | let (a, b) = (p1_hash, p2_hash); |
|
367 | 370 | if a > b { |
|
368 |
hasher. |
|
|
369 |
hasher. |
|
|
371 | hasher.update(b); | |
|
372 | hasher.update(a); | |
|
370 | 373 | } else { |
|
371 |
hasher. |
|
|
372 |
hasher. |
|
|
374 | hasher.update(a); | |
|
375 | hasher.update(b); | |
|
373 | 376 | } |
|
374 |
hasher. |
|
|
375 | let mut hash = vec![0; NODE_BYTES_LENGTH]; | |
|
376 | hasher.result(&mut hash); | |
|
377 | hash | |
|
377 | hasher.update(data); | |
|
378 | *hasher.finalize().as_ref() | |
|
378 | 379 | } |
|
379 | 380 | |
|
380 | 381 | #[cfg(test)] |
General Comments 0
You need to be logged in to leave comments.
Login now