# HG changeset patch # User Matt Harbison # Date 2023-08-20 21:05:52 # Node ID 75b90a8eb168e67dc31d75bf30a37014ca0c5c68 # Parent 4803cea1e5ab2614c3fc0728a0f3bcb65e144bdd 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. diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -527,8 +527,8 @@ def trackedcmd(ui, repo, remotepath=None # 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(