Patchwork D9333: errors: raise InputError when line range to followlines() is out of bounds

login
register
mail settings
Submitter phabricator
Date Nov. 17, 2020, 12:28 a.m.
Message ID <differential-rev-PHID-DREV-tcv5smhf5yfvbdr6wlje-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47607/
State Superseded
Headers show

Comments

phabricator - Nov. 17, 2020, 12:28 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/mdiff.py
  tests/test-annotate.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-annotate.t b/tests/test-annotate.t
--- a/tests/test-annotate.t
+++ b/tests/test-annotate.t
@@ -960,7 +960,7 @@ 
   [10]
   $ hg log -r 'followlines(baz, 2:40)'
   abort: line range exceeds file size
-  [255]
+  [10]
   $ hg log -r 'followlines(baz, 2:4, startrev=20, descend=[1])'
   hg: parse error at 43: not a prefix: [
   (followlines(baz, 2:4, startrev=20, descend=[1])
diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
--- a/mercurial/mdiff.py
+++ b/mercurial/mdiff.py
@@ -199,7 +199,7 @@ 
         if hunkinrange((b1, (b2 - b1)), rangeb):
             filteredblocks.append(block)
     if lba is None or uba is None or uba < lba:
-        raise error.Abort(_(b'line range exceeds file size'))
+        raise error.InputError(_(b'line range exceeds file size'))
     return filteredblocks, (lba, uba)