From 93d4e7698afc92e3b257c2a0b2050540357edc96 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Sat, 24 Feb 2024 19:05:51 -0800 Subject: [PATCH] gnulib-tool.py: Handle the sorting of modules correctly. See discussion at * pygnulib/GLConfig.py (GLConfig.addModule, CLConfig.setModules): Use a sorted set when adding modules to replicate "sort -u" used by gnulib-tool. * pygnulib/GLImport.py (GLImport.actioncmd): Don't sort modules when constructing actioncmd as GLConfig handles it for us. --- ChangeLog | 11 +++++++++++ pygnulib/GLConfig.py | 6 ++++-- pygnulib/GLImport.py | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1910933eb7..a616db7e09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2024-02-24 Collin Funk + + gnulib-tool.py: Handle the sorting of modules correctly. + See discussion at + + * pygnulib/GLConfig.py (GLConfig.addModule, CLConfig.setModules): Use a + sorted set when adding modules to replicate "sort -u" used by + gnulib-tool. + * pygnulib/GLImport.py (GLImport.actioncmd): Don't sort modules when + constructing actioncmd as GLConfig handles it for us. + 2024-02-24 Collin Funk gnulib-tool.py: Follow gnulib-tool changes, part 28. diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py index bdebf243cc..03da6f8e3c 100644 --- a/pygnulib/GLConfig.py +++ b/pygnulib/GLConfig.py @@ -476,7 +476,7 @@ class GLConfig(object): '''Add the module to the modules list.''' if type(module) is str: if module not in self.table['modules']: - self.table['modules'] += [module] + self.table['modules'] = sorted(list(set(self.table['modules'] + [module]))) else: # if module has not str type raise TypeError('module must be a string, not %s' % type(module).__name__) @@ -499,7 +499,9 @@ class GLConfig(object): if type(modules) is list or type(modules) is tuple: old_modules = self.table['modules'] self.table['modules'] = list() - for module in modules: + # Canonicalize the list of specified modules. + # sort -u + for module in sorted(set(modules)): try: # Try to add each module self.addModule(module) except TypeError as error: diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index c69a33deb7..9b08e7e4b6 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -438,9 +438,9 @@ class GLImport(object): elif vc_files == False: actioncmd += ' \\\n# --no-vc-files' if len(avoids) > 0: - actioncmd += ''.join([f" \\\n# --avoid={x}" for x in sorted(avoids)]) + actioncmd += ''.join([f" \\\n# --avoid={x}" for x in avoids]) if len(modules) > 0: - actioncmd += ''.join([f" \\\n# {x}" for x in sorted(modules)]) + actioncmd += ''.join([f" \\\n# {x}" for x in modules]) return actioncmd def relative_to_destdir(self, dir): -- 2.39.2