Author: adrian
Date: 2007-08-20 22:08:02 -0500 (Mon, 20 Aug 2007)
New Revision: 5990
Added:
django/trunk/django/utils/version.py
Modified:
django/trunk/AUTHORS
django/trunk/django/__init__.py
Log:
Fixed #5215 -- Added Subversion revision number to Django version string.
Thanks for the patch, Deryck Hodge
Modified: django/trunk/AUTHORS
===================================================================
--- django/trunk/AUTHORS 2007-08-21 02:35:01 UTC (rev 5989)
+++ django/trunk/AUTHORS 2007-08-21 03:08:02 UTC (rev 5990)
@@ -136,6 +136,7 @@
Joe Heck <http://www.rhonabwy.com/wp/>
Joel Heenan <[EMAIL PROTECTED]>
[EMAIL PROTECTED]
+ Deryck Hodge <http://www.devurandom.org/>
Brett Hoerner <[EMAIL PROTECTED]>
Ian Holsman <http://feh.holsman.net/>
Kieran Holland <http://www.kieranholland.com>
Modified: django/trunk/django/__init__.py
===================================================================
--- django/trunk/django/__init__.py 2007-08-21 02:35:01 UTC (rev 5989)
+++ django/trunk/django/__init__.py 2007-08-21 03:08:02 UTC (rev 5990)
@@ -4,5 +4,6 @@
"Returns the version as a human-format string."
v = '.'.join([str(i) for i in VERSION[:-1]])
if VERSION[-1]:
- v += '-' + VERSION[-1]
+ from django.utils.version import get_svn_revision
+ v = '%s-%s-%s' % (v, VERSION[-1], get_svn_revision())
return v
Added: django/trunk/django/utils/version.py
===================================================================
--- django/trunk/django/utils/version.py (rev 0)
+++ django/trunk/django/utils/version.py 2007-08-21 03:08:02 UTC (rev
5990)
@@ -0,0 +1,33 @@
+import django
+import os.path
+import re
+
+def get_svn_revision():
+ """
+ Returns the SVN revision in the form SVN-XXXX,
+ where XXXX is the revision number.
+
+ Returns SVN-unknown if anything goes wrong, such as an unexpected
+ format of internal SVN files.
+ """
+ rev = None
+ entries_path = '%s/.svn/entries' % django.__path__[0]
+
+ 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')
+
+ if rev:
+ return u'SVN-%s' % rev
+ return u'SVN-unknown'
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---