Merge lp:~jbaudoux/anybox.recipe.openerp/1_7_version_string_decoding_for_saas_releases into lp:anybox.recipe.openerp

Proposed by Jacques-Etienne Baudoux
Status: Merged
Merged at revision: 476
Proposed branch: lp:~jbaudoux/anybox.recipe.openerp/1_7_version_string_decoding_for_saas_releases
Merge into: lp:anybox.recipe.openerp
Diff against target: 52 lines (+18/-9)
1 file modified
anybox/recipe/openerp/utils.py (+18/-9)
To merge this branch: bzr merge lp:~jbaudoux/anybox.recipe.openerp/1_7_version_string_decoding_for_saas_releases
Reviewer Review Type Date Requested Status
Anybox Pending
Review via email: mp+184470@code.launchpad.net

Description of the change

I improved the function major_version(version_string) for supporting OpenERP saas releases (e.g. 7.saas~1). They are short-lived stable versions between two "X.0" LTS releases. The second version number does not contain a numeric value.
To be compatible with existing code, a numeric value is returned.
I have chosen to return the value X.5 (e.g. 7.5) that I found the most in accordance to the concept of those releases.

To post a comment you must log in.
Revision history for this message
Georges Racinet (gracinet) wrote :

I agree with the version numbering. It's not that important, because this version number is somewhat transient. It's used as the basis for version independency (for instance, for v5.0, there's some cleaning to be done before exit, that sort of thing)

Therefore, if we change our minds in a later version, users would either not re-buildout or they would and in both cases, the state would be consistent.

Revision history for this message
Georges Racinet (gracinet) wrote :

Again, thanks for the contribution.
Just merged, but I had to rewrite it to restore some other version schemes that got broken, and that the unit tests detected (after a bit of adaptation, I went back to the regexp).

This will be treated as a merge by bzr, though.

The documentation on how to launch the unit tests has been written since you submitted this merge request: http://docs.anybox.fr/anybox.recipe.openerp/trunk/contributing.html (comments welcomed)

Regards,

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'anybox/recipe/openerp/utils.py'
2--- anybox/recipe/openerp/utils.py 2013-08-27 09:29:47 +0000
3+++ anybox/recipe/openerp/utils.py 2013-09-08 13:19:48 +0000
4@@ -1,6 +1,6 @@
5 import os
6 import sys
7-import re
8+import string
9 import subprocess
10 from contextlib import contextmanager
11 import logging
12@@ -43,11 +43,6 @@
13 yield f
14
15
16-NIGHTLY_VERSION_RE = re.compile(r'(\d+)[.](\d+)-(\d+-\d+)$')
17-
18-MAJOR_VERSION_RE = re.compile(r'(\d+)[.](\d+)')
19-
20-
21 def major_version(version_string):
22 """The least common denominator of OpenERP versions : two numbers.
23
24@@ -58,11 +53,25 @@
25 Beware, the packaging script does funny things, such as labeling current
26 nightlies as 6.2-date-time whereas version_info is (7, 0, 0, ALPHA)
27 We can in recipe code check for >= (6, 2), that's not a big issue.
28+
29+ Regarding OpenERP saas releases (e.g. 7.saas~1) that are short-lived stable
30+ versions between two "X.0" LTS releases, the second version number does not
31+ contain a numeric value. The value X.5 will be returned (e.g. 7.5).
32 """
33
34- m = MAJOR_VERSION_RE.match(version_string)
35- if m is not None:
36- return tuple(int(m.group(i)) for i in (1, 2))
37+ version = version_string.split('.', 3)
38+ assert len(version) >= 2, ('Version string must have a major and minor '
39+ 'number: "%s".' % version_string)
40+ major = version[0]
41+ minor = version[1]
42+ if not all(ch in set(string.digits) for ch in major):
43+ raise ValueError('Cannot decode version number "%s". Major is not a '
44+ 'number.' % version_string)
45+ if all(ch in set(string.digits) for ch in minor):
46+ return (int(major), int(minor))
47+ elif minor.startswith('saas'):
48+ return (int(major), 5)
49+ raise ValueError('Cannot decode version number "%s".' % version_string)
50
51
52 def mkdirp(path):

Subscribers

People subscribed via source and target branches