* gnulib-tool.py: Sort file lists case-sensitively
@ 2024-04-20 21:05 Bruno Haible
0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2024-04-20 21:05 UTC (permalink / raw)
To: bug-gnulib
When computing the list of old and new file, gnulib-tool.sh sorts them in
ASCII order, i.e. case-sensitively. (gnulib.tool.sh lines 5507 and 5513.)
gnulib-tool.py needs to be consistent with that.
2024-04-20 Bruno Haible <bruno@clisp.org>
gnulib-tool.py: Sort file lists case-sensitively.
* pygnulib/GLImport.py (GLImport.prepare, GLImport.execute): Omit
.lower() call in sort key computation.
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index b38808a353..e65e3e1235 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -943,11 +943,14 @@ def prepare(self) -> tuple[dict[str, list[str]], dict[str, str]]:
# Prepare basic filelist and basic old_files/new_files variables.
filelist = sorted(set(filelist))
+ # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
new_files = filelist + ['m4/gnulib-tool.m4']
old_files = list(self.cache['files'])
path = joinpath(destdir, m4base, 'gnulib-tool.m4')
if isfile(path):
old_files.append(joinpath('m4', 'gnulib-tool.m4'))
+ # old_files is the list of files according to the last gnulib-tool invocation.
+ # new_files is the list of files after this gnulib-tool invocation.
# Construct tables and transformers.
transformers = dict()
@@ -965,14 +968,18 @@ def prepare(self) -> tuple[dict[str, list[str]], dict[str, str]]:
new_table.append(tuple([dest, src]))
old_table = sorted(set(old_table))
new_table = sorted(set(new_table))
+ # old_table is a table with two columns: (rewritten-file-name original-file-name),
+ # representing the files according to the last gnulib-tool invocation.
+ # new_table is a table with two columns: (rewritten-file-name original-file-name),
+ # representing the files after this gnulib-tool invocation.
# Prepare the filetable.
filetable = dict()
filetable['all'] = sorted(set(filelist))
filetable['old'] = \
- sorted(set(old_table), key=lambda t: tuple(t[0].lower()))
+ sorted(set(old_table), key=lambda pair: pair[0])
filetable['new'] = \
- sorted(set(new_table), key=lambda t: tuple(t[0].lower()))
+ sorted(set(new_table), key=lambda pair: pair[0])
filetable['added'] = []
filetable['removed'] = []
@@ -1046,7 +1053,7 @@ def execute(self, filetable: dict[str, list[str]], transformers: dict[str, str])
pairs = [ f
for f in filetable['old']
if f not in filetable['new'] ]
- pairs = sorted(set(pairs), key=lambda t: tuple(t[0].lower()))
+ pairs = sorted(set(pairs), key=lambda pair: pair[0])
files = sorted(set(pair[0] for pair in pairs))
for file in files:
path = joinpath(destdir, file)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-20 21:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-20 21:05 gnulib-tool.py: Sort file lists case-sensitively Bruno Haible
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).