diff i18n/hggettext @ 8626:1fc1c77d4863

hggettext: ensure correct Mercurial is imported
author Martin Geisler <mg@lazybytes.net>
date Tue, 26 May 2009 20:12:37 +0200
parents de150a942ec8
children c904e76e3834
line wrap: on
line diff
--- 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)