[Numpy-svn] r3164 - trunk/numpy/distutils

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Sep 15 16:06:50 CDT 2006


Author: oliphant
Date: 2006-09-15 16:06:47 -0500 (Fri, 15 Sep 2006)
New Revision: 3164

Modified:
   trunk/numpy/distutils/misc_util.py
Log:
Fix subversion number getting for 1.4 clients.  Also works for pre 1.4 clients.

Modified: trunk/numpy/distutils/misc_util.py
===================================================================
--- trunk/numpy/distutils/misc_util.py	2006-09-15 19:48:27 UTC (rev 3163)
+++ trunk/numpy/distutils/misc_util.py	2006-09-15 21:06:47 UTC (rev 3164)
@@ -1201,14 +1201,31 @@
     def _get_svn_revision(self,path):
         """ Return path's SVN revision number.
         """
-        entries = njoin(path,'.svn','entries')
         revision = None
+        try:
+            sin, sout = os.popen4('svnversion')
+            m = re.search(r'(?P<revision>\d+)', sout.read())
+            if m:
+                revision = int(m.group('revision'))
+                return revision
+        except:
+            pass
+        if sys.platform=='win32' and os.environ.get('SVN_ASP_DOT_NET_HACK',None):
+            entries = njoin(path,'_svn','entries')
+        else:
+            entries = njoin(path,'.svn','entries')
         if os.path.isfile(entries):
             f = open(entries)
-            m = re.search(r'revision="(?P<revision>\d+)"',f.read())
+            fstr = f.read()
             f.close()
-            if m:
-                revision = int(m.group('revision'))
+            if fstr[:5] == '<?xml':  # pre 1.4
+                m = re.search(r'revision="(?P<revision>\d+)"',fstr)
+                if m:
+                    revision = int(m.group('revision'))
+            else:  # non-xml entries file --- check to be sure that
+                m = re.search(r'dir[\n\r]+(?P<revision>\d+)', fstr)
+                if m:
+                    revision = int(m.group('revision'))
         return revision
 
     def get_version(self, version_file=None, version_variable=None):



More information about the Numpy-svn mailing list