public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jon TURNEY <jturney@sourceware.org>
To: cygwin-apps-cvs@sourceware.org
Subject: [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20200611-6-ge790649
Date: Sun, 19 Jul 2020 16:51:31 +0000 (GMT)	[thread overview]
Message-ID: <20200719165131.5C7903858D34@sourceware.org> (raw)




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=e79064972edfad6a12fe0a27e8dceb63fe5550dc

commit e79064972edfad6a12fe0a27e8dceb63fe5550dc
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sun Jul 19 16:02:59 2020 +0100

    package.delete() also deletes empty packages
    
    Once a Package object no longer contains any files (archives or hints),
    it can be removed from the package set.
    
    (This fixes calm complaining when it wants to vault a stale package
    which had source, but no kept version does. Otherwise it complains that
    the source package has no versions)
    
    Also remove removed hints from version_hints, since we iterate over that
    in some places. This also prevents removed versions from bogusly
    appearing in packages.json, so update test data appropriately.


Diff:
---
 calm/package.py                                   | 12 ++++++++++--
 test/testdata/process_arch/packages.json.expected |  5 -----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/calm/package.py b/calm/package.py
index 4151c21..2d115c2 100755
--- a/calm/package.py
+++ b/calm/package.py
@@ -1290,7 +1290,9 @@ def merge(a, *l):
 #
 
 def delete(packages, path, fn):
+    ex_packages = []
     (_, _, pkgpath) = path.split(os.sep, 2)
+
     for p in packages:
         if packages[p].pkgpath == pkgpath:
             for vr in packages[p].tars:
@@ -1306,11 +1308,17 @@ def delete(packages, path, fn):
             for h in packages[p].hints:
                 if packages[p].hints[h].fn == fn:
                     del packages[p].hints[h]
+                    del packages[p].version_hints[h]
                     break
 
-        # if nothing remains, remove also from package set
+        # if nothing remains, also remove from package set
         if not packages[p].vermap and not packages[p].hints:
-            del packages[p]
+            ex_packages.append(p)
+
+    # (modify package set outside of iteration over it)
+    for p in ex_packages:
+        logging.info("removing package '%s' for package set" % (p))
+        del packages[p]
 
 
 #
diff --git a/test/testdata/process_arch/packages.json.expected b/test/testdata/process_arch/packages.json.expected
index f639e3c..05e4168 100644
--- a/test/testdata/process_arch/packages.json.expected
+++ b/test/testdata/process_arch/packages.json.expected
@@ -282,7 +282,6 @@
  '            "summary": "Perl distribution Net-SMTP-SSL",\n'
  '            "versions": {\n'
  '                "stable": [\n'
- '                    "1.01-1",\n'
  '                    "1.02-1",\n'
  '                    "1.03-1",\n'
  '                    "1.03-2"\n'
@@ -330,13 +329,10 @@
  '            "summary": "Test package for stale version removal",\n'
  '            "versions": {\n'
  '                "stable": [\n'
- '                    "240-1",\n'
- '                    "242-0",\n'
  '                    "243-0",\n'
  '                    "250-0"\n'
  '                ],\n'
  '                "test": [\n'
- '                    "251-0",\n'
  '                    "260-0"\n'
  '                ]\n'
  '            }\n'
@@ -430,7 +426,6 @@
  '            "summary": "A test package",\n'
  '            "versions": {\n'
  '                "stable": [\n'
- '                    "0.1-1",\n'
  '                    "1.0-1"\n'
  '                ]\n'
  '            }\n'



                 reply	other threads:[~2020-07-19 16:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200719165131.5C7903858D34@sourceware.org \
    --to=jturney@sourceware.org \
    --cc=cygwin-apps-cvs@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).