Commits

Jannis Leidel  committed e9f07d8

Removed default call of hg_file_finder and added exception handling for environments without Mercurial.

  • Participants
  • Parent commits 9daba9d

Comments (0)

Files changed (2)

 
 setup(
     name="setuptools_hg",
-    version='0.1.3',
+    version='0.1.4',
     author="Jannis Leidel",
     author_email="jannis@leidel.info",
     url="http://bitbucket.org/jezdez/setuptools_hg/",

File setuptools_hg.py

 
 import os
 import subprocess
+from distutils.errors import DistutilsSetupError
 
 try:
     from mercurial import hg, ui, cmdutil
     """
     Use the hg command to recursively find versioned files in dirname.
     """
-    proc = subprocess.Popen(['hg', 'locate'],
-                            stdin=subprocess.PIPE,
-                            stdout=subprocess.PIPE,
-                            stderr=subprocess.PIPE,
-                            cwd=dirname)
-    stdout, stderr = proc.communicate()
+    try:
+        proc = subprocess.Popen(['hg', 'locate'],
+                                stdin=subprocess.PIPE,
+                                stderr=subprocess.PIPE,
+                                stdout=subprocess.PIPE,
+                                cwd=dirname)
+        stdout, stderr = proc.communicate()
+    except Exception, e:
+        # Let's behave a bit nicer and return nothing if something fails.
+        return []
     return stdout.splitlines()
 
 def find_files_with_lib(dirname):
     if hg is None:
         return find_files_with_cmd(dirname)
     return find_files_with_lib(dirname)
-
-def main():
-    import sys
-    from pprint import pprint
-    try:
-        dirname = sys.argv[1]
-    except IndexError:
-        dirname = "."
-    pprint(list(hg_file_finder(dirname)))
-
-if __name__ == '__main__':
-    main()