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
=== modified file 'cupstream2distro/packagemanager.py'
--- cupstream2distro/packagemanager.py 2014-01-08 10:54:09 +0000
+++ cupstream2distro/packagemanager.py 2014-01-08 15:56:15 +0000
@@ -1,8 +1,9 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2# Copyright (C) 2012 Canonical2# Copyright (C) 2012-2014 Canonical
3#3#
4# Authors:4# Authors:
5# Didier Roche5# Didier Roche
6# Rodney Dawes
6#7#
7# This program is free software; you can redistribute it and/or modify it under8# This program is free software; you can redistribute it and/or modify it under
8# the terms of the GNU General Public License as published by the Free Software9# the terms of the GNU General Public License as published by the Free Software
@@ -295,8 +296,11 @@
295 if we already have something delivered today, it will be .minor, then, .minor+1…296 if we already have something delivered today, it will be .minor, then, .minor+1…
296297
297 We append the destination ppa name if we target a dest ppa and not distro'''298 We append the destination ppa name if we target a dest ppa and not distro'''
299 # to keep track of whether the package is native or not
300 native_pkg = False
298301
299 today_version = datetime.date.today().strftime('%Y%m%d')302 today_version = datetime.date.today().strftime('%Y%m%d')
303 destppa = destppa.replace("-", '.').replace("_", ".").replace("/", ".")
300 # bootstrapping mode or direct upload or UNRELEASED for bumping to a new series304 # bootstrapping mode or direct upload or UNRELEASED for bumping to a new series
301 # TRANSITION305 # TRANSITION
302 if not ("daily" in base_package_version or "+" in base_package_version):306 if not ("daily" in base_package_version or "+" in base_package_version):
@@ -305,6 +309,23 @@
305 # if we have 42ubuntu1 like a wrong native version309 # if we have 42ubuntu1 like a wrong native version
306 if "ubuntu" in upstream_version:310 if "ubuntu" in upstream_version:
307 upstream_version = upstream_version.split('ubuntu')[0]311 upstream_version = upstream_version.split('ubuntu')[0]
312 elif not "-" in base_package_version and "+" in base_package_version:
313 # extract the day of previous daily upload and bump if already uploaded
314 regexp = re.compile("(.*)\+([\d\.]{5})\.(\d{8})\.?([\d]*).*")
315 try:
316 previous_day = regexp.findall(base_package_version)[0]
317 upstream_version = previous_day[0]
318 native_pkg = True
319 if (previous_day[1] == series_version and
320 previous_day[2] == today_version):
321 minor = 1
322 if previous_day[3]: # second upload of the day
323 minor = int(previous_day[3]) + 1
324 today_version = "{}.{}".format(today_version, minor)
325 except IndexError:
326 raise Exception(
327 "Unable to get previous day from native version: %s"
328 % base_package_version)
308 else:329 else:
309 # extract the day of previous daily upload and bump if already uploaded today330 # extract the day of previous daily upload and bump if already uploaded today
310 regexp = re.compile("(.*)\+([\d\.]{5})\.(\d{8})\.?([\d]*).*-.*")331 regexp = re.compile("(.*)\+([\d\.]{5})\.(\d{8})\.?([\d]*).*-.*")
@@ -326,10 +347,13 @@
326 minor = int(previous_day[3]) + 1347 minor = int(previous_day[3]) + 1
327 today_version = "{}.{}".format(today_version, minor)348 today_version = "{}.{}".format(today_version, minor)
328349
329 destppa = destppa.replace("-", '.').replace("_", ".").replace("/", ".")350 new_upstream_version = "{upstream}+{series}.{date}{destppa}".format(
330 new_upstream_version = "{upstream}+{series}.{date}{destppa}".format(upstream=upstream_version, series=series_version,351 upstream=upstream_version, series=series_version,
331 date=today_version, destppa=destppa)352 date=today_version, destppa=destppa)
332 return "{}-0ubuntu1".format(new_upstream_version)353 if native_pkg is not True:
354 new_upstream_version = "{}-0ubuntu1".format(new_upstream_version)
355
356 return new_upstream_version
333357
334358
335def get_packaging_sourcename():359def get_packaging_sourcename():
336360
=== modified file 'tests/unit/test_packagemanager.py'
--- tests/unit/test_packagemanager.py 2013-11-05 14:52:56 +0000
+++ tests/unit/test_packagemanager.py 2014-01-08 15:56:15 +0000
@@ -1,8 +1,9 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2# Copyright: (C) 2013 Canonical2# Copyright: (C) 2013-2014 Canonical
3#3#
4# Authors:4# Authors:
5# Didier Roche5# Didier Roche
6# Rodney Dawes
6#7#
7# This program is free software; you can redistribute it and/or modify it under8# This program is free software; you can redistribute it and/or modify it under
8# the terms of the GNU General Public License as published by the Free Software9# the terms of the GNU General Public License as published by the Free Software
@@ -494,6 +495,58 @@
494 strftime_call.assert_called_with('%Y%m%d')495 strftime_call.assert_called_with('%Y%m%d')
495496
496 @patch('cupstream2distro.packagemanager.datetime')497 @patch('cupstream2distro.packagemanager.datetime')
498 def test_create_new_packaging_version_native(self, datetimeMock):
499 """Verify that native package versions are supported."""
500 strftime_call = datetimeMock.date.today.return_value.strftime
501 strftime_call.side_effect = lambda date: '19830913'
502 self.assertEqual(packagemanager.create_new_packaging_version(
503 '13.10+13.10.19830912', '13.10'),
504 '13.10+13.10.19830913')
505 strftime_call.assert_called_with('%Y%m%d')
506
507 @patch('cupstream2distro.packagemanager.datetime')
508 def test_create_new_packaging_version_native_epoch(self, datetimeMock):
509 """Verify that native package versions with epoch are supported."""
510 strftime_call = datetimeMock.date.today.return_value.strftime
511 strftime_call.side_effect = lambda date: '19830913'
512 self.assertEqual(packagemanager.create_new_packaging_version(
513 '1:13.10+13.10.19830912', '13.10'),
514 '1:13.10+13.10.19830913')
515 strftime_call.assert_called_with('%Y%m%d')
516
517 @patch('cupstream2distro.packagemanager.datetime')
518 def test_create_new_packaging_version_native_first_rerelease_sameday(
519 self, datetimeMock):
520 """Verify that native versions re-release on same day is supported."""
521 strftime_call = datetimeMock.date.today.return_value.strftime
522 strftime_call.side_effect = lambda date: '19830913'
523 self.assertEqual(packagemanager.create_new_packaging_version(
524 '13.10+13.10.19830913', '13.10'),
525 '13.10+13.10.19830913.1')
526 strftime_call.assert_called_with('%Y%m%d')
527
528 @patch('cupstream2distro.packagemanager.datetime')
529 def test_create_new_packaging_version_native_continous_rerelease_sameday(
530 self, datetimeMock):
531 """Verify that native versions continuoed re-release is supported."""
532 strftime_call = datetimeMock.date.today.return_value.strftime
533 strftime_call.side_effect = lambda date: '19830913'
534 self.assertEqual(packagemanager.create_new_packaging_version(
535 '13.10+13.10.19830913.2', '13.10'),
536 '13.10+13.10.19830913.3')
537 strftime_call.assert_called_with('%Y%m%d')
538
539 @patch('cupstream2distro.packagemanager.datetime')
540 def test_create_new_packaging_version_native_ppa_dest(self, datetimeMock):
541 """Verify that native versions with a ppa dest are supported."""
542 strftime_call = datetimeMock.date.today.return_value.strftime
543 strftime_call.side_effect = lambda date: '19830913'
544 self.assertEqual(packagemanager.create_new_packaging_version(
545 '13.10+13.10.19830912', '13.10', 'didrocks/my-ppa_mine'),
546 '13.10+13.10.19830913didrocks.my.ppa.mine')
547 strftime_call.assert_called_with('%Y%m%d')
548
549 @patch('cupstream2distro.packagemanager.datetime')
497 def test_create_new_packaging_version_from_native(self, datetimeMock):550 def test_create_new_packaging_version_from_native(self, datetimeMock):
498 '''We create a new packaging version after a native released version'''551 '''We create a new packaging version after a native released version'''
499 strftime_call = datetimeMock.date.today.return_value.strftime552 strftime_call = datetimeMock.date.today.return_value.strftime

Subscribers

People subscribed via source and target branches

to all changes: