[calm - Cygwin server-side packaging maintenance script] branch master, updated. 20200611-6-ge790649
Jon TURNEY via Cygwin-apps-cvs <[email protected]>
| Newsgroups | gmane.os.cygwin.cvs.apps |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=e79064972edfad6a12fe0a27e8dceb63fe5550dc commit e79064972edfad6a12fe0a27e8dceb63fe5550dc Author: Jon Turney <[email protected]> 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'