From b163f88f90453f20564960265a3cb5236c33ba85 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Fri, 22 Mar 2024 19:43:41 -0700 Subject: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 69. Follow gnulib-tool change 2012-08-19 Bruno Haible gnulib-tool: Remove old file names from .cvsignore, .gitignore. * pygnulib/GLImport.py (GLImport._update_ignorelist_): Add gnulib-comp.m4 to the added file list. (GLImport.execute): Remove unused variables. Use sets to match the 'join' invocations in gnulib-tool.sh. --- ChangeLog | 11 +++++++++++ gnulib-tool.py.TODO | 11 ----------- pygnulib/GLImport.py | 25 +++++++++---------------- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8f4063444..a4bc9eda0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2024-03-22 Collin Funk + + gnulib-tool.py: Follow gnulib-tool changes, part 69. + Follow gnulib-tool change + 2012-08-19 Bruno Haible + gnulib-tool: Remove old file names from .cvsignore, .gitignore. + * pygnulib/GLImport.py (GLImport._update_ignorelist_): Add + gnulib-comp.m4 to the added file list. + (GLImport.execute): Remove unused variables. Use sets to match the + 'join' invocations in gnulib-tool.sh. + 2024-03-22 Collin Funk gnulib-tool.py: Don't remove newlines in testdir's Automake snippets. diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO index b3d83eeeb4..83d13eb1cb 100644 --- a/gnulib-tool.py.TODO +++ b/gnulib-tool.py.TODO @@ -65,15 +65,4 @@ Date: Sat May 20 13:24:37 2017 +0200 -------------------------------------------------------------------------------- -commit 9bdf6c8a0cdeb13c12e4b65dee9538c5468dbe1d -Author: Bruno Haible -Date: Sun Aug 19 14:06:50 2012 +0200 - - gnulib-tool: Remove old file names from .cvsignore, .gitignore. - - * gnulib-tool (func_update_ignorelist): Don't use 'join -v 1' command - on the list of removed files. - --------------------------------------------------------------------------------- - ================================================================================ diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 66b63ef08e..ca266242e2 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -790,7 +790,6 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix '''GLImport._update_ignorelist_(directory, ignore, dirs_added, dirs_removed) Update .gitignore or .cvsignore files.''' - result = '' destdir = self.config['destdir'] if ignore == '.gitignore': anchor = '/' @@ -802,26 +801,18 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix if dirs_added or dirs_removed: with codecs.open(joinpath(destdir, srcpath), 'rb', 'UTF-8') as file: srcdata = file.read() - dirs_ignore = sorted(set(srcdata.split('\n'))) - dirs_ignore = [ line - for line in dirs_ignore - if line.strip() ] - srcdata = lines_to_multiline(sorted(set(dirs_ignore))) - dirs_ignore += [ d - for d in dirs_added - if d not in dirs_ignore ] - dirs_ignore = [ d - for d in dirs_ignore - if d in dirs_removed ] + dirs_ignore = { filename + if not filename.startswith(anchor) else filename[len(anchor):] + for filename in srcdata.split('\n') + if filename.strip() } + srcdata = lines_to_multiline(sorted(dirs_ignore)) dirs_ignore = [ '%s%s' % (anchor, d) - for d in dirs_ignore ] - dirs_ignore = sorted(set(dirs_ignore)) - destdata = lines_to_multiline(sorted(set(dirs_ignore))) + for d in set(dirs_added).difference(dirs_ignore) ] + destdata = lines_to_multiline(sorted(dirs_ignore)) if srcdata != destdata: if not self.config['dryrun']: print('Updating %s (backup in %s)' % (srcpath, backupname)) copyfile2(joinpath(destdir, srcpath), joinpath(destdir, backupname)) - result = '' with codecs.open(joinpath(destdir, srcpath), 'ab', 'UTF-8') as file: file.write(destdata) else: # if self.config['dryrun'] @@ -1396,6 +1387,8 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix if vc_files != False: # Update the .cvsignore and .gitignore files. ignorelist = list() + # Treat gnulib-comp.m4 like an added file, even if it already existed. + filetable['added'] += [joinpath(m4base, 'gnulib-comp.m4')] filetable['added'] = sorted(set(filetable['added'])) filetable['removed'] = sorted(set(filetable['added'])) for file in filetable['added']: -- 2.44.0