OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.61/] [tools/] [bin/] [svn_set_ignore] - Diff between revs 22 and 26

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 22 Rev 26
#!/usr/bin/perl -w
#!/usr/bin/perl -w
# $Id: svn_set_ignore 547 2013-12-29 13:10:07Z mueller $
# $Id: svn_set_ignore 547 2013-12-29 13:10:07Z mueller $
#
#
# Copyright 2007-2010 by Walter F.J. Mueller 
# Copyright 2007-2010 by Walter F.J. Mueller 
#
#
# This program is free software; you may redistribute and/or modify it under
# This program is free software; you may redistribute and/or modify it under
# the terms of the GNU General Public License as published by the Free
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 2, or at your option any later version.
# Software Foundation, either version 2, or at your option any later version.
#
#
# This program is distributed in the hope that it will be useful, but
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
# WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for complete details.
# for complete details.
#
#
#  Revision History:
#  Revision History:
# Date         Rev  Vers    Comment
# Date         Rev  Vers    Comment
# 2010-04-26   284   1.0.1  add error check for GetOptions
# 2010-04-26   284   1.0.1  add error check for GetOptions
# 2007-06-16    56   1.0    Initial version
# 2007-06-16    56   1.0    Initial version
#
#
use 5.005;                                  # require Perl 5.005 or higher
use 5.005;                                  # require Perl 5.005 or higher
use strict;                                 # require strict checking
use strict;                                 # require strict checking
use Getopt::Long;
use Getopt::Long;
sub do_dir;
sub do_dir;
my @dirlist;
my @dirlist;
my @def_ipat;
my @def_ipat;
my %opts = ();
my %opts = ();
GetOptions(\%opts, "dry-run")
GetOptions(\%opts, "dry-run")
  or die "bad options";
  or die "bad options";
if (@ARGV) {
if (@ARGV) {
  push @dirlist, @ARGV;
  push @dirlist, @ARGV;
} else {
} else {
  @dirlist = `find -type d | grep -v "\.svn"`;
  @dirlist = `find -type d | grep -v "\.svn"`;
  die "bad find|grep" if $?;
  die "bad find|grep" if $?;
}
}
open (CVSIG, ".cvsignore") or die "no top level .cvsigore found";
open (CVSIG, ".cvsignore") or die "no top level .cvsigore found";
@def_ipat = grep /.+/, ;
@def_ipat = grep /.+/, ;
close (CVSIG);
close (CVSIG);
foreach (@dirlist) { chomp; do_dir($_); }
foreach (@dirlist) { chomp; do_dir($_); }
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
sub do_dir {
sub do_dir {
  my ($dirname) = @_;
  my ($dirname) = @_;
  my @cur_ipat;
  my @cur_ipat;
  my @loc_ipat;
  my @loc_ipat;
  my @sum_ipat;
  my @sum_ipat;
  my @new_ipat;
  my @new_ipat;
  my %ipat;
  my %ipat;
  return unless -d "$dirname/.svn";
  return unless -d "$dirname/.svn";
  print "$dirname\n";
  print "$dirname\n";
  open (SVN, "svn pg svn:ignore $dirname|") or die "failed to open svn pg pipe";
  open (SVN, "svn pg svn:ignore $dirname|") or die "failed to open svn pg pipe";
  @cur_ipat = grep /.+/, ;      # prop get and drop empty lines
  @cur_ipat = grep /.+/, ;      # prop get and drop empty lines
  close (SVN);
  close (SVN);
  if ($dirname ne "." && -r "$dirname/.cvsignore") {
  if ($dirname ne "." && -r "$dirname/.cvsignore") {
    open (CVSIG, "$dirname/.cvsignore")
    open (CVSIG, "$dirname/.cvsignore")
      or die "failed to read local .cvsignore";
      or die "failed to read local .cvsignore";
    @loc_ipat = grep /.+/, ;
    @loc_ipat = grep /.+/, ;
    close (CVSIG);
    close (CVSIG);
  }
  }
  push @sum_ipat, @def_ipat;
  push @sum_ipat, @def_ipat;
  push @sum_ipat, @loc_ipat;
  push @sum_ipat, @loc_ipat;
  foreach (@sum_ipat) {
  foreach (@sum_ipat) {
    if (exists $ipat{$_}) {
    if (exists $ipat{$_}) {
      my $pat = $_;
      my $pat = $_;
      chomp $pat;
      chomp $pat;
      print "duplicate ignore: $pat in $dirname\n";
      print "duplicate ignore: $pat in $dirname\n";
    } else {
    } else {
      $ipat{$_} = 1;
      $ipat{$_} = 1;
      push @new_ipat, $_;
      push @new_ipat, $_;
    }
    }
  }
  }
  if (join("",@cur_ipat) ne join("",@new_ipat)) {
  if (join("",@cur_ipat) ne join("",@new_ipat)) {
    print "update svn:ignore for $dirname\n";
    print "update svn:ignore for $dirname\n";
    print "old svn:ignore:\n";
    print "old svn:ignore:\n";
    print "   ", join "   ",@cur_ipat if @cur_ipat;
    print "   ", join "   ",@cur_ipat if @cur_ipat;
    print "local .cvsignore:\n";
    print "local .cvsignore:\n";
    print "   ", join "   ",@loc_ipat if @loc_ipat;
    print "   ", join "   ",@loc_ipat if @loc_ipat;
    print "new svn:ignore:\n";
    print "new svn:ignore:\n";
    print "   ", join "   ",@new_ipat if @new_ipat;
    print "   ", join "   ",@new_ipat if @new_ipat;
    if (not exists $opts{"dry-run"}) {
    if (not exists $opts{"dry-run"}) {
      open (TMP, ">/tmp/svn_set_ignore_$$") or die "failed to open tmp file";
      open (TMP, ">/tmp/svn_set_ignore_$$") or die "failed to open tmp file";
      print TMP join "",@new_ipat;
      print TMP join "",@new_ipat;
      close (TMP);
      close (TMP);
      print `svn ps svn:ignore -F /tmp/svn_set_ignore_$$ $dirname`;
      print `svn ps svn:ignore -F /tmp/svn_set_ignore_$$ $dirname`;
      die "bad svn ps" if $?;
      die "bad svn ps" if $?;
      unlink "/tmp/svn_set_ignore_$$" or die "failed to delete tmp file";
      unlink "/tmp/svn_set_ignore_$$" or die "failed to delete tmp file";
    }
    }
  }
  }
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.