commit: 2b0a904f6b3e0376d0ee2359469d8732c11e376b Author: Mike Gilbert <floppym <AT> gentoo <DOT> org> AuthorDate: Sun Oct 1 21:36:23 2023 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Mon Oct 2 11:47:53 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=2b0a904f
search: fix 'mlen' counter for ambiguous package names self.mlen was being incremented in both addCP() and output(). Drop the increment in addCP(), and convert mlen to a function-local variable in output(). Bug: https://bugs.gentoo.org/915054 Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org> Closes: https://github.com/gentoo/portage/pull/1106 Signed-off-by: Sam James <sam <AT> gentoo.org> NEWS | 3 +++ lib/_emerge/search.py | 14 +++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index aa2b39ee9b..bfa6261bb9 100644 --- a/NEWS +++ b/NEWS @@ -28,6 +28,9 @@ Bug fixes: * dispatch-conf, etc-update: fix SELinux security labels on merged files. +* emerge: fix application count when listing search results for ambiguous + packages (bug #915054). + Cleanups: * vartree: Remove unused variables and parameters diff --git a/lib/_emerge/search.py b/lib/_emerge/search.py index e422434a72..62406258d0 100644 --- a/lib/_emerge/search.py +++ b/lib/_emerge/search.py @@ -57,7 +57,6 @@ class search: self.fuzzy = fuzzy self.search_similarity = 80 if search_similarity is None else search_similarity self.matches = {"pkg": []} - self.mlen = 0 self._dbs = [] @@ -377,7 +376,6 @@ class search: if not self._xmatch("match-all", cp): return self.matches["pkg"].append(cp) - self.mlen += 1 def output(self): """Outputs the results of the search.""" @@ -407,8 +405,9 @@ class search: # Do a normal search iterator = self._iter_search() + mlen = 0 for mtype, match in iterator: - self.mlen += 1 + mlen += 1 masked = False full_package = None if mtype in ("pkg", "desc"): @@ -521,14 +520,7 @@ class search: " " + darkgreen("License:") + " " + license + "\n\n" ) - msg.append("[ Applications found : " + bold(str(self.mlen)) + " ]\n\n") - - # This method can be called multiple times, so - # reset the match count for the next call. Don't - # reset it at the beginning of this method, since - # that would lose modfications from the addCP - # method. - self.mlen = 0 + msg.append("[ Applications found : " + bold(str(mlen)) + " ]\n\n") # # private interface