changeset 50905:75b90a8eb168

narrow: hoist a variable to a higher level to avoid use-before-init warning In practice, this shouldn't generate an IOError, so there wouldn't have been a problem. But PyCharm didn't know that.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 20 Aug 2023 17:05:52 -0400
parents 4803cea1e5ab
children 9ed17632ad83
files hgext/narrow/narrowcommands.py
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/narrow/narrowcommands.py	Sun Aug 20 17:04:17 2023 -0400
+++ b/hgext/narrow/narrowcommands.py	Sun Aug 20 17:05:52 2023 -0400
@@ -527,8 +527,8 @@
     # import rules from a file
     newrules = opts.get('import_rules')
     if newrules:
+        filepath = os.path.join(encoding.getcwd(), newrules)
         try:
-            filepath = os.path.join(encoding.getcwd(), newrules)
             fdata = util.readfile(filepath)
         except IOError as inst:
             raise error.StorageError(