mq: avoid using `__file__` to compare modules
authorMatt Harbison <matt_harbison@yahoo.com>
Mon, 30 Dec 2019 12:17:02 -0500
changeset 44019 5bbd770d1324
parent 44018 f9d29e1d3354
child 44020 ac3cb5e05a38
mq: avoid using `__file__` to compare modules This fixes ~70 tests when using an oxidized executable, bringing the current failure count down to 92 (with 110 skips) when templates/ is copied next to the executable. Differential Revision: https://phab.mercurial-scm.org/D7778
hgext/mq.py
--- a/hgext/mq.py	Tue Dec 31 16:24:38 2019 -0500
+++ b/hgext/mq.py	Mon Dec 30 12:17:02 2019 -0500
@@ -68,6 +68,7 @@
 import os
 import re
 import shutil
+import sys
 from mercurial.i18n import _
 from mercurial.node import (
     bin,
@@ -4277,8 +4278,9 @@
 
     dotable(commands.table)
 
+    thismodule = sys.modules["hgext.mq"]
     for extname, extmodule in extensions.extensions():
-        if extmodule.__file__ != __file__:
+        if extmodule != thismodule:
             dotable(getattr(extmodule, 'cmdtable', {}))