##// END OF EJS Templates
wix: more robust normalization of RC version components...
Gregory Szorc -
r44632:8d653abe stable
parent child Browse files
Show More
@@ -74,9 +74,36 b' def find_version(source_dir: pathlib.Pat'
74 def normalize_version(version):
74 def normalize_version(version):
75 """Normalize Mercurial version string so WiX accepts it.
75 """Normalize Mercurial version string so WiX accepts it.
76
76
77 Version strings have to be numeric X.Y.Z.
77 Version strings have to be numeric ``A.B.C[.D]`` to conform with MSI's
78 requirements.
79
80 We normalize RC version or the commit count to a 4th version component.
81 We store this in the 4th component because ``A.B.C`` releases do occur
82 and we want an e.g. ``5.3rc0`` version to be semantically less than a
83 ``5.3.1rc2`` version. This requires always reserving the 3rd version
84 component for the point release and the ``X.YrcN`` release is always
85 point release 0.
86
87 In the case of an RC and presence of ``+`` suffix data, we can't use both
88 because the version format is limited to 4 components. We choose to use
89 RC and throw away the commit count in the suffix. This means we could
90 produce multiple installers with the same normalized version string.
91
92 >>> normalize_version("5.3")
93 '5.3.0'
94
95 >>> normalize_version("5.3rc0")
96 '5.3.0.0'
97
98 >>> normalize_version("5.3rc1")
99 '5.3.0.1'
100
101 >>> normalize_version("5.3rc1+2-abcdef")
102 '5.3.0.1'
103
104 >>> normalize_version("5.3+2-abcdef")
105 '5.3.0.2'
78 """
106 """
79
80 if '+' in version:
107 if '+' in version:
81 version, extra = version.split('+', 1)
108 version, extra = version.split('+', 1)
82 else:
109 else:
@@ -84,19 +111,24 b' def normalize_version(version):'
84
111
85 # 4.9rc0
112 # 4.9rc0
86 if version[:-1].endswith('rc'):
113 if version[:-1].endswith('rc'):
114 rc = int(version[-1:])
87 version = version[:-3]
115 version = version[:-3]
116 else:
117 rc = None
88
118
119 # Ensure we have at least X.Y version components.
89 versions = [int(v) for v in version.split('.')]
120 versions = [int(v) for v in version.split('.')]
90 while len(versions) < 3:
121 while len(versions) < 3:
91 versions.append(0)
122 versions.append(0)
92
123
93 major, minor, build = versions[:3]
124 if len(versions) < 4:
125 if rc is not None:
126 versions.append(rc)
127 elif extra:
128 # <commit count>-<hash>+<date>
129 versions.append(int(extra.split('-')[0]))
94
130
95 if extra:
131 return '.'.join('%d' % x for x in versions[0:4])
96 # <commit count>-<hash>+<date>
97 build = int(extra.split('-')[0])
98
99 return '.'.join('%d' % x for x in (major, minor, build))
100
132
101
133
102 def ensure_vc90_merge_modules(build_dir):
134 def ensure_vc90_merge_modules(build_dir):
General Comments 0
You need to be logged in to leave comments. Login now