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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [bin/] [svn_set_ignore] - Blame information for rev 24

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wfjm
#!/usr/bin/perl -w
2 22 wfjm
# $Id: svn_set_ignore 547 2013-12-29 13:10:07Z mueller $
3 2 wfjm
#
4
# Copyright 2007-2010 by Walter F.J. Mueller 
5
#
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 2 wfjm
# 2010-04-26   284   1.0.1  add error check for GetOptions
18
# 2007-06-16    56   1.0    Initial version
19
#
20
 
21
use 5.005;                                  # require Perl 5.005 or higher
22
use strict;                                 # require strict checking
23
 
24
use Getopt::Long;
25
 
26
sub do_dir;
27
 
28
my @dirlist;
29
my @def_ipat;
30
 
31
my %opts = ();
32
 
33
GetOptions(\%opts, "dry-run")
34
  or die "bad options";
35
 
36
if (@ARGV) {
37
  push @dirlist, @ARGV;
38
} else {
39
  @dirlist = `find -type d | grep -v "\.svn"`;
40
  die "bad find|grep" if $?;
41
}
42
 
43
open (CVSIG, ".cvsignore") or die "no top level .cvsigore found";
44
@def_ipat = grep /.+/, ;
45
close (CVSIG);
46
 
47
foreach (@dirlist) { chomp; do_dir($_); }
48
 
49
#-------------------------------------------------------------------------------
50
 
51
sub do_dir {
52
  my ($dirname) = @_;
53
  my @cur_ipat;
54
  my @loc_ipat;
55
  my @sum_ipat;
56
  my @new_ipat;
57
  my %ipat;
58
 
59
  return unless -d "$dirname/.svn";
60
  print "$dirname\n";
61
  open (SVN, "svn pg svn:ignore $dirname|") or die "failed to open svn pg pipe";
62
  @cur_ipat = grep /.+/, ;      # prop get and drop empty lines
63
  close (SVN);
64
 
65
  if ($dirname ne "." && -r "$dirname/.cvsignore") {
66
    open (CVSIG, "$dirname/.cvsignore")
67
      or die "failed to read local .cvsignore";
68
    @loc_ipat = grep /.+/, ;
69
    close (CVSIG);
70
  }
71
 
72
  push @sum_ipat, @def_ipat;
73
  push @sum_ipat, @loc_ipat;
74
 
75
  foreach (@sum_ipat) {
76
    if (exists $ipat{$_}) {
77
      my $pat = $_;
78
      chomp $pat;
79
      print "duplicate ignore: $pat in $dirname\n";
80
    } else {
81
      $ipat{$_} = 1;
82
      push @new_ipat, $_;
83
    }
84
  }
85
 
86
  if (join("",@cur_ipat) ne join("",@new_ipat)) {
87
    print "update svn:ignore for $dirname\n";
88
    print "old svn:ignore:\n";
89
    print "   ", join "   ",@cur_ipat if @cur_ipat;
90
    print "local .cvsignore:\n";
91
    print "   ", join "   ",@loc_ipat if @loc_ipat;
92
    print "new svn:ignore:\n";
93
    print "   ", join "   ",@new_ipat if @new_ipat;
94
 
95
    if (not exists $opts{"dry-run"}) {
96
      open (TMP, ">/tmp/svn_set_ignore_$$") or die "failed to open tmp file";
97
      print TMP join "",@new_ipat;
98
      close (TMP);
99
      print `svn ps svn:ignore -F /tmp/svn_set_ignore_$$ $dirname`;
100
      die "bad svn ps" if $?;
101
      unlink "/tmp/svn_set_ignore_$$" or die "failed to delete tmp file";
102
    }
103
 
104
  }
105
 
106
}

powered by: WebSVN 2.1.0

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