Merge lp:~dobey/cupstream2distro/native-versions into lp:cupstream2distro

Proposed by dobey
Status: Merged
Approved by: Didier Roche-Tolomelli
Approved revision: 438
Merged at revision: 448
Proposed branch: lp:~dobey/cupstream2distro/native-versions
Merge into: lp:cupstream2distro
Diff against target: 142 lines (+83/-6)
2 files modified
cupstream2distro/packagemanager.py (+29/-5)
tests/unit/test_packagemanager.py (+54/-1)
To merge this branch: bzr merge lp:~dobey/cupstream2distro/native-versions
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli Approve
Review via email: mp+200736@code.launchpad.net

Commit message

Support native package versions when creating a new packaging version.

To post a comment you must log in.
437. By dobey

It's actually 2014 now.

438. By dobey

Add more tests.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

That looks good. Thanks a lot for the patch!

Just two small things (which are related):

as you can see in test_create_new_packaging_version_from_native(), we enable transforming a native version in a split mode. This is when upstream are bumping the changelog themselves without really knowing what they do, so we enable that use case.

The test is still passing because you added the "+" check in :
+ elif not "-" in base_package_version and "+" in base_package_version:

However, I think that's a use case to support as well for native packages (and not forcing adding a + for the bootstrapping).

What do you think detecting native reading debian/source/format as well? That way, you can remove the check "+" in base_package_version.

And so adding a test for the additional case:
test_create_new_packaging_version_from_native should still work:
42 to 42+13.10.19830913-0ubuntu1 for split mode

and a new one from:
42 to 42+13.10.19830913 for native mode

What do you think?

review: Needs Information
Revision history for this message
dobey (dobey) wrote :

I think it makes sense, but I think it would create excessive complexity to do it in this function, and would make the tests too complex. Supporting that would require a fair bit of refactoring, I think, and I'm not sure it should be done here.

This works, and the previous test work, because native versions without a '+' were already being handled specially, and I followed that concept by treating native versions with a '+' differently, here.

Given that the documentation for migration to daily-release includes adding a changelog entry with a datestamp version that includes the '+' and series/date after it, I think the behavior in this branch is safe, as it will not create any regressions in the existing behavior, while supporting the native daily release behavior for projects that want it.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Based on discussion on IRC +1

review: Approve
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Seems that the CI team removed the cred for us to deploy the code. I'm asking them to deploy it now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cupstream2distro/packagemanager.py'
2--- cupstream2distro/packagemanager.py 2014-01-08 10:54:09 +0000
3+++ cupstream2distro/packagemanager.py 2014-01-08 15:56:15 +0000
4@@ -1,8 +1,9 @@
5 # -*- coding: utf-8 -*-
6-# Copyright (C) 2012 Canonical
7+# Copyright (C) 2012-2014 Canonical
8 #
9 # Authors:
10 # Didier Roche
11+# Rodney Dawes
12 #
13 # This program is free software; you can redistribute it and/or modify it under
14 # the terms of the GNU General Public License as published by the Free Software
15@@ -295,8 +296,11 @@
16 if we already have something delivered today, it will be .minor, then, .minor+1…
17
18 We append the destination ppa name if we target a dest ppa and not distro'''
19+ # to keep track of whether the package is native or not
20+ native_pkg = False
21
22 today_version = datetime.date.today().strftime('%Y%m%d')
23+ destppa = destppa.replace("-", '.').replace("_", ".").replace("/", ".")
24 # bootstrapping mode or direct upload or UNRELEASED for bumping to a new series
25 # TRANSITION
26 if not ("daily" in base_package_version or "+" in base_package_version):
27@@ -305,6 +309,23 @@
28 # if we have 42ubuntu1 like a wrong native version
29 if "ubuntu" in upstream_version:
30 upstream_version = upstream_version.split('ubuntu')[0]
31+ elif not "-" in base_package_version and "+" in base_package_version:
32+ # extract the day of previous daily upload and bump if already uploaded
33+ regexp = re.compile("(.*)\+([\d\.]{5})\.(\d{8})\.?([\d]*).*")
34+ try:
35+ previous_day = regexp.findall(base_package_version)[0]
36+ upstream_version = previous_day[0]
37+ native_pkg = True
38+ if (previous_day[1] == series_version and
39+ previous_day[2] == today_version):
40+ minor = 1
41+ if previous_day[3]: # second upload of the day
42+ minor = int(previous_day[3]) + 1
43+ today_version = "{}.{}".format(today_version, minor)
44+ except IndexError:
45+ raise Exception(
46+ "Unable to get previous day from native version: %s"
47+ % base_package_version)
48 else:
49 # extract the day of previous daily upload and bump if already uploaded today
50 regexp = re.compile("(.*)\+([\d\.]{5})\.(\d{8})\.?([\d]*).*-.*")
51@@ -326,10 +347,13 @@
52 minor = int(previous_day[3]) + 1
53 today_version = "{}.{}".format(today_version, minor)
54
55- destppa = destppa.replace("-", '.').replace("_", ".").replace("/", ".")
56- new_upstream_version = "{upstream}+{series}.{date}{destppa}".format(upstream=upstream_version, series=series_version,
57- date=today_version, destppa=destppa)
58- return "{}-0ubuntu1".format(new_upstream_version)
59+ new_upstream_version = "{upstream}+{series}.{date}{destppa}".format(
60+ upstream=upstream_version, series=series_version,
61+ date=today_version, destppa=destppa)
62+ if native_pkg is not True:
63+ new_upstream_version = "{}-0ubuntu1".format(new_upstream_version)
64+
65+ return new_upstream_version
66
67
68 def get_packaging_sourcename():
69
70=== modified file 'tests/unit/test_packagemanager.py'
71--- tests/unit/test_packagemanager.py 2013-11-05 14:52:56 +0000
72+++ tests/unit/test_packagemanager.py 2014-01-08 15:56:15 +0000
73@@ -1,8 +1,9 @@
74 # -*- coding: utf-8 -*-
75-# Copyright: (C) 2013 Canonical
76+# Copyright: (C) 2013-2014 Canonical
77 #
78 # Authors:
79 # Didier Roche
80+# Rodney Dawes
81 #
82 # This program is free software; you can redistribute it and/or modify it under
83 # the terms of the GNU General Public License as published by the Free Software
84@@ -494,6 +495,58 @@
85 strftime_call.assert_called_with('%Y%m%d')
86
87 @patch('cupstream2distro.packagemanager.datetime')
88+ def test_create_new_packaging_version_native(self, datetimeMock):
89+ """Verify that native package versions are supported."""
90+ strftime_call = datetimeMock.date.today.return_value.strftime
91+ strftime_call.side_effect = lambda date: '19830913'
92+ self.assertEqual(packagemanager.create_new_packaging_version(
93+ '13.10+13.10.19830912', '13.10'),
94+ '13.10+13.10.19830913')
95+ strftime_call.assert_called_with('%Y%m%d')
96+
97+ @patch('cupstream2distro.packagemanager.datetime')
98+ def test_create_new_packaging_version_native_epoch(self, datetimeMock):
99+ """Verify that native package versions with epoch are supported."""
100+ strftime_call = datetimeMock.date.today.return_value.strftime
101+ strftime_call.side_effect = lambda date: '19830913'
102+ self.assertEqual(packagemanager.create_new_packaging_version(
103+ '1:13.10+13.10.19830912', '13.10'),
104+ '1:13.10+13.10.19830913')
105+ strftime_call.assert_called_with('%Y%m%d')
106+
107+ @patch('cupstream2distro.packagemanager.datetime')
108+ def test_create_new_packaging_version_native_first_rerelease_sameday(
109+ self, datetimeMock):
110+ """Verify that native versions re-release on same day is supported."""
111+ strftime_call = datetimeMock.date.today.return_value.strftime
112+ strftime_call.side_effect = lambda date: '19830913'
113+ self.assertEqual(packagemanager.create_new_packaging_version(
114+ '13.10+13.10.19830913', '13.10'),
115+ '13.10+13.10.19830913.1')
116+ strftime_call.assert_called_with('%Y%m%d')
117+
118+ @patch('cupstream2distro.packagemanager.datetime')
119+ def test_create_new_packaging_version_native_continous_rerelease_sameday(
120+ self, datetimeMock):
121+ """Verify that native versions continuoed re-release is supported."""
122+ strftime_call = datetimeMock.date.today.return_value.strftime
123+ strftime_call.side_effect = lambda date: '19830913'
124+ self.assertEqual(packagemanager.create_new_packaging_version(
125+ '13.10+13.10.19830913.2', '13.10'),
126+ '13.10+13.10.19830913.3')
127+ strftime_call.assert_called_with('%Y%m%d')
128+
129+ @patch('cupstream2distro.packagemanager.datetime')
130+ def test_create_new_packaging_version_native_ppa_dest(self, datetimeMock):
131+ """Verify that native versions with a ppa dest are supported."""
132+ strftime_call = datetimeMock.date.today.return_value.strftime
133+ strftime_call.side_effect = lambda date: '19830913'
134+ self.assertEqual(packagemanager.create_new_packaging_version(
135+ '13.10+13.10.19830912', '13.10', 'didrocks/my-ppa_mine'),
136+ '13.10+13.10.19830913didrocks.my.ppa.mine')
137+ strftime_call.assert_called_with('%Y%m%d')
138+
139+ @patch('cupstream2distro.packagemanager.datetime')
140 def test_create_new_packaging_version_from_native(self, datetimeMock):
141 '''We create a new packaging version after a native released version'''
142 strftime_call = datetimeMock.date.today.return_value.strftime

Subscribers

People subscribed via source and target branches

to all changes: