15425 action comparison dies if one argument is not an action
15699 pkgdiff exit status not correct when ignoring differences
--- a/src/modules/actions/generic.py Wed Apr 21 13:57:00 2010 +0100
+++ b/src/modules/actions/generic.py Wed Apr 21 10:22:37 2010 -0700
@@ -235,12 +235,20 @@
return out
+ def __eq__(self, other):
+ if isinstance(other, Action):
+ return cmp(self, other) == 0
+ return False
+
def __cmp__(self, other):
"""Compare actions for ordering. The ordinality of a
given action is computed and stored at action
initialization."""
+ if not isinstance(other, Action):
+ return cmp(id(self), id(other))
res = cmp(self.ord, other.ord)
+
if res == 0:
return self.compare(other) # often subclassed
--- a/src/util/publish/pkgdiff.py Wed Apr 21 13:57:00 2010 +0100
+++ b/src/util/publish/pkgdiff.py Wed Apr 21 10:22:37 2010 -0700
@@ -146,12 +146,17 @@
diffs += a
diffs += c
diffs += r
- # License action still causes spurious diffs... elide to get exit
- # code correct
- if not diffs or (len(diffs) == 1 and
- diffs[0][0] == diffs[0][1]): # no real changes detected at all
+ # License action still causes spurious diffs... check again for now.
+
+ real_diffs = [
+ (a,b)
+ for a, b in diffs
+ if a is None or b is None or a.different(b)
+ ]
+
+ if not real_diffs:
return 0
-
+
# define some ordering functions so that output is easily readable
# First, a human version of action comparison that works across
# variants and action changes...
@@ -203,17 +208,20 @@
def conditional_print(s, a):
if onlyattrs:
if not set(a.attrs.keys()) & onlyattrs:
- return
+ return False
elif ignoreattrs:
if not set(a.attrs.keys()) - ignoreattrs:
- return
+ return False
print "%s %s" % (s, a)
-
+ return True
+
+ different = False
+
for old, new in diffs:
if not new:
- conditional_print("-", old)
+ different |= conditional_print("-", old)
elif not old:
- conditional_print("+", new)
+ different |= conditional_print("+", new)
else:
s = []
@@ -251,6 +259,7 @@
s.append(" + %s" % diff_str)
# print out part of action that is the same
if s:
+ different = True
print "%s %s %s" % (old.name,
attrval(old.attrs, old.key_attr),
" ".join(("%s" % attrval(old.attrs,v)
@@ -258,7 +267,7 @@
for l in s:
print l
- sys.exit(1)
+ return int(different)
def product(*args, **kwds):
# product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy