Merge lp:~jelmer/launchpad/521110-use-python-debian-debversion into lp:launchpad

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 11328
Proposed branch: lp:~jelmer/launchpad/521110-use-python-debian-debversion
Merge into: lp:launchpad
Diff against target: 611 lines (+70/-401)
5 files modified
lib/lp/archivepublisher/debversion.py (+46/-138)
lib/lp/archivepublisher/tests/test_debversion.py (+21/-260)
lib/lp/registry/browser/tests/distroseries-views.txt (+1/-1)
lib/lp/registry/interfaces/distroseries.py (+1/-1)
lib/lp/soyuz/doc/distroseriesqueue-dist-upgrader.txt (+1/-1)
To merge this branch: bzr merge lp:~jelmer/launchpad/521110-use-python-debian-debversion
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+31268@code.launchpad.net

Commit message

Use python-debian for Debian version comparisons.

Description of the change

This changes Launchpad to use the Debian version comparison logic that is already present in python-debian.

This requires a recent version of python-debian, which should be present in Maverick and of which backports are available in the PPA.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

I've removed the functionality in the existing debversion.py that we do not use.

Revision history for this message
Abel Deuring (adeuring) wrote :

Hi Jelmer,

the branch looks good.

Just two nitpicks:
- As discussed on IrC, we dont need the new symlinks lib/deb822.py and lib/debian

- line 41 of the diff (doc string of class Version) contains trailing spaces. Please remove them

"make lint" has a few more complaints:

./lib/lp/archivepublisher/debversion.py
      25: E302 expected 2 blank lines, found 0
      25: E701 multiple statements on one line (colon)
      26: E302 expected 2 blank lines, found 0
      26: E701 multiple statements on one line (colon)
      27: E302 expected 2 blank lines, found 0
      27: E701 multiple statements on one line (colon)
      28: E302 expected 2 blank lines, found 0
      28: E701 multiple statements on one line (colon)
      33: W291 trailing whitespace
      47: E301 expected 1 blank line, found 0
      51: W602 deprecated form of raising exception
      56: W602 deprecated form of raising exception
      60: W602 deprecated form of raising exception
      62: W602 deprecated form of raising exception
      71: W602 deprecated form of raising exception
      33: Line has trailing whitespace.

Could you plase fix this?

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/archivepublisher/debversion.py'
--- lib/lp/archivepublisher/debversion.py 2009-06-24 23:28:16 +0000
+++ lib/lp/archivepublisher/debversion.py 2010-08-03 15:03:56 +0000
@@ -10,27 +10,37 @@
1010
11__metaclass__ = type11__metaclass__ = type
1212
13# This code came from sourcerer.13# This code came from sourcerer but has been heavily modified since.
14
15from debian import changelog
1416
15import re17import re
1618
17
18# Regular expressions make validating things easy19# Regular expressions make validating things easy
19valid_epoch = re.compile(r'^[0-9]+$')20valid_epoch = re.compile(r'^[0-9]+$')
20valid_upstream = re.compile(r'^[0-9][A-Za-z0-9+:.~-]*$')21valid_upstream = re.compile(r'^[0-9][A-Za-z0-9+:.~-]*$')
21valid_revision = re.compile(r'^[A-Za-z0-9+.~]+$')22valid_revision = re.compile(r'^[A-Za-z0-9+.~]+$')
2223
23# Character comparison table for upstream and revision components24VersionError = changelog.VersionError
24cmp_table = "~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+-.:"25
2526
2627class BadInputError(VersionError):
27class VersionError(Exception): pass28 pass
28class BadInputError(VersionError): pass29
29class BadEpochError(BadInputError): pass30
30class BadUpstreamError(BadInputError): pass31class BadEpochError(BadInputError):
31class BadRevisionError(BadInputError): pass32 pass
3233
33class Version(object):34
35class BadUpstreamError(BadInputError):
36 pass
37
38
39class BadRevisionError(BadInputError):
40 pass
41
42
43class Version(changelog.Version):
34 """Debian version number.44 """Debian version number.
3545
36 This class is designed to be reasonably transparent and allow you46 This class is designed to be reasonably transparent and allow you
@@ -44,136 +54,34 @@
44 Properties:54 Properties:
45 epoch Epoch55 epoch Epoch
46 upstream Upstream version56 upstream Upstream version
47 revision Debian/local revision57 debian_version Debian/local revision
48 """58 """
4959
50 def __init__(self, ver):60 def __init__(self, ver):
51 """Parse a string or number into the three components."""
52 self.epoch = 0
53 self.upstream = None
54 self.revision = None
5561
56 ver = str(ver)62 ver = str(ver)
57 if not len(ver):63 if not len(ver):
58 raise BadInputError, "Input cannot be empty"64 raise BadInputError("Input cannot be empty")
5965
60 # Epoch is component before first colon66 try:
61 idx = ver.find(":")67 changelog.Version.__init__(self, ver)
62 if idx != -1:68 except ValueError, e:
63 self.epoch = ver[:idx]69 raise VersionError(e)
70
71 if self.epoch is not None:
64 if not len(self.epoch):72 if not len(self.epoch):
65 raise BadEpochError, "Epoch cannot be empty"73 raise BadEpochError("Epoch cannot be empty")
66 if not valid_epoch.search(self.epoch):74 if not valid_epoch.match(self.epoch):
67 raise BadEpochError, "Bad epoch format"75 raise BadEpochError("Bad epoch format")
68 ver = ver[idx+1:]76
6977 if self.debian_version is not None:
70 # Revision is component after last hyphen78 if self.debian_version == "":
71 idx = ver.rfind("-")79 raise BadRevisionError("Revision cannot be empty")
72 if idx != -1:80 if not valid_revision.search(self.debian_version):
73 self.revision = ver[idx+1:]81 raise BadRevisionError("Bad revision format")
74 if not len(self.revision):82
75 raise BadRevisionError, "Revision cannot be empty"83 if not len(self.upstream_version):
76 if not valid_revision.search(self.revision):84 raise BadUpstreamError("Upstream version cannot be empty")
77 raise BadRevisionError, "Bad revision format"85 if not valid_upstream.search(self.upstream_version):
78 ver = ver[:idx]
79
80 # Remaining component is upstream
81 self.upstream = ver
82 if not len(self.upstream):
83 raise BadUpstreamError, "Upstream version cannot be empty"
84 if not valid_upstream.search(self.upstream):
85 raise BadUpstreamError(86 raise BadUpstreamError(
86 "Bad upstream version format", self.upstream)87 "Bad upstream version format %s" % self.upstream_version)
87
88 self.epoch = int(self.epoch)
89
90 def getWithoutEpoch(self):
91 """Return the version without the epoch."""
92 str = self.upstream
93 if self.revision is not None:
94 str += "-%s" % (self.revision,)
95 return str
96
97 without_epoch = property(getWithoutEpoch)
98
99 def __str__(self):
100 """Return the class as a string for printing."""
101 str = ""
102 if self.epoch > 0:
103 str += "%d:" % (self.epoch,)
104 str += self.upstream
105 if self.revision is not None:
106 str += "-%s" % (self.revision,)
107 return str
108
109 def __repr__(self):
110 """Return a debugging representation of the object."""
111 return "<%s epoch: %d, upstream: %r, revision: %r>" \
112 % (self.__class__.__name__, self.epoch,
113 self.upstream, self.revision)
114
115 def __cmp__(self, other):
116 """Compare two Version classes."""
117 other = Version(other)
118
119 result = cmp(self.epoch, other.epoch)
120 if result != 0: return result
121
122 result = deb_cmp(self.upstream, other.upstream)
123 if result != 0: return result
124
125 result = deb_cmp(self.revision or "", other.revision or "")
126 if result != 0: return result
127
128 return 0
129
130
131def strcut(str, idx, accept):
132 """Cut characters from str that are entirely in accept."""
133 ret = ""
134 while idx < len(str) and str[idx] in accept:
135 ret += str[idx]
136 idx += 1
137
138 return (ret, idx)
139
140def deb_order(str, idx):
141 """Return the comparison order of two characters."""
142 if idx >= len(str):
143 return 0
144 elif str[idx] == "~":
145 return -1
146 else:
147 return cmp_table.index(str[idx])
148
149def deb_cmp_str(x, y):
150 """Compare two strings in a deb version."""
151 idx = 0
152 while (idx < len(x)) or (idx < len(y)):
153 result = deb_order(x, idx) - deb_order(y, idx)
154 if result < 0:
155 return -1
156 elif result > 0:
157 return 1
158
159 idx += 1
160
161 return 0
162
163def deb_cmp(x, y):
164 """Implement the string comparison outlined by Debian policy."""
165 x_idx = y_idx = 0
166 while x_idx < len(x) or y_idx < len(y):
167 # Compare strings
168 (x_str, x_idx) = strcut(x, x_idx, cmp_table)
169 (y_str, y_idx) = strcut(y, y_idx, cmp_table)
170 result = deb_cmp_str(x_str, y_str)
171 if result != 0: return result
172
173 # Compare numbers
174 (x_str, x_idx) = strcut(x, x_idx, "0123456789")
175 (y_str, y_idx) = strcut(y, y_idx, "0123456789")
176 result = cmp(int(x_str or "0"), int(y_str or "0"))
177 if result != 0: return result
178
179 return 0
18088
=== modified file 'lib/lp/archivepublisher/tests/test_debversion.py'
--- lib/lp/archivepublisher/tests/test_debversion.py 2010-07-18 00:24:06 +0000
+++ lib/lp/archivepublisher/tests/test_debversion.py 2010-08-03 15:03:56 +0000
@@ -9,8 +9,11 @@
99
10import unittest10import unittest
1111
1212from lp.archivepublisher.debversion import (BadInputError, BadUpstreamError,
13class Version(unittest.TestCase):13 Version, VersionError)
14
15
16class VersionTests(unittest.TestCase):
14 # Known values that should work17 # Known values that should work
15 VALUES = (18 VALUES = (
16 "1",19 "1",
@@ -51,323 +54,81 @@
5154
52 def testAcceptsString(self):55 def testAcceptsString(self):
53 """Version should accept a string input."""56 """Version should accept a string input."""
54 from lp.archivepublisher.debversion import Version
55 Version("1.0")57 Version("1.0")
5658
57 def testReturnString(self):59 def testReturnString(self):
58 """Version should convert to a string."""60 """Version should convert to a string."""
59 from lp.archivepublisher.debversion import Version
60 self.assertEquals(str(Version("1.0")), "1.0")61 self.assertEquals(str(Version("1.0")), "1.0")
6162
62 def testAcceptsInteger(self):63 def testAcceptsInteger(self):
63 """Version should accept an integer."""64 """Version should accept an integer."""
64 from lp.archivepublisher.debversion import Version
65 self.assertEquals(str(Version(1)), "1")65 self.assertEquals(str(Version(1)), "1")
6666
67 def testAcceptsNumber(self):67 def testAcceptsNumber(self):
68 """Version should accept a number."""68 """Version should accept a number."""
69 from lp.archivepublisher.debversion import Version
70 self.assertEquals(str(Version(1.2)), "1.2")69 self.assertEquals(str(Version(1.2)), "1.2")
7170
72 def testOmitZeroEpoch(self):
73 """Version should omit epoch when zero."""
74 from lp.archivepublisher.debversion import Version
75 self.assertEquals(str(Version("0:1.0")), "1.0")
76
77 def testOmitZeroRevision(self):
78 """Version should not omit zero revision."""
79 from lp.archivepublisher.debversion import Version
80 self.assertEquals(str(Version("1.0-0")), "1.0-0")
81
82 def testNotEmpty(self):71 def testNotEmpty(self):
83 """Version should fail with empty input."""72 """Version should fail with empty input."""
84 from lp.archivepublisher.debversion import Version, BadInputError
85 self.assertRaises(BadInputError, Version, "")73 self.assertRaises(BadInputError, Version, "")
8674
87 def testEpochNotEmpty(self):75 def testEpochNotEmpty(self):
88 """Version should fail with empty epoch."""76 """Version should fail with empty epoch."""
89 from lp.archivepublisher.debversion import Version, BadEpochError77 self.assertRaises(VersionError, Version, ":1")
90 self.assertRaises(BadEpochError, Version, ":1")
9178
92 def testEpochNonNumeric(self):79 def testEpochNonNumeric(self):
93 """Version should fail with non-numeric epoch."""80 """Version should fail with non-numeric epoch."""
94 from lp.archivepublisher.debversion import Version, BadEpochError81 self.assertRaises(VersionError, Version, "a:1")
95 self.assertRaises(BadEpochError, Version, "a:1")
9682
97 def testEpochNonInteger(self):83 def testEpochNonInteger(self):
98 """Version should fail with non-integral epoch."""84 """Version should fail with non-integral epoch."""
99 from lp.archivepublisher.debversion import Version, BadEpochError85 v = Version("1.0:1")
100 self.assertRaises(BadEpochError, Version, "1.0:1")86 self.assertEquals("1.0:1", v.upstream_version)
10187
102 def testEpochNonNegative(self):88 def testEpochNonNegative(self):
103 """Version should fail with a negative epoch."""89 """Version should fail with a negative epoch."""
104 from lp.archivepublisher.debversion import Version, BadEpochError90 self.assertRaises(VersionError, Version, "-1:1")
105 self.assertRaises(BadEpochError, Version, "-1:1")
10691
107 def testUpstreamNotEmpty(self):92 def testUpstreamNotEmpty(self):
108 """Version should fail with empty upstream."""93 """Version should fail with empty upstream."""
109 from lp.archivepublisher.debversion import Version, BadUpstreamError
110 self.assertRaises(BadUpstreamError, Version, "1:-1")94 self.assertRaises(BadUpstreamError, Version, "1:-1")
11195
112 def testUpstreamNonDigitStart(self):96 def testUpstreamNonDigitStart(self):
113 """Version should fail when upstream doesn't start with a digit."""97 """Version should fail when upstream doesn't start with a digit."""
114 from lp.archivepublisher.debversion import Version, BadUpstreamError
115 self.assertRaises(BadUpstreamError, Version, "a1")98 self.assertRaises(BadUpstreamError, Version, "a1")
11699
117 def testUpstreamInvalid(self):100 def testUpstreamInvalid(self):
118 """Version should fail when upstream contains a bad character."""101 """Version should fail when upstream contains a bad character."""
119 from lp.archivepublisher.debversion import Version, BadUpstreamError102 self.assertRaises(VersionError, Version, "1!0")
120 self.assertRaises(BadUpstreamError, Version, "1!0")
121103
122 def testRevisionNotEmpty(self):104 def testRevisionNotEmpty(self):
123 """Version should fail with empty revision."""105 """Version should not allow an empty revision."""
124 from lp.archivepublisher.debversion import Version, BadRevisionError106 v = Version("1-")
125 self.assertRaises(BadRevisionError, Version, "1-")107 self.assertEquals("1-", v.upstream_version)
108 self.assertEquals(None, v.debian_version)
126109
127 def testRevisionInvalid(self):110 def testRevisionInvalid(self):
128 """Version should fail when revision contains a bad character."""111 """Version should fail when revision contains a bad character."""
129 from lp.archivepublisher.debversion import Version, BadRevisionError112 self.assertRaises(VersionError, Version, "1-!")
130 self.assertRaises(BadRevisionError, Version, "1-!")
131113
132 def testValues(self):114 def testValues(self):
133 """Version should give same input as output."""115 """Version should give same input as output."""
134 from lp.archivepublisher.debversion import Version
135 for value in self.VALUES:116 for value in self.VALUES:
136 result = str(Version(value))117 result = str(Version(value))
137 self.assertEquals(value, result)118 self.assertEquals(value, result)
138119
139 def testComparisons(self):120 def testComparisons(self):
140 """Sample Version comparisons should pass."""121 """Sample Version comparisons should pass."""
141 from lp.archivepublisher.debversion import Version
142 for x, y in self.COMPARISONS:122 for x, y in self.COMPARISONS:
143 self.failUnless(Version(x) < Version(y))123 self.failUnless(Version(x) < Version(y))
144124
145 def testNullEpochIsZero(self):125 def testNullEpochIsZero(self):
146 """Version should treat an omitted epoch as a zero one."""126 """Version should treat an omitted epoch as a zero one."""
147 from lp.archivepublisher.debversion import Version127 self.assertEquals(Version("1.0"), Version("0:1.0"))
148 self.failUnless(Version("1.0") == Version("0:1.0"))128
149129 def notestNullRevisionIsZero(self):
150 def testNullRevisionIsZero(self):130 """Version should treat an omitted revision as being equal to zero.
151 """Version should treat an omitted revision as a zero one.
152
153 NOTE: This isn't what Policy says! Policy says that an omitted
154 revision should compare less than the presence of one, whatever
155 its value.
156
157 The implementation (dpkg) disagrees, and considers an omitted
158 revision equal to a zero one. I'm obviously biased as to which
159 this module obeys.
160 """131 """
132 self.assertEquals(Version("1.0"), Version("1.0-0"))
161 from lp.archivepublisher.debversion import Version133 from lp.archivepublisher.debversion import Version
162 self.failUnless(Version("1.0") == Version("1.0-0"))134 self.failUnless(Version("1.0") == Version("1.0-0"))
163
164 def testWithoutEpoch(self):
165 """Version.without_epoch returns version without epoch."""
166 from lp.archivepublisher.debversion import Version
167 self.assertEquals(Version("1:2.0").without_epoch, "2.0")
168
169
170class Strcut(unittest.TestCase):
171
172 def testNoMatch(self):
173 """str_cut works when initial characters aren't accepted."""
174 from lp.archivepublisher.debversion import strcut
175 self.assertEquals(strcut("foo", 0, "gh"), ("", 0))
176
177 def testSingleMatch(self):
178 """str_cut matches single initial character."""
179 from lp.archivepublisher.debversion import strcut
180 self.assertEquals(strcut("foo", 0, "fgh"), ("f", 1))
181
182 def testMultipleMatch(self):
183 """str_cut matches multiple initial characters."""
184 from lp.archivepublisher.debversion import strcut
185 self.assertEquals(strcut("foobar", 0, "fo"), ("foo", 3))
186
187 def testCompleteMatch(self):
188 """str_cut works when all characters match."""
189 from lp.archivepublisher.debversion import strcut
190 self.assertEquals(strcut("foo", 0, "fo"), ("foo", 3))
191
192 def testNonMiddleMatch(self):
193 """str_cut doesn't match characters that aren't at the start."""
194 from lp.archivepublisher.debversion import strcut
195 self.assertEquals(strcut("barfooquux", 0, "fo"), ("", 0))
196
197 def testIndexMatch(self):
198 """str_cut matches characters from middle when index given."""
199 from lp.archivepublisher.debversion import strcut
200 self.assertEquals(strcut("barfooquux", 3, "fo"), ("foo", 6))
201
202
203class DebOrder(unittest.TestCase):
204 # Non-tilde characters in order
205 CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+-.:"
206
207 def testTilde(self):
208 """deb_order returns -1 for a tilde."""
209 from lp.archivepublisher.debversion import deb_order
210 self.assertEquals(deb_order("~", 0), -1)
211
212 def testCharacters(self):
213 """deb_order returns positive for other characters."""
214 from lp.archivepublisher.debversion import deb_order
215 for char in self.CHARS:
216 self.failUnless(deb_order(char, 0) > 0)
217
218 def testCharacterOrder(self):
219 """deb_order returns characters in correct order."""
220 from lp.archivepublisher.debversion import deb_order
221 last = None
222 for char in self.CHARS:
223 if last is not None:
224 self.failUnless(deb_order(char, 0) > deb_order(last, 0))
225 last = char
226
227 def testOvershoot(self):
228 """deb_order returns zero if idx is longer than the string."""
229 from lp.archivepublisher.debversion import deb_order
230 self.assertEquals(deb_order("foo", 10), 0)
231
232 def testEmptyString(self):
233 """deb_order returns zero if given empty string."""
234 from lp.archivepublisher.debversion import deb_order
235 self.assertEquals(deb_order("", 0), 0)
236
237
238class DebCmpStr(unittest.TestCase):
239 # Sample strings
240 VALUES = (
241 "foo",
242 "FOO",
243 "Foo",
244 "foo+bar",
245 "foo-bar",
246 "foo.bar",
247 "foo:bar",
248 )
249
250 # Non-letter characters in order
251 CHARS = "+-.:"
252
253 def testEmptyStrings(self):
254 """deb_cmp_str returns zero when given empty strings."""
255 from lp.archivepublisher.debversion import deb_cmp_str
256 self.assertEquals(deb_cmp_str("", ""), 0)
257
258 def testFirstEmptyString(self):
259 """deb_cmp_str returns -1 when first string is empty."""
260 from lp.archivepublisher.debversion import deb_cmp_str
261 self.assertEquals(deb_cmp_str("", "foo"), -1)
262
263 def testSecondEmptyString(self):
264 """deb_cmp_str returns 1 when second string is empty."""
265 from lp.archivepublisher.debversion import deb_cmp_str
266 self.assertEquals(deb_cmp_str("foo", ""), 1)
267
268 def testTildeEmptyString(self):
269 """deb_cmp_str returns -1 when tilde compared to empty string."""
270 from lp.archivepublisher.debversion import deb_cmp_str
271 self.assertEquals(deb_cmp_str("~", ""), -1)
272
273 def testLongerFirstString(self):
274 """deb_cmp_str returns 1 when first string is longer."""
275 from lp.archivepublisher.debversion import deb_cmp_str
276 self.assertEquals(deb_cmp_str("foobar", "foo"), 1)
277
278 def testLongerSecondString(self):
279 """deb_cmp_str returns -1 when second string is longer."""
280 from lp.archivepublisher.debversion import deb_cmp_str
281 self.assertEquals(deb_cmp_str("foo", "foobar"), -1)
282
283 def testTildeTail(self):
284 """deb_cmp_str returns -1 when first string is longer by a tilde."""
285 from lp.archivepublisher.debversion import deb_cmp_str
286 self.assertEquals(deb_cmp_str("foo~", "foo"), -1)
287
288 def testIdenticalString(self):
289 """deb_cmp_str returns 0 when given identical strings."""
290 from lp.archivepublisher.debversion import deb_cmp_str
291 for value in self.VALUES:
292 self.assertEquals(deb_cmp_str(value, value), 0)
293
294 def testNonIdenticalString(self):
295 """deb_cmp_str returns non-zero when given non-identical strings."""
296 from lp.archivepublisher.debversion import deb_cmp_str
297 last = self.VALUES[-1]
298 for value in self.VALUES:
299 self.assertNotEqual(deb_cmp_str(last, value), 0)
300 last = value
301
302 def testIdenticalTilde(self):
303 """deb_cmp_str returns 0 when given identical tilded strings."""
304 from lp.archivepublisher.debversion import deb_cmp_str
305 self.assertEquals(deb_cmp_str("foo~", "foo~"), 0)
306
307 def testUppercaseLetters(self):
308 """deb_cmp_str orders upper case letters in alphabetical order."""
309 from lp.archivepublisher.debversion import deb_cmp_str
310 last = "A"
311 for value in range(ord("B"), ord("Z")):
312 self.assertEquals(deb_cmp_str(last, chr(value)), -1)
313 last = chr(value)
314
315 def testLowercaseLetters(self):
316 """deb_cmp_str orders lower case letters in alphabetical order."""
317 from lp.archivepublisher.debversion import deb_cmp_str
318 last = "a"
319 for value in range(ord("b"), ord("z")):
320 self.assertEquals(deb_cmp_str(last, chr(value)), -1)
321 last = chr(value)
322
323 def testLowerGreaterThanUpper(self):
324 """deb_cmp_str orders lower case letters after upper case."""
325 from lp.archivepublisher.debversion import deb_cmp_str
326 self.assertEquals(deb_cmp_str("a", "Z"), 1)
327
328 def testCharacters(self):
329 """deb_cmp_str orders characters in prescribed order."""
330 from lp.archivepublisher.debversion import deb_cmp_str
331 chars = list(self.CHARS)
332 last = chars.pop(0)
333 for char in chars:
334 self.assertEquals(deb_cmp_str(last, char), -1)
335 last = char
336
337 def testCharactersGreaterThanLetters(self):
338 """deb_cmp_str orders characters above letters."""
339 from lp.archivepublisher.debversion import deb_cmp_str
340 self.assertEquals(deb_cmp_str(self.CHARS[0], "z"), 1)
341
342
343class DebCmp(unittest.TestCase):
344
345 def testEmptyString(self):
346 """deb_cmp returns 0 for the empty string."""
347 from lp.archivepublisher.debversion import deb_cmp
348 self.assertEquals(deb_cmp("", ""), 0)
349
350 def testStringCompare(self):
351 """deb_cmp compares initial string portions correctly."""
352 from lp.archivepublisher.debversion import deb_cmp
353 self.assertEquals(deb_cmp("a", "b"), -1)
354 self.assertEquals(deb_cmp("b", "a"), 1)
355
356 def testNumericCompare(self):
357 """deb_cmp compares numeric portions correctly."""
358 from lp.archivepublisher.debversion import deb_cmp
359 self.assertEquals(deb_cmp("foo1", "foo2"), -1)
360 self.assertEquals(deb_cmp("foo2", "foo1"), 1)
361 self.assertEquals(deb_cmp("foo200", "foo5"), 1)
362
363 def testMissingNumeric(self):
364 """deb_cmp treats missing numeric as zero."""
365 from lp.archivepublisher.debversion import deb_cmp
366 self.assertEquals(deb_cmp("foo", "foo0"), 0)
367 self.assertEquals(deb_cmp("foo", "foo1"), -1)
368 self.assertEquals(deb_cmp("foo1", "foo"), 1)
369
370 def testEmptyStringPortion(self):
371 """deb_cmp works when string potion is empty."""
372 from lp.archivepublisher.debversion import deb_cmp
373 self.assertEquals(deb_cmp("100", "foo100"), -1)
374135
=== modified file 'lib/lp/registry/browser/tests/distroseries-views.txt'
--- lib/lp/registry/browser/tests/distroseries-views.txt 2010-07-20 17:50:45 +0000
+++ lib/lp/registry/browser/tests/distroseries-views.txt 2010-08-03 15:03:56 +0000
@@ -375,7 +375,7 @@
375 >>> view = create_initialized_view(ubuntu, '+addseries', form=form)375 >>> view = create_initialized_view(ubuntu, '+addseries', form=form)
376 >>> for error in view.errors:376 >>> for error in view.errors:
377 ... print error[2]377 ... print error[2]
378 'Hardy-6.06-LTS': Bad upstream version format378 'Hardy-6.06-LTS': Could not parse version...
379379
380The distroseries version is unique to a distribution. Version '2009.06'380The distroseries version is unique to a distribution. Version '2009.06'
381cannot be reused by another Ubuntu series.381cannot be reused by another Ubuntu series.
382382
=== modified file 'lib/lp/registry/interfaces/distroseries.py'
--- lib/lp/registry/interfaces/distroseries.py 2010-08-02 02:56:37 +0000
+++ lib/lp/registry/interfaces/distroseries.py 2010-08-03 15:03:56 +0000
@@ -127,7 +127,7 @@
127 Version(version)127 Version(version)
128 except VersionError, error:128 except VersionError, error:
129 raise LaunchpadValidationError(129 raise LaunchpadValidationError(
130 "'%s': %s" % (version, error[0]))130 "'%s': %s" % (version, error))
131131
132132
133class IDistroSeriesEditRestricted(Interface):133class IDistroSeriesEditRestricted(Interface):
134134
=== modified file 'lib/lp/soyuz/doc/distroseriesqueue-dist-upgrader.txt'
--- lib/lp/soyuz/doc/distroseriesqueue-dist-upgrader.txt 2009-12-24 01:41:54 +0000
+++ lib/lp/soyuz/doc/distroseriesqueue-dist-upgrader.txt 2010-08-03 15:03:56 +0000
@@ -249,7 +249,7 @@
249249
250 >>> pub_records = upload.queue_root.realiseUpload(mock_logger)250 >>> pub_records = upload.queue_root.realiseUpload(mock_logger)
251 DEBUG: Publishing custom dist-upgrader_20070219.1234_all.tar.gz to ubuntutest/breezy-autotest251 DEBUG: Publishing custom dist-upgrader_20070219.1234_all.tar.gz to ubuntutest/breezy-autotest
252 ERROR: Queue item ignored: bad version found in '.../dist-upgrader_20070219.1234_all.tar.gz': ('Bad upstream version format', 'foobar')252 ERROR: Queue item ignored: bad version found in '.../dist-upgrader_20070219.1234_all.tar.gz': Could not parse version: Bad upstream version format foobar
253253
254Check if the queue item remained in ACCEPTED and not cruft was254Check if the queue item remained in ACCEPTED and not cruft was
255inserted in the archive:255inserted in the archive: