summaryrefslogtreecommitdiff
path: root/setuptools/command
diff options
context:
space:
mode:
authorPhilip Thiem <ptthiem@gmail.com>2013-06-30 13:13:33 -0500
committerPhilip Thiem <ptthiem@gmail.com>2013-06-30 13:13:33 -0500
commit8d389a37b8237d9dfb3f2b92baf79acda9c5b3f1 (patch)
tree62369cfdccb56fb981581b373cc180956f44e6d8 /setuptools/command
parent82a8940be2ae4f000a95a964b0d945175a0a7cd7 (diff)
downloadpython-setuptools-git-8d389a37b8237d9dfb3f2b92baf79acda9c5b3f1.tar.gz
Added SVNTextEntries for the moment as a fallback for no SVN/Rev8-10
Added Externals processing for all formats Will use dir-prop[-base] as a fallback otherwise CMD. --HG-- extra : rebase_source : dc27f779f22d5f9795c425b92d34db29d62b495d
Diffstat (limited to 'setuptools/command')
-rwxr-xr-xsetuptools/command/egg_info.py36
-rwxr-xr-xsetuptools/command/sdist.py45
2 files changed, 14 insertions, 67 deletions
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py
index 7daaee0f..7ed50d73 100755
--- a/setuptools/command/egg_info.py
+++ b/setuptools/command/egg_info.py
@@ -9,6 +9,7 @@ from distutils.errors import *
from distutils import log
from setuptools.command.sdist import sdist
from setuptools.compat import basestring
+from setuptools import svn_util
from distutils.util import convert_path
from distutils.filelist import FileList as _FileList
from pkg_resources import parse_requirements, safe_name, parse_version, \
@@ -217,40 +218,21 @@ class egg_info(Command):
@staticmethod
def get_svn_revision():
revision = 0
- urlre = re.compile('url="([^"]+)"')
- revre = re.compile('committed-rev="(\d+)"')
- urlre11 = re.compile('<url>([^<>]+)</url>')
- revre11 = re.compile('<commit\s+[^>]*revision="(\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()
- if data.startswith('<?xml'):
- dirurl = urlre.search(data).group(1) # get repository URL
- localrev = max([int(m.group(1)) for m in revre.finditer(data)]+[0])
- else:
- try: svnver = int(data.splitlines()[0])
- except: svnver=-1
- if svnver<8:
- log.warn("unrecognized .svn/entries format; skipping %s", base)
- dirs[:] = []
- continue
- elif svnver > 10:
- p = _Popen(['svn', 'info', '--xml'], stdout=_PIPE, shell=(sys.platform=='win32'))
- data = unicode(p.communicate()[0], encoding='utf-8')
- dirurl = urlre11.search(data).group(1)
- localrev = max([int(m.group(1)) for m in revre11.finditer(data)]+[0])
- else:
- data = list(map(str.splitlines,data.split('\n\x0c\n')))
- del data[0][0] # get rid of the '8' or '9' or '10'
- dirurl = data[0][3]
- localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0])
+ enteries = svn_util.SVNEntries.load(base)
+ if not entries.is_valid:
+ log.warn(" get_svn_revision: Cannot determine how to read enteries.")
+ dirs[:] = []
+ continue
+
+ localrev = entries.parse_revsion()
+ dirurl = entries.get_url()
if base==os.curdir:
base_url = dirurl+'/' # save the root url
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py
index 39cd6043..e0c4b7e5 100755
--- a/setuptools/command/sdist.py
+++ b/setuptools/command/sdist.py
@@ -4,6 +4,7 @@ from distutils import log
from glob import glob
import os, re, sys, pkg_resources
from glob import glob
+from setuptools.svn_util import SVNEntries
READMES = ('README', 'README.rst', 'README.txt')
@@ -61,49 +62,13 @@ def _default_revctrl(dirname=''):
def externals_finder(dirname, filename):
"""Find any 'svn:externals' directories"""
- found = False
- f = open(filename,'rt')
- for line in iter(f.readline, ''): # can't use direct iter!
- parts = line.split()
- if len(parts)==2:
- kind,length = parts
- data = f.read(int(length))
- if kind=='K' and data=='svn:externals':
- found = True
- elif kind=='V' and found:
- f.close()
- break
- else:
- f.close()
- return
-
- for line in data.splitlines():
- parts = line.split()
- if parts:
- yield joinpath(dirname, parts[0])
-
+ for name in SVNEntries.load(dirname).get_external_dirs(filename):
+ yield joinpath(dirname, name)
-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('<?xml'):
- for match in entries_pattern.finditer(data):
- yield joinpath(dirname,unescape(match.group(1)))
- else:
- svnver=-1
- try: svnver = int(data.splitlines()[0])
- except: pass
- if svnver<8:
- log.warn("unrecognized .svn/entries format in %s", os.path.abspath(dirname))
- return
- for record in map(str.splitlines, data.split('\n\x0c\n')[1:]):
- # subversion 1.6/1.5/1.4
- if not record or len(record)>=6 and record[5]=="delete":
- continue # skip deleted
- yield joinpath(dirname, record[0])
+ for record in SVNEntries.load(dirname).get_undeleted_records():
+ yield joinpath(dirname, record)
finders = [