Description: Get version details from the Debian source package, rather than VCS
 We aren't building from a VCS checkout.
 Return 'release-MAJOR' as the branch name, and '' as the revision hash.
 Change the version that appears in sys.version from revision to branch name
 (matching cpython).
Author: Stefano Rivera <stefanor@debian.org>
Forwarded: not-needed
Last-Update: 2011-12-11

--- a/pypy/tool/version.py
+++ b/pypy/tool/version.py
@@ -18,6 +18,16 @@
 def get_repo_version_info(hgexe=None):
     '''Obtain version information by invoking the 'hg' or 'git' commands.'''
 
+    # Debian: built from a source tarball
+    p = Popen(('dpkg-parsechangelog',), stdout=PIPE, cwd=pypyroot)
+    if p.wait() != 0:
+        maywarn(p.stderr.read(), 'dpkg-parsechangelog')
+        return default_retval
+    for line in p.stdout.read().split('\n'):
+        if line.split(':', 1)[0].strip() == 'Version':
+            version = line.split(':', 1)[1].strip()
+            return 'PyPy', version, ''
+
     # Try to see if we can get info from Git if hgexe is not specified.
     if not hgexe:
         if os.path.isdir(os.path.join(pypyroot, '.git')):
--- a/pypy/module/sys/version.py
+++ b/pypy/module/sys/version.py
@@ -67,7 +67,7 @@
         CPYTHON_VERSION[0],
         CPYTHON_VERSION[1],
         CPYTHON_VERSION[2],
-        get_repo_version_info()[2],
+        get_repo_version_info()[1],
         date,
         time,
         ver,
