1 | Index: utils/version.py
|
---|
2 | ===================================================================
|
---|
3 | --- utils/version.py (revision 10368)
|
---|
4 | +++ utils/version.py (working copy)
|
---|
5 | @@ -2,6 +2,7 @@
|
---|
6 | import os.path
|
---|
7 | import re
|
---|
8 |
|
---|
9 | +
|
---|
10 | def get_svn_revision(path=None):
|
---|
11 | """
|
---|
12 | Returns the SVN revision in the form SVN-XXXX,
|
---|
13 | @@ -19,20 +20,26 @@
|
---|
14 | path = django.__path__[0]
|
---|
15 | entries_path = '%s/.svn/entries' % path
|
---|
16 |
|
---|
17 | - if os.path.exists(entries_path):
|
---|
18 | - entries = open(entries_path, 'r').read()
|
---|
19 | - # Versions >= 7 of the entries file are flat text. The first line is
|
---|
20 | - # the version number. The next set of digits after 'dir' is the revision.
|
---|
21 | - if re.match('(\d+)', entries):
|
---|
22 | - rev_match = re.search('\d+\s+dir\s+(\d+)', entries)
|
---|
23 | - if rev_match:
|
---|
24 | - rev = rev_match.groups()[0]
|
---|
25 | - # Older XML versions of the file specify revision as an attribute of
|
---|
26 | - # the first entries node.
|
---|
27 | - else:
|
---|
28 | - from xml.dom import minidom
|
---|
29 | - dom = minidom.parse(entries_path)
|
---|
30 | - rev = dom.getElementsByTagName('entry')[0].getAttribute('revision')
|
---|
31 | + try:
|
---|
32 | + if os.path.exists(entries_path):
|
---|
33 | + entries = open(entries_path, 'r').read()
|
---|
34 | + # Versions >= 7 of the entries file are flat text. The first line
|
---|
35 | + # is the version number. The next set of digits after 'dir' is the
|
---|
36 | + # revision.
|
---|
37 | + if re.match('(\d+)', entries):
|
---|
38 | + rev_match = re.search('\d+\s+dir\s+(\d+)', entries)
|
---|
39 | + if rev_match:
|
---|
40 | + rev = rev_match.groups()[0]
|
---|
41 | + # Older XML versions of the file specify revision as an attribute
|
---|
42 | + # of the first entries node.
|
---|
43 | + else:
|
---|
44 | + from xml.dom import minidom
|
---|
45 | + dom = minidom.parse(entries_path)
|
---|
46 | + rev = dom.getElementsByTagName('entry')[0].getAttribute(
|
---|
47 | + 'revision')
|
---|
48 | + except:
|
---|
49 | + # We may be running in an environment that doesn't allow file access.
|
---|
50 | + pass
|
---|
51 |
|
---|
52 | if rev:
|
---|
53 | return u'SVN-%s' % rev
|
---|