D11007: shallowutil: narrow scope of try/except block
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Wed Jul 7 18:12:27 UTC 2021
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This will make this code easier to understand in the future.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D11007
AFFECTED FILES
hgext/remotefilelog/shallowutil.py
CHANGE DETAILS
diff --git a/hgext/remotefilelog/shallowutil.py b/hgext/remotefilelog/shallowutil.py
--- a/hgext/remotefilelog/shallowutil.py
+++ b/hgext/remotefilelog/shallowutil.py
@@ -247,6 +247,11 @@
size = None
try:
index = raw.index(b'\0')
+ except ValueError:
+ raise BadRemotefilelogHeader(
+ "unexpected remotefilelog header: illegal format"
+ )
+ if True:
header = raw[:index]
if header.startswith(b'v'):
# v1 and above, header starts with 'v'
@@ -263,10 +268,6 @@
else:
# v0, str(int(size)) is the header
size = int(header)
- except ValueError:
- raise BadRemotefilelogHeader(
- "unexpected remotefilelog header: illegal format"
- )
if size is None:
raise BadRemotefilelogHeader(
"unexpected remotefilelog header: no size found"
To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list