[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
Tue Mar 29 05:48:54 PDT 2022
kpdev42 updated this revision to Diff 418850.
kpdev42 added a comment.
Add hashlib
Repository:
rLNT LNT
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109577/new/
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
@@ -1,4 +1,5 @@
import colorsys
+import hashlib
import math
import re
from lnt.server.reporting.analysis import REGRESSED
@@ -262,25 +263,26 @@
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)
if val:
return val
- else:
- dotted_parsed = integral_rex.findall(dotted)
- val = tuple([int(d) for d in dotted_parsed])
- 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
+ [int(hashlib.sha1(dotted.encode("utf-8")).hexdigest(), 16)])
+ if cache is not None:
+ cache[dotted] = val
return val
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109577.418850.patch
Type: text/x-patch
Size: 1429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220329/48152c3b/attachment.bin>
More information about the llvm-commits
mailing list