Index: utils/version.py =================================================================== --- utils/version.py (revision 10368) +++ utils/version.py (working copy) @@ -2,6 +2,7 @@ import os.path import re + def get_svn_revision(path=None): """ Returns the SVN revision in the form SVN-XXXX, @@ -19,20 +20,26 @@ path = django.__path__[0] entries_path = '%s/.svn/entries' % path - if os.path.exists(entries_path): - entries = open(entries_path, 'r').read() - # Versions >= 7 of the entries file are flat text. The first line is - # the version number. The next set of digits after 'dir' is the revision. - if re.match('(\d+)', entries): - rev_match = re.search('\d+\s+dir\s+(\d+)', entries) - if rev_match: - rev = rev_match.groups()[0] - # Older XML versions of the file specify revision as an attribute of - # the first entries node. - else: - from xml.dom import minidom - dom = minidom.parse(entries_path) - rev = dom.getElementsByTagName('entry')[0].getAttribute('revision') + try: + if os.path.exists(entries_path): + entries = open(entries_path, 'r').read() + # Versions >= 7 of the entries file are flat text. The first line + # is the version number. The next set of digits after 'dir' is the + # revision. + if re.match('(\d+)', entries): + rev_match = re.search('\d+\s+dir\s+(\d+)', entries) + if rev_match: + rev = rev_match.groups()[0] + # Older XML versions of the file specify revision as an attribute + # of the first entries node. + else: + from xml.dom import minidom + dom = minidom.parse(entries_path) + rev = dom.getElementsByTagName('entry')[0].getAttribute( + 'revision') + except: + # We may be running in an environment that doesn't allow file access. + pass if rev: return u'SVN-%s' % rev