D6651: rust-utils: remove buggy assertion

Alphare (Raphaël Gomès) phabricator at mercurial-scm.org
Wed Jul 17 12:16:38 EDT 2019


Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  While this assertion had good intentions, it broke existing behavior with a
  nasty panic.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6651

AFFECTED FILES
  rust/hg-core/src/utils.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/utils.rs b/rust/hg-core/src/utils.rs
--- a/rust/hg-core/src/utils.rs
+++ b/rust/hg-core/src/utils.rs
@@ -18,8 +18,7 @@
 where
     T: Clone + PartialEq,
 {
-    assert_eq!(from.len(), to.len());
-    if buf.len() < from.len() {
+    if buf.len() < from.len() || from.len() != to.len() {
         return;
     }
     for i in 0..=buf.len() - from.len() {



To: Alphare, #hg-reviewers
Cc: durin42, kevincox, mercurial-devel


More information about the Mercurial-devel mailing list