changeset 1099:cc706ddd9376

Use Mercurial via command line. The use of Mercurial through its API was a violation of its license since we were using GPL code from a LGPL program. Interfacing through the command line is the officially encouraged way for non-GPL programs to use Mercurial.
author Martin Geisler <mg@daimi.au.dk>
date Wed, 04 Feb 2009 23:40:56 +0100
parents 54a68af0a945
children e810a006c2bf
files setup.py
diffstat 1 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Wed Feb 04 23:06:07 2009 +0100
+++ b/setup.py	Wed Feb 04 23:40:56 2009 +0100
@@ -4,7 +4,7 @@
 # For a local install into ~/opt, use:  python setup.py --home=~/opt
 # For more options, use:                python setup.py --help
 
-# Copyright 2007, 2008 VIFF Development Team.
+# Copyright 2007, 2008, 2009 VIFF Development Team.
 #
 # This file is part of VIFF, the Virtual Ideal Functionality Framework.
 #
@@ -33,22 +33,22 @@
 class hg_sdist(sdist):
     def get_file_list(self):
         try:
-            # Attempt the import here so that users can run the other
-            # Distutils commands without needing Mercurial.
-            from mercurial import hg
-        except ImportError:
             from distutils.errors import DistutilsModuleError
-            raise DistutilsModuleError("could not import mercurial")
+            import subprocess
+            p = subprocess.Popen(['hg', 'manifest'], stdout=subprocess.PIPE)
+            exitcode = p.wait()
+            if exitcode != 0:
+                raise DistutilsModuleError("Mercurial exited with non-zero "
+                                           "exit code: %d" % exitcode)
+            files = p.stdout.read().strip().split('\n')
 
-        repo = hg.repository(None)
-        changeset = repo.changectx(None)
-        files = changeset.manifest().keys()
-
-        # Add the files *before* the normal manifest magic is done.
-        # That allows the manifest template to exclude some files
-        # tracked by hg and to include others.
-        self.filelist.extend(files)
-        sdist.get_file_list(self)
+            # Add the files *before* the normal manifest magic is
+            # done. That allows the manifest template to exclude some
+            # files tracked by hg and to include others.
+            self.filelist.extend(files)
+            sdist.get_file_list(self)
+        except OSError, e:
+            raise DistutilsModuleError("could not execute Mercurial: %s" % e)
 
 setup(name='viff',
       version=viff.__version__,