Commit 6861a1ff authored by PJ Eby's avatar PJ Eby

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
parent 720fbd0c
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Create a distribution's .egg-info directory and contents""" Create a distribution's .egg-info directory and contents"""
# This module should be kept compatible with Python 2.3 # This module should be kept compatible with Python 2.3
import os import os, re
from setuptools import Command from setuptools import Command
from distutils.errors import * from distutils.errors import *
from distutils import log from distutils import log
...@@ -141,26 +141,26 @@ class egg_info(Command): ...@@ -141,26 +141,26 @@ class egg_info(Command):
return safe_version(version) return safe_version(version)
def get_svn_revision(self): def get_svn_revision(self):
stdin, stdout = os.popen4("svn info -R"); stdin.close() revision = 0
result = stdout.read(); stdout.close() urlre = re.compile('url="([^"]+)"')
import re revre = re.compile('committed-rev="(\d+)"')
revisions = [ for base,dirs,files in os.walk(os.curdir):
int(match.group(1)) if '.svn' not in dirs:
for match in re.finditer(r'Last Changed Rev: (\d+)', result) dirs[:] = []
] continue # no sense walking uncontrolled subdirs
if not revisions: dirs.remove('.svn')
raise DistutilsError("svn info error: %s" % result.strip()) f = open(os.path.join(base,'.svn','entries'))
return str(max(revisions)) 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): def write_pkg_info(cmd, basename, filename):
log.info("writing %s", filename) log.info("writing %s", filename)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment