Merge lp:~jelmer/bzr-builder/strip-dfsg into lp:bzr-builder

Proposed by Jelmer Vernooij on 2012-03-25
Status: Merged
Approved by: James Westby on 2012-03-26
Approved revision: 168
Merged at revision: 168
Proposed branch: lp:~jelmer/bzr-builder/strip-dfsg
Merge into: lp:bzr-builder
Diff against target: 84 lines (+38/-3)
2 files modified
deb_version.py (+12/-3)
tests/test_deb_version.py (+26/-0)
To merge this branch: bzr merge lp:~jelmer/bzr-builder/strip-dfsg
Reviewer Review Type Date Requested Status
James Westby 2012-03-25 Approve on 2012-03-26
Review via email: mp+99204@code.launchpad.net

Description of the change

Drop the dfsg suffix from versions when expanding {debupstream-base}.

To post a comment you must log in.
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'deb_version.py'
--- deb_version.py 2011-12-15 17:08:16 +0000
+++ deb_version.py 2012-03-25 12:23:18 +0000
@@ -88,16 +88,25 @@
88 "No previous changelog to take the version from")88 "No previous changelog to take the version from")
89 return str(self._version)89 return str(self._version)
9090
91dfsg_regex = lazy_regex.lazy_compile(
92 r'[+.]*dfsg[.]*[0-9]+')
93
94version_regex = lazy_regex.lazy_compile(
95 r'([~+])(svn[0-9]+|bzr[0-9]+|git[0-9a-f]+)')
96
97def version_extract_base(version):
98 version = dfsg_regex.sub("", version)
99 return version_regex.sub("\\1", version)
100
91101
92class DebUpstreamBaseVariable(DebUpstreamVariable):102class DebUpstreamBaseVariable(DebUpstreamVariable):
93103
94 basename = "debupstream-base"104 basename = "debupstream-base"
95 version_regex = lazy_regex.lazy_compile(r'([~+])(svn[0-9]+|bzr[0-9]+|git[0-9a-f]+)')
96 minimum_format = 0.4105 minimum_format = 0.4
97106
98 def get(self):107 def get(self):
99 version = super(DebUpstreamBaseVariable, self).get()108 version = super(DebUpstreamBaseVariable, self).get()
100 version = self.version_regex.sub("\\1", version)109 version = version_extract_base(version)
101 if version[-1] not in ("~", "+"):110 if version[-1] not in ("~", "+"):
102 version += "+"111 version += "+"
103 return version112 return version
@@ -169,7 +178,7 @@
169 if cl_file_id is not None:178 if cl_file_id is not None:
170 tree.lock_read()179 tree.lock_read()
171 try:180 try:
172 cl = changelog.Changelog(tree.get_file(cl_file_id))181 cl = changelog.Changelog(tree.get_file_text(cl_file_id))
173 substitute_changelog_vars(base_branch, branch_name, cl)182 substitute_changelog_vars(base_branch, branch_name, cl)
174 finally:183 finally:
175 tree.unlock()184 tree.unlock()
176185
=== modified file 'tests/test_deb_version.py'
--- tests/test_deb_version.py 2011-12-15 17:32:56 +0000
+++ tests/test_deb_version.py 2012-03-25 12:23:18 +0000
@@ -29,6 +29,7 @@
29 DebVersionVariable,29 DebVersionVariable,
30 SubstitutionUnavailable,30 SubstitutionUnavailable,
31 check_expanded_deb_version,31 check_expanded_deb_version,
32 version_extract_base,
32 substitute_branch_vars,33 substitute_branch_vars,
33 substitute_time,34 substitute_time,
34 )35 )
@@ -313,6 +314,31 @@
313 self.assertEquals("2.4+", var.get())314 self.assertEquals("2.4+", var.get())
314315
315316
317class VersionExtractBaseTests(TestCase):
318
319 def test_simple_extract(self):
320 self.assertEquals("2.4", version_extract_base("2.4"))
321 self.assertEquals("2.4+foobar", version_extract_base("2.4+foobar"))
322
323 def test_with_bzr(self):
324 self.assertEquals("2.4+", version_extract_base("2.4+bzr32"))
325 self.assertEquals("2.4~", version_extract_base("2.4~bzr32"))
326
327 def test_with_git(self):
328 self.assertEquals("2.4+", version_extract_base("2.4+git20101010"))
329 self.assertEquals("2.4~", version_extract_base("2.4~gitaabbccdd"))
330
331 def test_with_svn(self):
332 self.assertEquals("2.4+", version_extract_base("2.4+svn45"))
333 self.assertEquals("2.4~", version_extract_base("2.4~svn45"))
334
335 def test_with_dfsg(self):
336 self.assertEquals("2.4+", version_extract_base("2.4+bzr32+dfsg1"))
337 self.assertEquals("2.4~", version_extract_base("2.4~bzr32+dfsg.1"))
338 self.assertEquals("2.4~", version_extract_base("2.4~bzr32.dfsg.1"))
339 self.assertEquals("2.4~", version_extract_base("2.4~bzr32dfsg.1"))
340
341
316class DebVersionVariableTests(TestCase):342class DebVersionVariableTests(TestCase):
317343
318 def write_changelog(self, version):344 def write_changelog(self, version):

Subscribers

People subscribed via source and target branches