Commit 7231e489 authored by PJ Eby's avatar PJ Eby

Support svn 1.4 working copy format (backport from trunk)

--HG--
branch : setuptools-0.6
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4051900
parent a1a8375c
...@@ -2563,6 +2563,9 @@ XXX ...@@ -2563,6 +2563,9 @@ XXX
Release Notes/Change History Release Notes/Change History
---------------------------- ----------------------------
0.6c3
* Fixed breakages caused by Subversion 1.4's new "working copy" format
0.6c2 0.6c2
* The ``ez_setup`` module displays the conflicting version of setuptools (and * The ``ez_setup`` module displays the conflicting version of setuptools (and
its installation location) when a script requests a version that's not its installation location) when a script requests a version that's not
......
...@@ -181,10 +181,33 @@ class egg_info(Command): ...@@ -181,10 +181,33 @@ class egg_info(Command):
import time; version += time.strftime("-%Y%m%d") import time; version += time.strftime("-%Y%m%d")
return version return version
def get_svn_revision(self): def get_svn_revision(self):
revision = 0 revision = 0
urlre = re.compile('url="([^"]+)"') urlre = re.compile('url="([^"]+)"')
revre = re.compile('committed-rev="(\d+)"') revre = re.compile('committed-rev="(\d+)"')
for base,dirs,files in os.walk(os.curdir): for base,dirs,files in os.walk(os.curdir):
if '.svn' not in dirs: if '.svn' not in dirs:
dirs[:] = [] dirs[:] = []
...@@ -193,16 +216,34 @@ class egg_info(Command): ...@@ -193,16 +216,34 @@ class egg_info(Command):
f = open(os.path.join(base,'.svn','entries')) f = open(os.path.join(base,'.svn','entries'))
data = f.read() data = f.read()
f.close() f.close()
dirurl = urlre.search(data).group(1) # get repository URL
if data.startswith('8'):
data = map(str.splitlines,data.split('\n\x0c\n'))
del data[0][0] # get rid of the '8'
dirurl = data[0][3]
localrev = max([int(d[9]) for d in data if len(d)>9])
elif data.startswith('<?xml'):
dirurl = urlre.search(data).group(1) # get repository URL
localrev = max([int(m.group(1)) for m in revre.finditer(data)])
else:
from warnings import warn
warn("unrecognized .svn/entries format; skipping "+base)
dirs[:] = []
continue
if base==os.curdir: if base==os.curdir:
base_url = dirurl+'/' # save the root url base_url = dirurl+'/' # save the root url
elif not dirurl.startswith(base_url): elif not dirurl.startswith(base_url):
dirs[:] = [] dirs[:] = []
continue # not part of the same svn tree, skip it continue # not part of the same svn tree, skip it
for match in revre.finditer(data): revision = max(revision, localrev)
revision = max(revision, int(match.group(1)))
return str(revision or get_pkg_info_revision()) return str(revision or get_pkg_info_revision())
def find_sources(self): def find_sources(self):
"""Generate SOURCES.txt manifest file""" """Generate SOURCES.txt manifest file"""
manifest_filename = os.path.join(self.egg_info,"SOURCES.txt") manifest_filename = os.path.join(self.egg_info,"SOURCES.txt")
......
...@@ -80,16 +80,31 @@ def externals_finder(dirname, filename): ...@@ -80,16 +80,31 @@ def externals_finder(dirname, filename):
yield joinpath(dirname, parts[0]) yield joinpath(dirname, parts[0])
entries_pattern = re.compile(r'name="([^"]+)"(?![^>]+deleted="true")', re.I)
def entries_finder(dirname, filename):
f = open(filename,'rU')
data = f.read()
f.close()
if data.startswith('8'): # subversion 1.4
for record in map(str.splitlines, data.split('\n\x0c\n')[1:]):
if not record or len(record)>=6 and record[5]=="delete":
continue # skip deleted
yield joinpath(dirname, record[0])
elif data.startswith('<?xml'):
for match in entries_pattern.finditer(data):
yield joinpath(dirname,unescape(match.group(1)))
else:
from warnings import warn
warn("unrecognized .svn/entries format in "+dirname)
finders = [ finders = [
(convert_path('CVS/Entries'), (convert_path('CVS/Entries'),
re_finder(re.compile(r"^\w?/([^/]+)/", re.M))), re_finder(re.compile(r"^\w?/([^/]+)/", re.M))),
(convert_path('.svn/entries'), (convert_path('.svn/entries'), entries_finder),
re_finder(
re.compile(r'name="([^"]+)"(?![^>]+deleted="true")', re.I),
unescape
)
),
(convert_path('.svn/dir-props'), externals_finder), (convert_path('.svn/dir-props'), externals_finder),
(convert_path('.svn/dir-prop-base'), externals_finder), # svn 1.4
] ]
...@@ -100,21 +115,6 @@ finders = [ ...@@ -100,21 +115,6 @@ finders = [
......
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