Front page | perl.cvs.parrot |
Postings from January 2009
[svn:parrot] r35588 - in trunk: . lib/Parrot tools/dev
From:
bernhard
Date:
January 15, 2009 05:01
Subject:
[svn:parrot] r35588 - in trunk: . lib/Parrot tools/dev
Message ID:
20090115130014.A0705CB9AE@x12.develooper.com
Author: bernhard
Date: Thu Jan 15 05:00:13 2009
New Revision: 35588
Added:
trunk/tools/dev/mk_gitignore.pl (contents, props changed)
- copied, changed from r35585, /trunk/tools/dev/mk_manifest_and_skip.pl
Modified:
trunk/MANIFEST
trunk/lib/Parrot/Manifest.pm
Log:
[tools] Add script tools/dev/mk_gitignore.pl.
Add support for mk_gitignore.pl to Parrot::Manifest.
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Thu Jan 15 05:00:13 2009
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Thu Jan 15 12:20:30 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Thu Jan 15 12:32:42 2009 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -3678,6 +3678,7 @@
tools/dev/lib_deps.pl [devel]
tools/dev/list_unjitted.pl [devel]
tools/dev/manicheck.pl [devel]
+tools/dev/mk_gitignore.pl [devel]
tools/dev/mk_inno.pl [devel]
tools/dev/mk_language_shell.pl [devel]
tools/dev/mk_manifest_and_skip.pl [devel]
Modified: trunk/lib/Parrot/Manifest.pm
==============================================================================
--- trunk/lib/Parrot/Manifest.pm (original)
+++ trunk/lib/Parrot/Manifest.pm Thu Jan 15 05:00:13 2009
@@ -13,12 +13,13 @@
my $self = bless( {}, $class );
my %data = (
- id => '$' . 'Id$',
- time => scalar gmtime,
- cmd => -d '.svn' ? 'svn' : 'svk',
- script => $argsref->{script},
- file => $argsref->{file} ? $argsref->{file} : q{MANIFEST},
- skip => $argsref->{skip} ? $argsref->{skip} : q{MANIFEST.SKIP},
+ id => '$' . 'Id$',
+ time => scalar gmtime,
+ cmd => -d '.svn' ? 'svn' : 'svk',
+ script => $argsref->{script},
+ file => $argsref->{file} ? $argsref->{file} : q{MANIFEST},
+ skip => $argsref->{skip} ? $argsref->{skip} : q{MANIFEST.SKIP},
+ gitignore => $argsref->{gitignore} ? $argsref->{gitignore} : q{.gitignore},
);
my $status_output_ref = [qx($data{cmd} status -v)];
@@ -213,28 +214,17 @@
sub prepare_manifest_skip {
my $self = shift;
- my $svnignore = `$self->{cmd} propget svn:ignore @{ $self->{dirs} }`;
+ my $ignores_ref = $self->_get_ignores();
- # cope with trailing newlines in svn:ignore output
- $svnignore =~ s/\n{3,}/\n\n/g;
- my %ignore;
- my @ignore = split( /\n\n/, $svnignore );
- foreach (@ignore) {
- my @cnt = m/( - )/g;
- if ($#cnt) {
- my @a = split /\n(?=(?:.*?) - )/, $_;
- foreach (@a) {
- m/^\s*(.*?) - (.+)/sm;
- $ignore{$1} = $2 if $2;
- }
- }
- else {
- m/^(.*) - (.+)/sm;
- $ignore{$1} = $2 if $2;
- }
- }
+ return $self->_compose_manifest_skip($ignores_ref);
+}
+
+sub prepare_gitignore {
+ my $self = shift;
+
+ my $ignores_ref = $self->_get_ignores();
- return $self->_compose_print_str( \%ignore );
+ return $self->_compose_gitignore($ignores_ref);
}
sub determine_need_for_manifest_skip {
@@ -273,7 +263,78 @@
return 1;
}
-sub _compose_print_str {
+sub print_gitignore {
+ my $self = shift;
+ my $print_str = shift;
+
+ open my $GITIGNORE, '>', $self->{gitignore}
+ or die "Unable to open $self->{gitignore} for writing";
+ $print_str .= $text_file_coda;
+ print $GITIGNORE $print_str;
+ close $GITIGNORE
+ or die "Unable to close $self->{gitignore} after writing";
+
+ return 1;
+}
+
+sub _get_ignores {
+ my $self = shift;
+
+ my $svnignore = `$self->{cmd} propget svn:ignore @{ $self->{dirs} }`;
+
+ # cope with trailing newlines in svn:ignore output
+ $svnignore =~ s/\n{3,}/\n\n/g;
+ my %ignores;
+ my @ignore = split( /\n\n/, $svnignore );
+ foreach (@ignore) {
+ my @cnt = m/( - )/g;
+ if ($#cnt) {
+ my @a = split /\n(?=(?:.*?) - )/, $_;
+ foreach (@a) {
+ m/^\s*(.*?) - (.+)/sm;
+ $ignores{$1} = $2 if $2;
+ }
+ }
+ else {
+ m/^(.*) - (.+)/sm;
+ $ignores{$1} = $2 if $2;
+ }
+ }
+
+ return \%ignores;
+}
+
+sub _compose_gitignore {
+ my $self = shift;
+ my $ignores_ref = shift;
+
+ my $print_str = <<"END_HEADER";
+# ex: set ro:
+# $self->{id}
+# generated by $self->{script} $self->{time} UT
+#
+# This file should contain a transcript of the svn:ignore properties
+# of the directories in the Parrot subversion repository.
+# (Needed for convenience whne working with git-svn.
+#
+END_HEADER
+
+ foreach my $directory ( sort keys %{$ignores_ref} ) {
+ my $dir = $directory;
+ $dir =~ s!\\!/!g;
+ $print_str .= "# generated from svn:ignore of '$dir/'\n";
+ foreach ( sort split /\n/, $ignores_ref->{$directory} ) {
+ $print_str .=
+ ( $dir ne '.' )
+ ? "$dir/$_\n"
+ : "$_\n";
+ }
+ }
+
+ return $print_str;
+}
+
+sub _compose_manifest_skip {
my $self = shift;
my $ignore_ref = shift;
@@ -360,13 +421,16 @@
$mani = Parrot::Manifest->new($0);
$manifest_lines_ref = $mani->prepare_manifest();
- $need_for_files = $mani->determine_need_for_manifest($manifest_lines_ref);
+ $need_for_files = $mani->determine_need_for_manifest($manifest_lines_ref);
$mani->print_manifest($manifest_lines_ref) if $need_for_files;
- $print_str = $mani->prepare_manifest_skip();
+ $print_str = $mani->prepare_manifest_skip();
$need_for_skip = $mani->determine_need_for_manifest_skip($print_str);
$mani->print_manifest_skip($print_str) if $need_for_skip;
+ $print_str = $mani->prepare_gitignore();
+ $mani->print_gitignore($print_str) if $need_for_skip;
+
=head1 SEE ALSO
F<tools/dev/mk_manifest_and_skip.pl>.
Copied: trunk/tools/dev/mk_gitignore.pl (from r35585, /trunk/tools/dev/mk_manifest_and_skip.pl)
==============================================================================
--- /trunk/tools/dev/mk_manifest_and_skip.pl (original)
+++ trunk/tools/dev/mk_gitignore.pl Thu Jan 15 05:00:13 2009
@@ -1,6 +1,6 @@
##! perl
# $Id$
-# Copyright (C) 2006-2009, The Perl Foundation.
+# Copyright (C) 2009, The Perl Foundation.
use strict;
use warnings;
@@ -12,15 +12,10 @@
my $mani = Parrot::Manifest->new( { script => $script, } );
-my $manifest_lines_ref = $mani->prepare_manifest();
-my $need_for_files = $mani->determine_need_for_manifest($manifest_lines_ref);
-$mani->print_manifest($manifest_lines_ref) if $need_for_files;
-
-my $print_str = $mani->prepare_manifest_skip();
-my $need_for_skip = $mani->determine_need_for_manifest_skip($print_str);
-$mani->print_manifest_skip($print_str) if $need_for_skip;
+my $print_str = $mani->prepare_gitignore();
+$mani->print_gitignore($print_str);
-#################### DOCUMENTATION ####################
+__END__
=head1 NAME
-
[svn:parrot] r35588 - in trunk: . lib/Parrot tools/dev
by bernhard