Patchwork D6651: rust-utils: remove buggy assertion

login
register
mail settings
Submitter phabricator
Date July 17, 2019, 4:16 p.m.
Message ID <differential-rev-PHID-DREV-ze5npx2uw3pdvtlalw3p-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/40945/
State Superseded
Headers show

Comments

phabricator - July 17, 2019, 4:16 p.m.
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




To: Alphare, #hg-reviewers
Cc: durin42, kevincox, mercurial-devel
Yuya Nishihara - July 18, 2019, 1:43 p.m.
>   While this assertion had good intentions, it broke existing behavior with a
>   nasty panic.

So the hgignore parser doesn't handle `\#` correctly?

https://www.mercurial-scm.org/repo/hg-committed/file/5672bb73f61e/rust/hg-core/src/filepatterns.rs#l251
phabricator - July 18, 2019, 1:45 p.m.
yuja added a comment.


  >   While this assertion had good intentions, it broke existing behavior with a
  >   nasty panic.
  
  So the hgignore parser doesn't handle `\#` correctly?
  
  https://www.mercurial-scm.org/repo/hg-committed/file/5672bb73f61e/rust/hg-core/src/filepatterns.rs#l251

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6651/new/

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

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

Patch

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() {