hggettext: ensure correct Mercurial is imported
authorMartin Geisler <mg@lazybytes.net>
Tue, 26 May 2009 20:12:37 +0200
changeset 8626 1fc1c77d4863
parent 8625 34754aa62cd8
child 8627 4c5b46f736f1
hggettext: ensure correct Mercurial is imported
i18n/hggettext
--- a/i18n/hggettext	Tue May 26 19:51:22 2009 +0200
+++ b/i18n/hggettext	Tue May 26 20:12:37 2009 +0200
@@ -20,8 +20,7 @@
 join the message cataloges to get the final catalog.
 """
 
-from mercurial import demandimport; demandimport.enable()
-import sys, inspect
+import os, sys, inspect
 
 
 def escape(s):
@@ -114,5 +113,11 @@
 
 
 if __name__ == "__main__":
+    # It is very important that we import the Mercurial modules from
+    # the source tree where hggettext is executed. Otherwise we might
+    # accidentally import and extract strings from a Mercurial
+    # installation mentioned in PYTHONPATH.
+    sys.path.insert(0, os.getcwd())
+    from mercurial import demandimport; demandimport.enable()
     for path in sys.argv[1:]:
         docstrings(path)