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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.5/] [tools/] [bin/] [svn_set_ignore] - Blame information for rev 17

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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