Commit f3a0651b authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Change versioning format to comply with PEP 440

* Make the version template file simply host the upcoming version with
  an optional dev or .dev postfix
* Change the snapshot version form to X.Y.devN+df.Z were N is the revno
  and Z the revid
parent 77be530b
......@@ -44,13 +44,15 @@ from collections import namedtuple
branch_type = namedtuple("branch_type", ["builds_snapshot", "builds_release",
"versioned", "allowed_version_re",
"debian_branch"])
VERSION_RE = "[0-9]+\.[0-9]+(\.[0-9]+)*" # pylint: disable=W1401
RC_RE = "rc[1-9][0-9]*"
VERSION_RE = r'[0-9]+\.[0-9]+(\.[0-9]+)*'
RC_RE = r'rc[1-9][0-9]*'
BRANCH_TYPES = {
"feature": branch_type(True, False, False, "^%snext$" % VERSION_RE,
"feature": branch_type(True, False, False,
"^%s(next|\.?dev)?$" % VERSION_RE,
"debian-develop"),
"develop": branch_type(True, False, False, "^%snext$" % VERSION_RE,
"develop": branch_type(True, False, False,
"^%s(next|\.?dev)?$" % VERSION_RE,
"debian-develop"),
"release": branch_type(True, True, True,
"^(?P<bverstr>%s)(%s)+$" % (VERSION_RE, RC_RE),
......
......@@ -58,34 +58,39 @@ def conflicts():
def get_release_version(develop_version):
version = develop_version.rstrip('next')
parts = version.split('.')
major_version = int(parts[0])
minor_version = int(parts[1])
# return str(major_version) + '.' + str(minor_version+1) + 'rc1'
return str(major_version) + '.' + str(minor_version+1)
'''Given a development version it will return the release version'''
# Old version scheme
if 'next' in develop_version:
version = develop_version.rstrip('next')
parts = version.split('.')
major = int(parts[0])
minor = int(parts[1])
return "%d.%d" % (major, minor+1)
# New version may or may not contain dev:
# 0.19 is fine, same as 0.19.dev or 0.19dev
return develop_version.rstrip('.dev').rstrip('dev')
def get_develop_version_from_release(release_version):
'''Given a release version it will return the next develop version'''
# version = re.sub('rc[0-9]+$', '', release_version)
version = release_version
parts = version.split('.')
major_version = int(parts[0])
minor_version = int(parts[1])
return str(major_version) + '.' + str(minor_version+1) + 'next'
major = int(parts[0])
minor = int(parts[1])
return "%d.%ddev" % (major, minor+1)
def get_hotfix_version(version):
"""Given a version it will return the next hotfix version"""
parts = version.split('.')
major_version = int(parts[0])
minor_version = int(parts[1])
if len(parts) > 2:
hotfix_version = int(parts[2])
else:
hotfix_version = 0
major = int(parts[0])
minor = int(parts[1])
hotfix = int(parts[2]) if len(parts) > 2 else 0
return str(major_version) + '.' + str(minor_version) + '.' \
+ str(hotfix_version+1)
return "%d.%d.%d" % (major, minor, hotfix+1)
class GitManager(object):
......@@ -267,7 +272,7 @@ class GitManager(object):
new_develop_version = "%snext" % version
upstream_branch = self.get_branch("hotfix", version)
# debian_branch = self.get_debian_branch("hotfix", version)
debian_branch = self.get_debian_branch("hotfix", version)
# create hotfix branch
repo.git.branch(upstream_branch, upstream)
......
......@@ -127,25 +127,30 @@ def python_version(base_version, vcs_info, mode):
b) a version is generated either in 'release' or in 'snapshot' mode
c) the choice of mode depends on the branch, see following table.
A python version is of the form A_NNN,
The older python version format was of the form A_NNN,
where A: X.Y.Z{,next,rcW} and NNN: a revision number for the commit,
as returned by vcs_info().
The new python version complies with PEP 440 and is of the form:
X.Y.Z{,rcW}.devNNN
were X.Y.Z denote the upcoming release.
For every combination of branch and mode, releases are numbered as follows:
BRANCH: / MODE: snapshot release
-------- ------------------------------
feature 0.14next_150 N/A
develop 0.14next_151 N/A
release 0.14rc2_249 0.14rc2
master N/A 0.14
hotfix 0.14.1rc6_121 0.14.1rc6
BRANCH: / MODE: old_snapshot new_snapshot release
-------- ---------------------------------------
feature 0.14next_150 0.15.dev150 N/A
develop 0.14next_151 0.15.dev151 N/A
release 0.14rc2_249 0.14rc2.dev249 0.14rc2
master N/A N/A 0.14
hotfix 0.14.1rc6_121 0.14.1rc6.dev121 0.14.1rc6
N/A 0.14.1
The suffix 'next' in a version name is used to denote the upcoming version,
the one being under development in the develop and release branches.
In the older form, the suffix 'next' in a version name used to denote the
upcoming version, the one being under development in the develop branch.
Version '0.14next' is the version following 0.14, and only lives on the
develop and feature branches.
develop and feature branches. In the newer form we can denote the upcoming
version either as 0.15dev or simply 0.15.
The suffix 'rc' is used to denote release candidates. 'rc' versions live
only in release and hotfix branches.
......@@ -240,11 +245,15 @@ def python_version(base_version, vcs_info, mode):
raise ValueError("Invalid mode '%s' in branch type '%s'" %
(mode, btypestr))
if snap:
v = "%s_%d_%s" % (base_version, vcs_info.revno, vcs_info.revid)
else:
v = base_version
return v
if 'next' in base_version:
# This is the old version format and we are in snapshot mode, otherwise
# validate_version() would have failed.
return "%s_%d_%s" % (base_version, vcs_info.revno, vcs_info.revid)
elif snap:
return "%s.dev%d+df.%s" % (base_version.rstrip('.dev').rstrip('dev'),
vcs_info.revno,
vcs_info.revid.replace('_', '.'))
return base_version
def debian_version_from_python_version(pyver):
......@@ -316,7 +325,13 @@ def debian_version_from_python_version(pyver):
True
"""
version = pyver.replace("_", "~").replace("rc", "~rc")
if "_" in pyver:
# This is the old format
version = pyver.replace("_", "~").replace("rc", "~rc")
else:
version = pyver.replace(
".dev", "~dev").replace("dev", "~dev").replace("rc", "~rc")
codename = utils.get_distribution_codename()
minor = str(get_revision(version, codename))
return version + "-" + minor + "~" + codename
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment