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
1=== modified file '.bzrignore'
2--- .bzrignore 2010-12-31 04:03:21 +0000
3+++ .bzrignore 2011-01-07 23:07:09 +0000
4@@ -12,3 +12,4 @@
5 CA/serial*
6 CA/newcerts/*.pem
7 CA/private/cakey.pem
8+nova/vcsversion.py
9
10=== modified file 'doc/source/conf.py'
11--- doc/source/conf.py 2010-11-19 22:04:37 +0000
12+++ doc/source/conf.py 2011-01-07 23:07:09 +0000
13@@ -60,10 +60,11 @@
14 # |version| and |release|, also used in various other places throughout the
15 # built documents.
16 #
17+from nova import version as nova_version
18+# The full version, including alpha/beta/rc tags.
19+release = nova_version.version()
20 # The short X.Y version.
21-version = '2011.1'
22-# The full version, including alpha/beta/rc tags.
23-release = '2011.1-prerelease'
24+version = nova_version.canonical_version_string()
25
26 # The language for content autogenerated by Sphinx. Refer to documentation
27 # for a list of supported languages.
28
29=== modified file 'nova/log.py'
30--- nova/log.py 2011-01-06 20:08:14 +0000
31+++ nova/log.py 2011-01-07 23:07:09 +0000
32@@ -34,24 +34,19 @@
33 import traceback
34
35 from nova import flags
36-# TODO(todd): fix after version.py merge
37-# from nova import version
38+from nova import version
39
40
41 FLAGS = flags.FLAGS
42
43-# TODO(todd): fix after version.py merge
44-# '(%(name)s %(nova_version)s): %(levelname)s '
45 flags.DEFINE_string('logging_context_format_string',
46- '(%(name)s): %(levelname)s '
47+ '(%(name)s %(nova_version)s): %(levelname)s '
48 '[%(request_id)s %(user)s '
49 '%(project)s] %(message)s',
50 'format string to use for log messages')
51
52-# TODO(todd): fix after version.py merge
53-# '(%(name)s %(nova_version)s): %(levelname)s [N/A] '
54 flags.DEFINE_string('logging_default_format_string',
55- '(%(name)s): %(levelname)s [N/A] '
56+ '(%(name)s %(nova_version)s): %(levelname)s [N/A] '
57 '%(message)s',
58 'format string to use for log messages')
59
60@@ -162,8 +157,7 @@
61 extra = {}
62 if context:
63 extra.update(_dictify_context(context))
64- # TODO(todd): fix after version.py merge
65- #extra.update({"nova_version": version.string_with_vcs()})
66+ extra.update({"nova_version": version.version_string_with_vcs()})
67 logging.Logger._log(self, level, msg, args, exc_info, extra)
68
69 def addHandler(self, handler):
70
71=== added file 'nova/version.py'
72--- nova/version.py 1970-01-01 00:00:00 +0000
73+++ nova/version.py 2011-01-07 23:07:09 +0000
74@@ -0,0 +1,46 @@
75+# vim: tabstop=4 shiftwidth=4 softtabstop=4
76+
77+# Copyright 2011 OpenStack LLC
78+#
79+# Licensed under the Apache License, Version 2.0 (the "License"); you may
80+# not use this file except in compliance with the License. You may obtain
81+# a copy of the License at
82+#
83+# http://www.apache.org/licenses/LICENSE-2.0
84+#
85+# Unless required by applicable law or agreed to in writing, software
86+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
87+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
88+# License for the specific language governing permissions and limitations
89+# under the License.
90+
91+try:
92+ from nova.vcsversion import version_info
93+except ImportError:
94+ version_info = {'branch_nick': u'LOCALBRANCH',
95+ 'revision_id': 'LOCALREVISION',
96+ 'revno': 0}
97+
98+NOVA_VERSION = ['2011', '1']
99+YEAR, COUNT = NOVA_VERSION
100+
101+FINAL = False # This becomes true at Release Candidate time
102+
103+
104+def canonical_version_string():
105+ return '.'.join([YEAR, COUNT])
106+
107+
108+def version_string():
109+ if FINAL:
110+ return canonical_version_string()
111+ else:
112+ return '%s-dev' % (canonical_version_string(),)
113+
114+
115+def vcs_version_string():
116+ return "%s:%s" % (version_info['branch_nick'], version_info['revision_id'])
117+
118+
119+def version_string_with_vcs():
120+ return "%s-%s" % (canonical_version_string(), vcs_version_string())
121
122=== modified file 'setup.py'
123--- setup.py 2011-01-04 05:23:35 +0000
124+++ setup.py 2011-01-07 23:07:09 +0000
125@@ -24,6 +24,15 @@
126 from sphinx.setup_command import BuildDoc
127
128 from nova.utils import parse_mailmap, str_dict_replace
129+from nova import version
130+
131+if os.path.isdir('.bzr'):
132+ with open("nova/vcsversion.py", 'w') as version_file:
133+ vcs_cmd = subprocess.Popen(["bzr", "version-info", "--python"],
134+ stdout=subprocess.PIPE)
135+ vcsversion = vcs_cmd.communicate()[0]
136+ version_file.write(vcsversion)
137+
138
139 class local_BuildDoc(BuildDoc):
140 def run(self):
141@@ -49,7 +58,7 @@
142 sdist.run(self)
143
144 setup(name='nova',
145- version='2011.1',
146+ version=version.canonical_version_string(),
147 description='cloud computing fabric controller',
148 author='OpenStack',
149 author_email='nova@lists.launchpad.net',