Skip to content

Commit be9ab07

Browse files
committed
Merge branch 'hg'
2 parents 742355e + d05e349 commit be9ab07

File tree

3 files changed

+38
-42
lines changed

3 files changed

+38
-42
lines changed

.hgtags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,3 +497,4 @@ b1bb202dfa4679d5c482b66385caf99eb1778654 st190
497497
0000000000000000000000000000000000000000 st190
498498
0000000000000000000000000000000000000000 st190
499499
da5d68806e4acacc7259e6a1dc6a07b9232e3443 st190
500+
77a22afac056e605034ea6293762821d733e01d5 st191

src/tests/cli/t_pkgdiff.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,15 @@ def test_03_hash(self):
286286
file path=bin/true elfarch=i386 elfbits=32 elfhash=efgh
287287
- pkg.content-hash=file:sha512t_256:ijkl
288288
+ pkg.content-hash=file:sha512t_256:mnop
289-
file path=etc/hosts
289+
file path=etc/hosts
290290
- abcd
291291
+ efgh
292-
file path=etc/motd
292+
file path=etc/motd
293293
- 4ab5de3107a63f5cf454485f720cac025f1b7002
294294
+ 3aba408bd383553aa84bba4fefe8495239927763
295295
- chash=dc03afd488e3b3e4c4993d2403d7e15603b0a391
296296
+ chash=f0c2aa47dce2ba0132efdace8d3b88b6589767f3
297-
file path=etc/passwd
297+
file path=etc/passwd
298298
- pkg.content-hash=file:sha512t_256:abcd
299299
+ pkg.content-hash=file:sha512t_256:efgh
300300
"""
@@ -311,15 +311,15 @@ def test_03_hash(self):
311311
+ bar
312312
- pkg.content-hash=gelf.unsigned:sha512t_256:abcd pkg.content-hash=gelf:sha512t_256:abcd
313313
+ pkg.content-hash=gelf.unsigned:sha512t_256:efgh pkg.content-hash=gelf:sha512t_256:efgh
314-
file path=etc/hosts
314+
file path=etc/hosts
315315
- abcd
316316
+ efgh
317-
file path=etc/motd
317+
file path=etc/motd
318318
- 4ab5de3107a63f5cf454485f720cac025f1b7002
319319
+ 3aba408bd383553aa84bba4fefe8495239927763
320320
- chash=dc03afd488e3b3e4c4993d2403d7e15603b0a391
321321
+ chash=f0c2aa47dce2ba0132efdace8d3b88b6589767f3
322-
file path=etc/passwd
322+
file path=etc/passwd
323323
- pkg.content-hash=file:sha512t_256:abcd
324324
+ pkg.content-hash=file:sha512t_256:efgh
325325
"""
@@ -336,10 +336,10 @@ def test_03_hash(self):
336336
file path=bin/ls elfarch=i386 elfbits=32 elfhash=abcd
337337
- foo
338338
+ bar
339-
file path=etc/hosts
339+
file path=etc/hosts
340340
- abcd
341341
+ efgh
342-
file path=etc/motd
342+
file path=etc/motd
343343
- 4ab5de3107a63f5cf454485f720cac025f1b7002
344344
+ 3aba408bd383553aa84bba4fefe8495239927763
345345
"""
@@ -357,7 +357,7 @@ def test_03_hash(self):
357357
self.pkgdiff(" ".join(("-t license", self.hashed20_p5m,
358358
self.hashed10_p5m)), exit=1)
359359
expected = """\
360-
license license=lic_OTN
360+
license license=lic_OTN
361361
- 7ab6de3107a63f5cf454485f720cac025f1b7001
362362
+ 6aba708bd383553aa84bba4fefe8495239927767
363363
- chash=cc05afd488e3b3e4c4993d2403d7e15603b0a398
@@ -370,7 +370,7 @@ def test_03_hash(self):
370370
self.pkgdiff(" ".join(("-t license -o hash", self.hashed20_p5m,
371371
self.hashed10_p5m)), exit=1)
372372
expected = """\
373-
license license=lic_OTN
373+
license license=lic_OTN
374374
- 7ab6de3107a63f5cf454485f720cac025f1b7001
375375
+ 6aba708bd383553aa84bba4fefe8495239927767
376376
"""

src/util/publish/pkgdiff.py

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#
2222

2323
#
24-
# Copyright (c) 2009, 2024, Oracle and/or its affiliates.
24+
# Copyright (c) 2009, 2025, Oracle and/or its affiliates.
2525
#
2626

2727
try:
@@ -317,29 +317,28 @@ def conditional_print(s, a):
317317
elif not old:
318318
different |= conditional_print("+", new)
319319
else:
320-
s = []
320+
output = []
321321

322322
if not onlyattrs:
323-
if (hasattr(old, "hash") and
324-
"hash" not in ignoreattrs):
323+
if hasattr(old, "hash") and "hash" not in ignoreattrs:
325324
if old.hash != new.hash:
326-
s.append(" - {0}".format(old.hash))
327-
s.append(" + {0}".format(new.hash))
328-
attrdiffs = (set(new.differences(old)) -
329-
ignoreattrs)
330-
attrsames = sorted( list(set(list(old.attrs.keys()) +
331-
list(new.attrs.keys())) -
332-
set(new.differences(old))))
325+
output.append(f" - {old.hash}")
326+
output.append(f" + {new.hash}")
327+
attrdiffs = set(new.differences(old)) - ignoreattrs
333328
else:
334329
if hasattr(old, "hash") and "hash" in onlyattrs:
335330
if old.hash != new.hash:
336-
s.append(" - {0}".format(old.hash))
337-
s.append(" + {0}".format(new.hash))
338-
attrdiffs = (set(new.differences(old)) &
339-
onlyattrs)
340-
attrsames = sorted(list(set(list(old.attrs.keys()) +
341-
list(new.attrs.keys())) -
342-
set(new.differences(old))))
331+
output.append(f" - {old.hash}")
332+
output.append(f" + {new.hash}")
333+
attrdiffs = set(new.differences(old)) & onlyattrs
334+
335+
# sort attributes by name and put the key attribute first
336+
attrsames = sorted(
337+
set(old.attrs)
338+
.union(new.attrs)
339+
.difference(new.differences(old)),
340+
key=lambda val: "" if val == old.key_attr else val
341+
)
343342

344343
for a in sorted(attrdiffs):
345344
if a in old.attrs and a in new.attrs and \
@@ -350,25 +349,21 @@ def conditional_print(s, a):
350349
else:
351350
elide_set = set()
352351
if a in old.attrs:
353-
diff_str = attrval(old.attrs, a,
354-
elide_iter=elide_set)
352+
diff_str = attrval(old.attrs, a, elide_iter=elide_set)
355353
if diff_str:
356-
s.append(" - {0}".format(diff_str))
354+
output.append(f" - {diff_str}")
357355
if a in new.attrs:
358-
diff_str = attrval(new.attrs, a,
359-
elide_iter=elide_set)
356+
diff_str = attrval(new.attrs, a, elide_iter=elide_set)
360357
if diff_str:
361-
s.append(" + {0}".format(diff_str))
362-
# print out part of action that is the same
363-
if s:
358+
output.append(f" + {diff_str}")
359+
if output:
364360
different = True
365-
print("{0} {1} {2}".format(old.name,
366-
attrval(old.attrs, old.key_attr),
367-
" ".join(("{0}".format(attrval(old.attrs, v))
368-
for v in attrsames if v != old.key_attr))))
369361

370-
for l in s:
371-
print(l)
362+
# print out part of action that is the same
363+
attrs = ' '.join(attrval(old.attrs, val) for val in attrsames)
364+
print(f"{old.name} {attrs}")
365+
# and then all the differences
366+
print("\n".join(output))
372367

373368
return int(different)
374369

0 commit comments

Comments
 (0)