Merge lp:~maxb/udd/import-ordering-fix-take-2 into lp:udd

Proposed by Max Bowsher
Status: Merged
Approved by: James Westby
Approved revision: 451
Merged at revision: 452
Proposed branch: lp:~maxb/udd/import-ordering-fix-take-2
Merge into: lp:udd
Diff against target: 135 lines (+44/-58)
2 files modified
icommon.py (+32/-49)
tests/test_package_to_import.py (+12/-9)
To merge this branch: bzr merge lp:~maxb/udd/import-ordering-fix-take-2
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+63335@code.launchpad.net

Description of the change

Jelmer, you were so very right when you suggested import ordering could be better done based on versions at the bzr sprint in London.

What neither of us realized at the time was that importing sid first in all cases only holds true as a correct method if sid contains all older releases in its ancestry .... which is true in theory, but not in Launchpad's database.

In fact, Launchpad's "sid" only goes back as far as lenny, and woody, sarge, and etch are imported by the UDD importer via package indices from archive.debian.org.

Fortunately, this miscalculation of mine only causes suboptimal history to be produced when doing fresh imports of package versions around the etch / lenny boundary, so should not have had much if any impact.

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

The comments are much clearer now too, thanks.

James

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'icommon.py'
2--- icommon.py 2011-06-02 00:32:31 +0000
3+++ icommon.py 2011-06-03 07:49:30 +0000
4@@ -324,60 +324,43 @@
5 series or pockets are imported before imports to the likely
6 destinations, such that the source imported version is available to be
7 pulled."""
8- # Debian versions should be imported before Ubuntu versions, so
9- # that any Debian version an Ubuntu version may be based on is
10- # already imported when the Ubuntu version is imported.
11+ # Core assumption: packages always have higher versions than their
12+ # ancestors... except for backports. Therefore, sort backports after
13+ # all non-backports.
14+ if a.pocket == "backports" and b.pocket != "backports":
15+ return 1
16+ if a.pocket != "backports" and b.pocket == "backports":
17+ return -1
18+ # Next sort by version.
19+ if a.version < b.version:
20+ return -1
21+ if a.version > b.version:
22+ return 1
23+ # From here on, a.version == b.version
24+ # Sort Debian before Ubuntu, so that synced packages are first imported
25+ # into Debian.
26 if a.distro != b.distro:
27 if a.distro == "debian":
28 return -1
29 return 1
30 # From here on, a.distro == b.distro
31- if a.distro == "ubuntu":
32- # Ubuntu backports should be imported after all other Ubuntu
33- # pockets, so that the version the backport is based on is
34- # imported before the backport itself.
35- if a.pocket == "backports" and b.pocket != "backports":
36- return 1
37- if a.pocket != "backports" and b.pocket == "backports":
38- return -1
39- # Within Ubuntu, release series should be imported in ascending
40- # order, so that a package version is imported into the first
41- # series in which it is present.
42- if a.release != b.release:
43- a_release = distro_releases[a.distro].index(a.release)
44- b_release = distro_releases[b.distro].index(b.release)
45- if a_release < b_release:
46- return -1
47- return 1
48- # Within a single Ubuntu release series, import pockets such
49- # that any pocket that can contain versions based on versions
50- # in another pocket, is imported after that pocket.
51- if a.pocket != b.pocket:
52- a_pocket = distro_pockets[a.distro].index(a.pocket)
53- b_pocket = distro_pockets[b.distro].index(b.pocket)
54- if a_pocket < b_pocket:
55- return -1
56- return 1
57- if a.distro == "debian":
58- # Debian sid/experimental should be imported before any other
59- # codename, to get the proper ancestry.
60- if a.release in ("sid", "experimental") and b.release not in ("sid", "experimental"):
61- return -1
62- if a.release not in ("sid", "experimental") and b.release in ("sid", "experimental"):
63- return 1
64- # Other than that special case, import in ascending order.
65- if a.release != b.release:
66- a_release = distro_releases[a.distro].index(a.release)
67- b_release = distro_releases[b.distro].index(b.release)
68- if a_release < b_release:
69- return -1
70- return 1
71- # Within a single distro, release, and pocket, import in version
72- # order.
73- if a.version < b.version:
74- return -1
75- if a.version > b.version:
76- return 1
77+ # Release series should be imported in ascending order, modelling a
78+ # packaging being carried forward unchanged into new series.
79+ if a.release != b.release:
80+ a_release = distro_releases[a.distro].index(a.release)
81+ b_release = distro_releases[b.distro].index(b.release)
82+ if a_release < b_release:
83+ return -1
84+ return 1
85+ # Within a single release series, import pockets such that for all
86+ # typical pocket copy workflows, the source pocket is imported first.
87+ if a.pocket != b.pocket:
88+ a_pocket = distro_pockets[a.distro].index(a.pocket)
89+ b_pocket = distro_pockets[b.distro].index(b.pocket)
90+ if a_pocket < b_pocket:
91+ return -1
92+ return 1
93+ # Same version, distro, release and pocket
94 return 0
95
96
97
98=== modified file 'tests/test_package_to_import.py'
99--- tests/test_package_to_import.py 2011-05-17 13:26:32 +0000
100+++ tests/test_package_to_import.py 2011-06-03 07:49:30 +0000
101@@ -68,22 +68,25 @@
102 self.assertTrue(PTI.import_order_comparator(a, b) < 0)
103
104 def test_comparison(self):
105- # Distro is the most-significant factor, with all of Ubuntu coming
106- # after all of Debian, irregardless of releases and versions:
107- self.assertOrdering(PTI("a", V("999999"), "debian", "sid", "release"),
108- PTI("a", V("1"), "ubuntu", "warty", "release"))
109-
110- # Within a distro, release is the next most significant:
111+ # Version is the most-significant factor:
112+ self.assertOrdering(PTI("a", V("1"), "ubuntu", "warty", "release"),
113+ PTI("a", V("999999"), "debian", "sid", "release"))
114+
115+ # For something that looks like a sync, Debian comes before Ubuntu:
116+ self.assertOrdering(PTI("a", V("1"), "debian", "lenny", "release"),
117+ PTI("a", V("1"), "ubuntu", "lucid", "release"))
118+
119+ # With same version, same distro, release is the next most significant:
120 self.assertOrdering(PTI("a", V("1"), "debian", "lenny", "release"),
121 PTI("a", V("1"), "debian", "squeeze", "release"))
122
123- # Except for Ubuntu backports, which are a special case, imported after
124- # all other Ubuntu imports in the same per-package run:
125+ # Except for backports, which are a special case, imported after all
126+ # other imports in the same per-package run:
127 self.assertOrdering(PTI("a", V("1"), "ubuntu", "natty", "release"),
128 PTI("a", V("1~hardy1"), "ubuntu", "hardy",
129 "backports"))
130
131- # Within Ubuntu, pockets matter:
132+ # Pockets have a defined ordering:
133 self.assertOrdering(PTI("a", V("1"), "ubuntu", "natty", "release"),
134 PTI("a", V("1"), "ubuntu", "natty", "security"))
135 self.assertOrdering(PTI("a", V("1"), "ubuntu", "natty", "security"),

Subscribers

People subscribed via source and target branches