#13 Provide a way to specify a null epoch in the 6-arg form of rpmdev-vercmp
Closed: Fixed None Opened 13 years ago by pghmcfc.

Using "" or "(none)" doesn't work, but the two-arg form does:
{{{
$ rpmdev-vercmp 0 2 1 "" 3 1
0:2-1 is newer
$ rpmdev-vercmp 0 2 1 "(none)" 3 1
0:2-1 is newer
$ rpmdev-vercmp 0:2-1 3-1
0:3-1 is newer
}}}
This had led to the retention of pointless zero epochs in some cases, e.g.:

http://lists.fedoraproject.org/pipermail/scm-commits/2011-January/543691.html


Potential fix:
{{{
--- /usr/bin/rpmdev-vercmp.orig 2010-09-27 19:32:19.000000000 +0100
+++ /usr/bin/rpmdev-vercmp 2011-01-14 10:16:59.386396930 +0000
@@ -34,6 +34,10 @@
""")

def vercmp((e1, v1, r1), (e2, v2, r2)):
+ if e1 in ['', '(none)', '(None)']:
+ e1 = None
+ if e2 in ['', '(none)', '(None)']:
+ e2 = None
rc = rpm.labelCompare((e1, v1, r1), (e2, v2, r2))
return rc

}}}

Empty string now gets passed as None to rpm.labelCompare in git (and output has been tweaked as well). I didn't add special "none" cases as I want the code to be as clean from internal assumptions/special cases as possible.

{{{
$ ./rpmdev-vercmp 0 2 1 "" 3 1
0:2-1 < 3-1
$ ./rpmdev-vercmp 0:2-1 3-1
0:2-1 < 3-1
}}}

Login to comment on this ticket.

Metadata