public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: /, lib/_emerge/
Date: Mon,  2 Oct 2023 11:47:56 +0000 (UTC)	[thread overview]
Message-ID: <1696247273.2b0a904f6b3e0376d0ee2359469d8732c11e376b.sam@gentoo> (raw)

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


             reply	other threads:[~2023-10-02 11:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-02 11:47 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-12-19  1:25 [gentoo-commits] proj/portage:master commit in: /, lib/_emerge/ Zac Medico
2024-08-02 13:38 James Le Cuirot
2023-10-02 12:22 Sam James
2023-08-17  6:53 Sam James
2023-07-09  6:25 Sam James
2023-02-18  0:00 Sam James
2023-01-10  3:28 Sam James
2023-01-10  3:28 Sam James
2022-11-23 23:02 Sam James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1696247273.2b0a904f6b3e0376d0ee2359469d8732c11e376b.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox