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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [tools/] [bin/] [svn_set_ignore] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wfjm
#!/usr/bin/perl -w
2 27 wfjm
# $Id: svn_set_ignore 601 2014-11-07 22:44:43Z mueller $
3 2 wfjm
#
4 27 wfjm
# Copyright 2007-2014 by Walter F.J. Mueller 
5 2 wfjm
#
6
# This program is free software; you may redistribute and/or modify it under
7
# the terms of the GNU General Public License as published by the Free
8
# Software Foundation, either version 2, or at your option any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
12
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13
# for complete details.
14
#
15
#  Revision History:
16 22 wfjm
# Date         Rev  Vers    Comment
17 27 wfjm
# 2014-11-04   601   1.1    use 'svn info' rather /.svn check for svn >= 1.7
18 2 wfjm
# 2010-04-26   284   1.0.1  add error check for GetOptions
19
# 2007-06-16    56   1.0    Initial version
20
#
21
 
22
use 5.005;                                  # require Perl 5.005 or higher
23
use strict;                                 # require strict checking
24
 
25
use Getopt::Long;
26
 
27
sub do_dir;
28
 
29
my @dirlist;
30
my @def_ipat;
31
 
32
my %opts = ();
33
 
34
GetOptions(\%opts, "dry-run")
35
  or die "bad options";
36
 
37
if (@ARGV) {
38
  push @dirlist, @ARGV;
39
} else {
40
  @dirlist = `find -type d | grep -v "\.svn"`;
41
  die "bad find|grep" if $?;
42
}
43
 
44
open (CVSIG, ".cvsignore") or die "no top level .cvsigore found";
45
@def_ipat = grep /.+/, ;
46
close (CVSIG);
47
 
48
foreach (@dirlist) { chomp; do_dir($_); }
49
 
50
#-------------------------------------------------------------------------------
51
 
52
sub do_dir {
53
  my ($dirname) = @_;
54
  my @cur_ipat;
55
  my @loc_ipat;
56
  my @sum_ipat;
57
  my @new_ipat;
58
  my %ipat;
59
 
60 27 wfjm
  # skip ise directories (they have sometimes strange chars in dir names
61
  return if $dirname =~ m|/ise/|;
62
  # check for svn working directory
63
  my $svn_info = `svn info $dirname 2>&1`;
64
  return if $?;
65
 
66 2 wfjm
  print "$dirname\n";
67
  open (SVN, "svn pg svn:ignore $dirname|") or die "failed to open svn pg pipe";
68
  @cur_ipat = grep /.+/, ;      # prop get and drop empty lines
69
  close (SVN);
70
 
71
  if ($dirname ne "." && -r "$dirname/.cvsignore") {
72
    open (CVSIG, "$dirname/.cvsignore")
73
      or die "failed to read local .cvsignore";
74
    @loc_ipat = grep /.+/, ;
75
    close (CVSIG);
76
  }
77
 
78
  push @sum_ipat, @def_ipat;
79
  push @sum_ipat, @loc_ipat;
80
 
81
  foreach (@sum_ipat) {
82
    if (exists $ipat{$_}) {
83
      my $pat = $_;
84
      chomp $pat;
85
      print "duplicate ignore: $pat in $dirname\n";
86
    } else {
87
      $ipat{$_} = 1;
88
      push @new_ipat, $_;
89
    }
90
  }
91
 
92
  if (join("",@cur_ipat) ne join("",@new_ipat)) {
93
    print "update svn:ignore for $dirname\n";
94
    print "old svn:ignore:\n";
95
    print "   ", join "   ",@cur_ipat if @cur_ipat;
96
    print "local .cvsignore:\n";
97
    print "   ", join "   ",@loc_ipat if @loc_ipat;
98
    print "new svn:ignore:\n";
99
    print "   ", join "   ",@new_ipat if @new_ipat;
100
 
101
    if (not exists $opts{"dry-run"}) {
102
      open (TMP, ">/tmp/svn_set_ignore_$$") or die "failed to open tmp file";
103
      print TMP join "",@new_ipat;
104
      close (TMP);
105
      print `svn ps svn:ignore -F /tmp/svn_set_ignore_$$ $dirname`;
106
      die "bad svn ps" if $?;
107
      unlink "/tmp/svn_set_ignore_$$" or die "failed to delete tmp file";
108
    }
109
 
110
  }
111
 
112
}

powered by: WebSVN 2.1.0

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