Merge lp:~james-w/launchpad/sync-source-negative-versions into lp:launchpad

Proposed by James Westby
Status: Merged
Approved by: Graham Binns
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~james-w/launchpad/sync-source-negative-versions
Merge into: lp:launchpad
Diff against target: 48 lines (+8/-5)
2 files modified
lib/lp/soyuz/scripts/tests/test_sync_source.py (+2/-2)
scripts/ftpmaster-tools/sync-source.py (+6/-3)
To merge this branch: bzr merge lp:~james-w/launchpad/sync-source-negative-versions
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+16861@code.launchpad.net

Commit message

Handle '0' correctly in version numbers when syncing new packages.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Fixes a problem found by geser with syncing new packages
that have odd version numbers.

A version can be 0~bzr123-1 or similar, which comapares
to less than 0. However, 0 was being used to mean "not
in Ubuntu," so sync-source.py considered the package to be
absent.

This change makes it use a proper sentinel, None, when
the package is new, so we can't get caught out by odd
comparisons.

Thanks,

James

Revision history for this message
Graham Binns (gmb) wrote :

This looks like a good change. r=me

review: Approve (code)
Revision history for this message
Graham Binns (gmb) wrote :

Hi James,

Can you link this branch to a bug? PQM gets upset if we don't supply a bug in the commit message.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/scripts/tests/test_sync_source.py'
2--- lib/lp/soyuz/scripts/tests/test_sync_source.py 2010-02-04 16:15:47 +0000
3+++ lib/lp/soyuz/scripts/tests/test_sync_source.py 2010-03-03 13:52:23 +0000
4@@ -301,7 +301,7 @@
5 self.assertEqual(
6 out.splitlines(),
7 ['Getting binaries for hoary...',
8- '[Updating] bar (0 [Ubuntu] < 1.0-1 [Debian])',
9+ '[Updating] bar (None [Ubuntu] < 1.0-1 [Debian])',
10 ' * Trying to add bar...',
11 ])
12
13@@ -376,7 +376,7 @@
14 self.assertEqual(
15 out.splitlines(),
16 ['Getting binaries for hoary...',
17- '[Updating] sample1 (0 [Ubuntu] < 1.0-1 [Debian])',
18+ '[Updating] sample1 (None [Ubuntu] < 1.0-1 [Debian])',
19 ' * Trying to add sample1...',
20 ])
21
22
23=== modified file 'scripts/ftpmaster-tools/sync-source.py'
24--- scripts/ftpmaster-tools/sync-source.py 2010-02-11 16:51:14 +0000
25+++ scripts/ftpmaster-tools/sync-source.py 2010-03-03 13:52:23 +0000
26@@ -678,7 +678,7 @@
27 packages.sort()
28 for pkg in packages:
29 stat_count += 1
30- dest_version = Suite.get(pkg, ["0", ""])[0]
31+ dest_version = Suite.get(pkg, [None, ""])[0]
32
33 if not Sources.has_key(pkg):
34 if not Options.all:
35@@ -694,8 +694,11 @@
36 continue
37
38 source_version = Sources[pkg]["version"]
39- if apt_pkg.VersionCompare(dest_version, source_version) < 0:
40- if not Options.force and dest_version.find("ubuntu") != -1:
41+ if (dest_version is None
42+ or apt_pkg.VersionCompare(dest_version, source_version) < 0):
43+ if (dest_version is not None
44+ and (not Options.force
45+ and dest_version.find("ubuntu") != -1)):
46 stat_cant_update += 1
47 print ("[NOT Updating - Modified] %s_%s (vs %s)"
48 % (pkg, dest_version, source_version))