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
=== modified file 'lib/lp/soyuz/scripts/tests/test_sync_source.py'
--- lib/lp/soyuz/scripts/tests/test_sync_source.py 2010-02-04 16:15:47 +0000
+++ lib/lp/soyuz/scripts/tests/test_sync_source.py 2010-03-03 13:52:23 +0000
@@ -301,7 +301,7 @@
301 self.assertEqual(301 self.assertEqual(
302 out.splitlines(),302 out.splitlines(),
303 ['Getting binaries for hoary...',303 ['Getting binaries for hoary...',
304 '[Updating] bar (0 [Ubuntu] < 1.0-1 [Debian])',304 '[Updating] bar (None [Ubuntu] < 1.0-1 [Debian])',
305 ' * Trying to add bar...',305 ' * Trying to add bar...',
306 ])306 ])
307307
@@ -376,7 +376,7 @@
376 self.assertEqual(376 self.assertEqual(
377 out.splitlines(),377 out.splitlines(),
378 ['Getting binaries for hoary...',378 ['Getting binaries for hoary...',
379 '[Updating] sample1 (0 [Ubuntu] < 1.0-1 [Debian])',379 '[Updating] sample1 (None [Ubuntu] < 1.0-1 [Debian])',
380 ' * Trying to add sample1...',380 ' * Trying to add sample1...',
381 ])381 ])
382382
383383
=== modified file 'scripts/ftpmaster-tools/sync-source.py'
--- scripts/ftpmaster-tools/sync-source.py 2010-02-11 16:51:14 +0000
+++ scripts/ftpmaster-tools/sync-source.py 2010-03-03 13:52:23 +0000
@@ -678,7 +678,7 @@
678 packages.sort()678 packages.sort()
679 for pkg in packages:679 for pkg in packages:
680 stat_count += 1680 stat_count += 1
681 dest_version = Suite.get(pkg, ["0", ""])[0]681 dest_version = Suite.get(pkg, [None, ""])[0]
682682
683 if not Sources.has_key(pkg):683 if not Sources.has_key(pkg):
684 if not Options.all:684 if not Options.all:
@@ -694,8 +694,11 @@
694 continue694 continue
695695
696 source_version = Sources[pkg]["version"]696 source_version = Sources[pkg]["version"]
697 if apt_pkg.VersionCompare(dest_version, source_version) < 0:697 if (dest_version is None
698 if not Options.force and dest_version.find("ubuntu") != -1:698 or apt_pkg.VersionCompare(dest_version, source_version) < 0):
699 if (dest_version is not None
700 and (not Options.force
701 and dest_version.find("ubuntu") != -1)):
699 stat_cant_update += 1702 stat_cant_update += 1
700 print ("[NOT Updating - Modified] %s_%s (vs %s)"703 print ("[NOT Updating - Modified] %s_%s (vs %s)"
701 % (pkg, dest_version, source_version))704 % (pkg, dest_version, source_version))