[Python-checkins] python/nondist/sandbox/setuptools/setuptools/command egg_info.py, 1.12, 1.13

pje@users.sourceforge.net pje at users.sourceforge.net
Sun Aug 21 23:49:49 CEST 2005


Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3737/setuptools/command

Modified Files:
	egg_info.py 
Log Message:
Parse .svn/entries directly instead of using 'svn info' to obtain a 
revision number.  (Christopher Lenz reported that svn info's output is
different in non-English locales.)


Index: egg_info.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/egg_info.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- egg_info.py	13 Aug 2005 23:04:08 -0000	1.12
+++ egg_info.py	21 Aug 2005 21:49:39 -0000	1.13
@@ -3,7 +3,7 @@
 Create a distribution's .egg-info directory and contents"""
 
 # This module should be kept compatible with Python 2.3
-import os
+import os, re
 from setuptools import Command
 from distutils.errors import *
 from distutils import log
@@ -141,26 +141,26 @@
         return safe_version(version)
 
     def get_svn_revision(self):
-        stdin, stdout = os.popen4("svn info -R"); stdin.close()
-        result = stdout.read(); stdout.close()
-        import re
-        revisions = [
-            int(match.group(1))
-                for match in re.finditer(r'Last Changed Rev: (\d+)', result)
-        ]
-        if not revisions:
-            raise DistutilsError("svn info error: %s" % result.strip())
-        return str(max(revisions))
-
-
-
-
-
-
-
-
-
-
+        revision = 0
+        urlre = re.compile('url="([^"]+)"')
+        revre = re.compile('committed-rev="(\d+)"')
+        for base,dirs,files in os.walk(os.curdir):
+            if '.svn' not in dirs:
+                dirs[:] = []
+                continue    # no sense walking uncontrolled subdirs
+            dirs.remove('.svn')
+            f = open(os.path.join(base,'.svn','entries'))
+            data = f.read()
+            f.close()
+            dirurl = urlre.search(data).group(1)    # get repository URL
+            if base==os.curdir:
+                base_url = dirurl+'/'   # save the root url
+            elif not dirurl.startswith(base_url):
+                dirs[:] = []
+                continue    # not part of the same svn tree, skip it
+            for match in revre.finditer(data):
+                revision = max(revision, int(match.group(1)))
+        return str(revision)
 
 def write_pkg_info(cmd, basename, filename):
     log.info("writing %s", filename)



More information about the Python-checkins mailing list