aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-08-21 21:49:39 +0000
committerPJ Eby <distutils-sig@python.org>2005-08-21 21:49:39 +0000
commit6861a1ffbb22a507dd28571f7d3e48d9f0d089de (patch)
treef1323a9c3df4c3add4f5b91a52a9f7a4726c865c
parent720fbd0c7cfadc63870d088440fac3ab1f07178e (diff)
downloadexternal_python_setuptools-6861a1ffbb22a507dd28571f7d3e48d9f0d089de.tar.gz
external_python_setuptools-6861a1ffbb22a507dd28571f7d3e48d9f0d089de.tar.bz2
external_python_setuptools-6861a1ffbb22a507dd28571f7d3e48d9f0d089de.zip
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.) --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041212
-rwxr-xr-xsetuptools/command/egg_info.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py
index c05601a4..8bfc8d42 100755
--- a/setuptools/command/egg_info.py
+++ b/setuptools/command/egg_info.py
@@ -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 @@ class egg_info(Command):
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)