changeset 47550:db31bafa4ae3

shallowutil: narrow scope of try/except block This will make this code easier to understand in the future. Differential Revision: https://phab.mercurial-scm.org/D11007
author Augie Fackler <augie@google.com>
date Wed, 07 Jul 2021 11:47:02 -0400
parents e972077600e5
children b7a706e7843a
files hgext/remotefilelog/shallowutil.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/remotefilelog/shallowutil.py	Wed Jul 07 11:45:17 2021 -0400
+++ b/hgext/remotefilelog/shallowutil.py	Wed Jul 07 11:47:02 2021 -0400
@@ -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"