[devscripts] 01/01: mk-origtargz: Deduplicate using a hash instead of List::MoreUtils::uniq

James McCoy jamessan at debian.org
Wed Oct 28 01:05:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch multitar
in repository devscripts.

commit ad38b0676c1e7f2efbd153b901c393b797477e90
Author: James McCoy <jamessan at debian.org>
Date:   Tue Oct 27 20:47:02 2015 -0400

    mk-origtargz: Deduplicate using a hash instead of List::MoreUtils::uniq
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 scripts/mk-origtargz.pl | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/scripts/mk-origtargz.pl b/scripts/mk-origtargz.pl
index 3c1db9e..ad1e5b9 100644
--- a/scripts/mk-origtargz.pl
+++ b/scripts/mk-origtargz.pl
@@ -180,7 +180,6 @@ use Devscripts::Compression qw/compression_is_supported compression_guess_from_f
 use Cwd 'abs_path';
 use File::Copy;
 use Dpkg::Control::Hash;
-use List::MoreUtils qw(uniq);
 
 sub decompress_archive($$);
 sub compress_archive($$$);
@@ -441,6 +440,7 @@ if (@exclude_globs) {
     @files = split /^/, $files;
     chomp @files;
 
+    my %delete;
     # find out what to delete
     my @exclude_info = map { { glob => $_, used => 0, regex => glob_to_regex($_) } } @exclude_globs;
     for my $filename (@files) {
@@ -450,7 +450,7 @@ if (@exclude_globs) {
 				(?:$info->{regex}) # User pattern
 				(?:/.*)?$          # Possible trailing / for a directory
 			      @x) {
-		push @to_delete, $filename if !$last_match;
+		$delete{$filename} = 1 if !$last_match;
 		$last_match = $info;
 	    }
 	}
@@ -467,8 +467,7 @@ if (@exclude_globs) {
 
     # ensure files are mentioned before the directory they live in
     # (otherwise tar complains)
-    @to_delete = sort {$b cmp $a}  @to_delete;
-    @to_delete = uniq  @to_delete;
+    @to_delete = sort {$b cmp $a} keys %delete;
 
     $deletecount = scalar(@to_delete);
 }
@@ -491,7 +490,7 @@ if ($do_repack || $deletecount) {
     unlink $upstream_tar if $mode eq "rename";
     # We have to use piping because --delete is broken otherwise, as documented
     # at https://www.gnu.org/software/tar/manual/html_node/delete.html
-    if (@to_delete > 0) {
+    if (@to_delete) {
 	spawn(exec => ['tar', '--delete', @to_delete ],
 	      from_file => $destfiletar,
 	      to_file => $destfiletar . ".tmp",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list