Merge lp:~soren/nova/version into lp:~hudson-openstack/nova/trunk

Proposed by Soren Hansen
Status: Merged
Approved by: Vish Ishaya
Approved revision: 525
Merged at revision: 530
Proposed branch: lp:~soren/nova/version
Merge into: lp:~hudson-openstack/nova/trunk
Prerequisite: lp:~anso/nova/newlog2
Diff against target: 149 lines (+65/-14)
5 files modified
.bzrignore (+1/-0)
doc/source/conf.py (+4/-3)
nova/log.py (+4/-10)
nova/version.py (+46/-0)
setup.py (+10/-1)
To merge this branch: bzr merge lp:~soren/nova/version
Reviewer Review Type Date Requested Status
Vish Ishaya (community) Approve
Eric Day (community) Approve
Todd Willey (community) Approve
Review via email: mp+45517@code.launchpad.net

Description of the change

Adds a mechanism to programmatically determine the version of Nova. The designated version is defined in nova/version.py. When running python setup.py from a bzr checkout, information about the bzr branch is put into nova/vcsversion.py which is conditionally imported in nova/version.py.

In short, you can now do:

>>> import nova.version
>>> nova.version.canonical_version_string()
'2011.1'
>>> nova.version.version_string()
'2011.1-dev'
>>> nova.version.version_string_with_vcs()
u'2011.1-newlog2:<email address hidden>'

It's also consumed by the docs and setup.py, so this ought to be the canonical place for updating version information from now on.

To post a comment you must log in.
Revision history for this message
Todd Willey (xtoddx) :
review: Approve
Revision history for this message
Eric Day (eday) wrote :

nova/version.py is missing a copyright header.

review: Needs Fixing
Revision history for this message
Soren Hansen (soren) wrote :

Good catch, Eric. Fixed. Thanks!

Revision history for this message
Eric Day (eday) wrote :

lgtm

review: Approve
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

The attempt to merge lp:~soren/nova/version into lp:nova failed. Below is the output from the failed tests.

Revision history for this message
Soren Hansen (soren) wrote :

/me puts on brown paper bag

Revision history for this message
Soren Hansen (soren) wrote :

There we go. I decided last second to change the function names, didn't follow through. Should be fine now.

Revision history for this message
Vish Ishaya (vishvananda) wrote :

lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2010-12-31 04:03:21 +0000
+++ .bzrignore 2011-01-07 23:07:09 +0000
@@ -12,3 +12,4 @@
12CA/serial*12CA/serial*
13CA/newcerts/*.pem13CA/newcerts/*.pem
14CA/private/cakey.pem14CA/private/cakey.pem
15nova/vcsversion.py
1516
=== modified file 'doc/source/conf.py'
--- doc/source/conf.py 2010-11-19 22:04:37 +0000
+++ doc/source/conf.py 2011-01-07 23:07:09 +0000
@@ -60,10 +60,11 @@
60# |version| and |release|, also used in various other places throughout the60# |version| and |release|, also used in various other places throughout the
61# built documents.61# built documents.
62#62#
63from nova import version as nova_version
64# The full version, including alpha/beta/rc tags.
65release = nova_version.version()
63# The short X.Y version.66# The short X.Y version.
64version = '2011.1'67version = nova_version.canonical_version_string()
65# The full version, including alpha/beta/rc tags.
66release = '2011.1-prerelease'
6768
68# The language for content autogenerated by Sphinx. Refer to documentation69# The language for content autogenerated by Sphinx. Refer to documentation
69# for a list of supported languages.70# for a list of supported languages.
7071
=== modified file 'nova/log.py'
--- nova/log.py 2011-01-06 20:08:14 +0000
+++ nova/log.py 2011-01-07 23:07:09 +0000
@@ -34,24 +34,19 @@
34import traceback34import traceback
3535
36from nova import flags36from nova import flags
37# TODO(todd): fix after version.py merge37from nova import version
38# from nova import version
3938
4039
41FLAGS = flags.FLAGS40FLAGS = flags.FLAGS
4241
43# TODO(todd): fix after version.py merge
44# '(%(name)s %(nova_version)s): %(levelname)s '
45flags.DEFINE_string('logging_context_format_string',42flags.DEFINE_string('logging_context_format_string',
46 '(%(name)s): %(levelname)s '43 '(%(name)s %(nova_version)s): %(levelname)s '
47 '[%(request_id)s %(user)s '44 '[%(request_id)s %(user)s '
48 '%(project)s] %(message)s',45 '%(project)s] %(message)s',
49 'format string to use for log messages')46 'format string to use for log messages')
5047
51# TODO(todd): fix after version.py merge
52# '(%(name)s %(nova_version)s): %(levelname)s [N/A] '
53flags.DEFINE_string('logging_default_format_string',48flags.DEFINE_string('logging_default_format_string',
54 '(%(name)s): %(levelname)s [N/A] '49 '(%(name)s %(nova_version)s): %(levelname)s [N/A] '
55 '%(message)s',50 '%(message)s',
56 'format string to use for log messages')51 'format string to use for log messages')
5752
@@ -162,8 +157,7 @@
162 extra = {}157 extra = {}
163 if context:158 if context:
164 extra.update(_dictify_context(context))159 extra.update(_dictify_context(context))
165 # TODO(todd): fix after version.py merge160 extra.update({"nova_version": version.version_string_with_vcs()})
166 #extra.update({"nova_version": version.string_with_vcs()})
167 logging.Logger._log(self, level, msg, args, exc_info, extra)161 logging.Logger._log(self, level, msg, args, exc_info, extra)
168162
169 def addHandler(self, handler):163 def addHandler(self, handler):
170164
=== added file 'nova/version.py'
--- nova/version.py 1970-01-01 00:00:00 +0000
+++ nova/version.py 2011-01-07 23:07:09 +0000
@@ -0,0 +1,46 @@
1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2011 OpenStack LLC
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17try:
18 from nova.vcsversion import version_info
19except ImportError:
20 version_info = {'branch_nick': u'LOCALBRANCH',
21 'revision_id': 'LOCALREVISION',
22 'revno': 0}
23
24NOVA_VERSION = ['2011', '1']
25YEAR, COUNT = NOVA_VERSION
26
27FINAL = False # This becomes true at Release Candidate time
28
29
30def canonical_version_string():
31 return '.'.join([YEAR, COUNT])
32
33
34def version_string():
35 if FINAL:
36 return canonical_version_string()
37 else:
38 return '%s-dev' % (canonical_version_string(),)
39
40
41def vcs_version_string():
42 return "%s:%s" % (version_info['branch_nick'], version_info['revision_id'])
43
44
45def version_string_with_vcs():
46 return "%s-%s" % (canonical_version_string(), vcs_version_string())
047
=== modified file 'setup.py'
--- setup.py 2011-01-04 05:23:35 +0000
+++ setup.py 2011-01-07 23:07:09 +0000
@@ -24,6 +24,15 @@
24from sphinx.setup_command import BuildDoc24from sphinx.setup_command import BuildDoc
2525
26from nova.utils import parse_mailmap, str_dict_replace26from nova.utils import parse_mailmap, str_dict_replace
27from nova import version
28
29if os.path.isdir('.bzr'):
30 with open("nova/vcsversion.py", 'w') as version_file:
31 vcs_cmd = subprocess.Popen(["bzr", "version-info", "--python"],
32 stdout=subprocess.PIPE)
33 vcsversion = vcs_cmd.communicate()[0]
34 version_file.write(vcsversion)
35
2736
28class local_BuildDoc(BuildDoc):37class local_BuildDoc(BuildDoc):
29 def run(self):38 def run(self):
@@ -49,7 +58,7 @@
49 sdist.run(self)58 sdist.run(self)
5059
51setup(name='nova',60setup(name='nova',
52 version='2011.1',61 version=version.canonical_version_string(),
53 description='cloud computing fabric controller',62 description='cloud computing fabric controller',
54 author='OpenStack',63 author='OpenStack',
55 author_email='nova@lists.launchpad.net',64 author_email='nova@lists.launchpad.net',