Commits

Jannis Leidel  committed 74d30b0

Updated code to import version from correct location and fixed some other bugs

  • Participants
  • Parent commits 12873af

Comments (0)

Files changed (1)

File setuptools_hg.py

 system which uses the Python library by default and falls back to use the
 command line programm hg(1).
 """
-__version__ = '0.1.4'
+__version__ = '0.1.5'
 __author__ = 'Jannis Leidel'
 __all__ = ['hg_file_finder']
 
 import subprocess
 
 try:
+    from mercurial.__version__ import version
     from mercurial import hg, ui, cmdutil
-    from mercurial.repo import RepoError
-    import mercurial.version
-except:
+except Exception, e:
     hg = None
 
-if os.getenv('HG_SETUPTOOLS_FORCE_CMD'):
+OLD_VERSIONS = ('1.0', '1.0.1', '1.0.2')
+
+try:
+    from mercurial.repo import RepoError
+except:
+    from mercurial.error import RepoError
+
+if os.environ.get('HG_SETUPTOOLS_FORCE_CMD', False):
     hg = None
 
 def find_files_with_cmd(dirname="."):
                                 stdout=subprocess.PIPE,
                                 cwd=dirname)
         stdout, stderr = proc.communicate()
-    except Exception, e:
+    except:
         # Let's behave a bit nicer and return nothing if something fails.
         return []
     return stdout.splitlines()
     Use the Mercurial library to recursively find versioned files in dirname.
     """
     try:
-        version = mercurial.version.get_version()
-        try:
-            repo = hg.repository(ui.ui(), dirname)
-        except RepoError:
-            return
-
+        repo = hg.repository(ui.ui(), path=dirname)
         # tuple of (modified, added, removed, deleted, unknown, ignored, clean)
         modified, added, removed, deleted, unknown = repo.status()[:5]
 
         # or have been deleted, removed, or have an unknown status
         excluded = removed + deleted + unknown
 
-        if version in ('1.0', '1.0.1', '1.0.2'):
+        if version in OLD_VERSIONS:
             from mercurial import util
             node = None
             for src, abs, rel, exact in cmdutil.walk(repo, [], {}, node=node,