[PATCH] D109577: [LNT] Fixed incorrect orders behavior in case of miss formatted llvm_project_revision
Pavel Kosov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 10 01:11:53 PDT 2021
kpdev42 created this revision.
kpdev42 added reviewers: cmatthews, thopre, danilaml.
kpdev42 added a project: LLVM.
Herald added a subscriber: dkolesnichenko.
kpdev42 requested review of this revision.
LNT expected that llvm_project_revision is a version in the format 1.2.3. But it is a string and may contain any symbols. Someone may use hex numbers, dashes, etc. If llvm_project_revision does not contain any digit at all the behavior is undefined and caused inconsistent DB. hash(str) is a workaround to fix this behavior. Note it does not fix the sorting.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D109577
Files:
lnt/server/ui/util.py
Index: lnt/server/ui/util.py
===================================================================
--- lnt/server/ui/util.py
+++ lnt/server/ui/util.py
@@ -262,13 +262,15 @@
that is ordered and sortable.
"1" -> (1)
"1.2.3" -> (1,2,3)
+ "1a2,3-45:b6;" -> (1,2,3,45,6)
+ "abc" -> (hash("abc"))
:param dotted: the string revision to convert
:param cache: a dict to use as a cache or None for no cache.
because this is called many times, it is a nice performance
increase to cache these conversions.
:return: a tuple with the numeric bits of this revision as ints.
-
+ return a hash in case of miss formatted version to avoid wrong equals.
"""
if cache is not None:
val = cache.get(dotted)
@@ -276,11 +278,11 @@
return val
else:
dotted_parsed = integral_rex.findall(dotted)
- val = tuple([int(d) for d in dotted_parsed])
+ val = tuple([int(d) for d in dotted_parsed] or [hash(dotted)])
cache[dotted] = val
return val
dotted_parsed = integral_rex.findall(dotted)
- val = tuple([int(d) for d in dotted_parsed])
+ val = tuple([int(d) for d in dotted_parsed] or [hash(dotted)])
return val
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109577.371812.patch
Type: text/x-patch
Size: 1263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210910/f61b6124/attachment.bin>
More information about the llvm-commits
mailing list