SVN-Look-0.39/0000755000423100042310000000000012231063752013130 5ustar gustavognustavoSVN-Look-0.39/README0000644000423100042310000000117112231063752014010 0ustar gustavognustavoSVN::Look - A caching wrapper around the svnlook command. The svnlook command is the workhorse of Subversion hook scripts, being used to gather all sorts of information about a repository, its revisions, and its transactions. This module provides a simple object oriented interface to a specific svnlook invocation, to make it easier to hook writers to get and use the information they need. Copyright (c) 2012 by CPqD (http://www.cpqd.com.br/) This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Home page: http://search.cpan.org/dist/SVN-Look/ SVN-Look-0.39/Makefile.PL0000644000423100042310000000450012231063752015101 0ustar gustavognustavo# This file was generated by http://search.cpan.org/dist/Dist-Zilla-Plugins-CJM/lib/Dist/Zilla/Plugin/MakeMaker/Custom.pm use strict; use warnings; # Check if we have a suitable version of the svnlook command. eval { my $path = $ENV{PATH} || ''; open my $svnlook, '-|', 'svnlook --version' or die "Aborting because I couldn't find the 'svnlook' executable in PATH='$path'.\n"; $_ = <$svnlook>; if (my ($major, $minor, $patch) = (/(\d+)\.(\d+)\.(\d+)/)) { $major > 1 || $major == 1 && $minor >= 4 or die "I need at least version 1.4.0 of svnlook but you have only $major.$minor.$patch.\n"; } else { die "Can't grok Subversion version from svnlook --version command.\n"; } local $/ = undef; # slurp mode <$svnlook>; close $svnlook or die "Can't close svnlook commnand.\n"; }; if ($@) { warn $@; # CPAN Testers says # (http://wiki.cpantesters.org/wiki/CPANAuthorNotes) that we # should simply exit normally before generating the Makefile if # there is an unmet dependency. exit 0; } use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( 'ABSTRACT' => 'A caching wrapper around the svnlook command.', 'AUTHOR' => 'Gustavo L. de M. Chaves ', 'CONFIGURE_REQUIRES' => { 'ExtUtils::MakeMaker' => '6.30' }, 'DISTNAME' => 'SVN-Look', 'LICENSE' => 'perl', 'MIN_PERL_VERSION' => '5.008_000', 'NAME' => 'SVN::Look', 'PREREQ_PM' => { 'Carp' => '0', 'File::Spec::Functions' => '0', 'List::MoreUtils' => '0', 'XML::Simple' => '0', 'strict' => '0', 'warnings' => '0' }, 'TEST_REQUIRES' => { 'Cwd' => '0', 'File::Copy' => '0', 'File::Path' => '0', 'File::Temp' => '0', 'Test::More' => '0', 'URI::file' => '0', 'lib' => '0' }, 'VERSION' => '0.39', 'test' => { 'TESTS' => 't/*.t' }, ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); SVN-Look-0.39/LICENSE0000644000423100042310000004362312231063752014145 0ustar gustavognustavoThis software is copyright (c) 2013 by CPqD. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2013 by CPqD. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2013 by CPqD. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End SVN-Look-0.39/lib/0000755000423100042310000000000012231063752013676 5ustar gustavognustavoSVN-Look-0.39/lib/SVN/0000755000423100042310000000000012231063752014344 5ustar gustavognustavoSVN-Look-0.39/lib/SVN/Look.pm0000644000423100042310000003242312231063752015612 0ustar gustavognustavouse 5.008_000; use strict; use warnings; package SVN::Look; { $SVN::Look::VERSION = '0.39'; } # ABSTRACT: A caching wrapper around the svnlook command. use Carp; use File::Spec::Functions; use List::MoreUtils qw{uniq}; my @SVN_VERSION; BEGIN { my $path = $ENV{PATH} || ''; open my $svnlook, 'svnlook --version |' ## no critic (InputOutput::ProhibitTwoArgOpen) or die "Aborting because I couldn't find the 'svnlook' executable in PATH='$path'.\n"; $_ = <$svnlook>; if (@SVN_VERSION = (/(\d+)\.(\d+)\.(\d+)/)) { $SVN_VERSION[0] > 1 || $SVN_VERSION[0] == 1 && $SVN_VERSION[1] >= 4 or die "I need at least version 1.4.0 of svnlook but you have only ", join('.', @SVN_VERSION), " in PATH='$path'.\n"; } else { die "Can't grok Subversion version from svnlook --version command.\n"; } local $/ = undef; # slurp mode <$svnlook>; close $svnlook or die "Can't close svnlook command.\n"; } sub new { my ($class, $repo, @opts) = @_; my $self = { repo => $repo, opts => [@opts], }; bless $self, $class; return $self; } sub _svnlook { my ($self, $cmd, @args) = @_; my @cmd = ('svnlook', $cmd, $self->{repo}); push @cmd, @{$self->{opts}} unless $cmd =~ /^(?:youngest|uuid|lock)$/; my $args = @args ? '"' . join('" "', @args) . '"' : ''; open my $fd, join(' ', @cmd, $args, '|') ## no critic (InputOutput::ProhibitTwoArgOpen) or die "Can't exec svnlook $cmd: $!\n"; if (wantarray) { my @lines = <$fd>; unless (close $fd) { if ($!) { die "Error closing (wantarray) svnlook $cmd pipe: $!\n"; } else { die "Exit status $? from (wantarray) svnlook $cmd\n"; } } chomp @lines; return @lines; } else { local $/ = undef; my $line = <$fd>; unless (close $fd) { if ($!) { die "Error closing svnlook $cmd pipe: $!\n"; } else { die "Exit status $? from svnlook $cmd\n"; } } chomp $line unless $cmd eq 'cat'; return $line; } } sub repo { my $self = shift; return $self->{repo}; } sub txn { my $self = shift; return $self->{opts}[0] eq '-t' ? $self->{opts}[1] : undef; } sub rev { my $self = shift; return $self->{opts}[0] eq '-r' ? $self->{opts}[1] : undef; } sub author { my $self = shift; unless (exists $self->{author}) { chomp($self->{author} = $self->_svnlook('author')); } return $self->{author}; } sub cat { my ($self, $path) = @_; return $self->_svnlook('cat', $path); } sub changed_hash { my $self = shift; unless ($self->{changed_hash}) { my (@added, @deleted, @updated, @prop_modified, %copied); foreach ($self->_svnlook('changed', '--copy-info')) { next if length($_) <= 4; chomp; my ($action, $prop, undef, undef, $changed) = unpack 'AAAA A*', $_; if ($action eq 'A') { push @added, $changed; } elsif ($action eq 'D') { push @deleted, $changed; } elsif ($action eq 'U') { push @updated, $changed; } else { if ($changed =~ /^\(from (.*?):r(\d+)\)$/) { $copied{$added[-1]} = [$1 => $2]; } } if ($prop eq 'U') { push @prop_modified, $changed; } } $self->{changed_hash} = { added => \@added, deleted => \@deleted, updated => \@updated, prop_modified => \@prop_modified, copied => \%copied, }; } return $self->{changed_hash}; } sub added { my $self = shift; return @{$self->changed_hash()->{added}}; } sub updated { my $self = shift; return @{$self->changed_hash()->{updated}}; } sub deleted { my $self = shift; return @{$self->changed_hash()->{deleted}}; } sub prop_modified { my $self = shift; return @{$self->changed_hash()->{prop_modified}}; } sub changed { my $self = shift; my $hash = $self->changed_hash(); unless (exists $hash->{changed}) { $hash->{changed} = [sort(uniq(@{$hash->{added}}, @{$hash->{updated}}, @{$hash->{deleted}}, @{$hash->{prop_modified}}))]; } return @{$hash->{changed}}; } sub copied_to { my $self = shift; return keys %{$self->changed_hash()->{copied}}; } sub copied_from { my $self = shift; return map {$_->[0]} values %{$self->changed_hash()->{copied}}; } sub date { my $self = shift; unless (exists $self->{date}) { $self->{date} = $self->_svnlook('date'); } return $self->{date}; } sub diff { my ($self, @opts) = @_; return $self->_svnlook('diff', @opts); } sub dirs_changed { my $self = shift; unless (exists $self->{dirs_changed}) { my @dirs = $self->_svnlook('dirs-changed'); $self->{dirs_changed} = \@dirs; } return @{$self->{dirs_changed}}; } sub filesize { my ($self, $path) = @_; return $self->_svnlook('filesize', $path); } sub info { my $self = shift; return $self->_svnlook('info'); } sub lock { my ($self, $path) = @_; my %lock = (); my @lock = $self->_svnlook('lock', $path); while (my $line = shift @lock) { chomp $line; my ($key, $value) = split /:\s*/, $line, 2; if ($key =~ /^Comment/) { $lock{Comment} = join('', @lock); last; } else { $lock{$key} = $value; } } return %lock ? \%lock : undef; } sub log_msg { my $self = shift; unless (exists $self->{log}) { $self->{log} = $self->_svnlook('log'); } return $self->{log}; } sub propget { my ($self, @args) = @_; return $self->_svnlook('propget', @args); } # The 'svnlook proplist' command had its output format changed in svn # 1.8.0. So, in order to make the code more stable we try to use the # --xml option. However, this option was implemented on svn 1.6.0 # only. Since we still want to support older Subversions we have to # check if we can use that option first. See discussion on # https://github.com/gnustavo/SVN-Look/pull/1. my $proplist_does_support_xml_option; sub proplist { my ($self, $path) = @_; unless ($self->{proplist}{$path}) { $proplist_does_support_xml_option = $SVN_VERSION[0] > 1 || $SVN_VERSION[0] == 1 && $SVN_VERSION[1] >= 8 unless defined $proplist_does_support_xml_option; if ($proplist_does_support_xml_option) { my $xml = $self->_svnlook(qw/proplist --verbose --xml/, $path); require XML::Simple; my $dom = XML::Simple::XMLin($xml, ForceArray => ['property']); while (my ($prop, $value) = each %{$dom->{target}{property}}) { $self->{proplist}{$path}{$prop} = $value->{content}; } } else { # Old syntax up to SVN 1.7. my $text = $self->_svnlook('proplist', '--verbose', $path); my @list = split /^\s\s(\S+)\s:\s/m, $text; shift @list; # skip the leading empty field chomp(my %hash = @list); $self->{proplist}{$path} = \%hash; } } return $self->{proplist}{$path}; } sub tree { my ($self, @args) = @_; return $self->_svnlook('tree', @args); } sub uuid { my ($self) = @_; return $self->_svnlook('uuid'); } sub youngest { my ($self) = @_; return $self->_svnlook('youngest'); } 1; # End of SVN::Look __END__ =pod =head1 NAME SVN::Look - A caching wrapper around the svnlook command. =head1 VERSION version 0.39 =head1 SYNOPSIS use SVN::Look; my $revlook = SVN::Look->new('/repo/path', -r => 123); my $author = $revlook->author(); my $msg = $revlook->log_msg(); my @added_files = $revlook->added(); my @updated_files = $revlook->updated(); my @deleted_files = $revlook->deleted(); my @changed_files = $revlook->changed(); my $file_contents = $revlook->cat('/path/to/file/in/repository'); my $trxlook = SVN::Look->new('/repo/path', -t => 123); =head1 DESCRIPTION The svnlook command is the workhorse of Subversion hook scripts, being used to gather all sorts of information about a repository, its revisions, and its transactions. This module provides a simple object oriented interface to a specific svnlook invocation, to make it easier to hook writers to get and use the information they need. Moreover, all the information gathered by calling the svnlook command is cached in the object, avoiding repetitious calls. =head1 METHODS =head2 B REPO [, WHAT, NUMBER] The SVN::Look constructor needs one or three arguments: =over =item REPO is the path to the repository. =item WHAT must be either '-r' or '-t', specifying if the third argument is a revision number or a transaction number, respectively. If neither -r or -t is specified, the HEAD revision is used. =item NUMBER is either a revision or transaction NUMBER, as specified by WHAT. =back =head2 B Returns the repository path that was passed to the constructor. =head2 B Returns the transaction number that was passed to the constructor. If none was passed, returns undef. =head2 B Returns the revision number that was passed to the constructor. If none was passed, returns undef. =head2 B Returns the author of the revision/transaction. =head2 B PATH Returns the contents of the file at PATH. In scalar context, return the whole contents in a single string. In list context returns a list of chomped lines. =head2 B Returns a reference to a hash containing information about all file changes occurred in the revision. The hash always has the following keys: =over =item added A list of files added in the revision. =item deleted A list of files deleted in the revision. =item updated A list of files updated in the revision. =item prop_modified A list of files that had properties modified in the revision. =item copied A hash containing information about each file or diretory copied in the revision. The hash keys are the names of elements copied to. The value associated with a key is a two-element array containing the name of the element copied from and the specific revision from which it was copied. =back =head2 B Returns the list of files added in the revision/transaction. =head2 B Returns the list of files updated in the revision/transaction. =head2 B Returns the list of files deleted in the revision/transaction. =head2 B Returns the list of files that had properties modified in the revision/transaction. =head2 B Returns the list of all files added, updated, deleted, and the ones that had properties modified in the revision/transaction. =head2 B Returns the list of new names of files that were copied in the revision/transaction. =head2 B Returns the list of original names of files that were copied in the revision/transaction. The order of this list is guaranteed to agree with the order generated by the method copied_to. =head2 B Returns the date of the revision/transaction. =head2 B [OPTS, ...] Returns the GNU-style diffs of changed files and properties. There are three optional options that can be passed as strings: =over =item C<--no-diff-deleted> Do not print differences for deleted files =item C<--no-diff-added> Do not print differences for added files. =item C<--diff-copy-from> Print differences against the copy source. =back In scalar context, return the whole diff in a single string. In list context returns a list of chomped lines. =head2 B Returns the list of directories changed in the revision/transaction. =head2 B PATH Returns the size (in bytes) of the file located at PATH as it is represented in the repository. =head2 B Returns the author, datestamp, log message size, and log message of the revision/transaction. =head2 B PATH If PATH has a lock, returns a hash containing information about the lock, with the following keys: =over =item UUID Token A string with the opaque lock token. =item Owner The name of the user that has the lock. =item Created The time at which the lock was created, in a format like this: '2010-02-16 17:23:08 -0200 (Tue, 16 Feb 2010)'. =item Comment The lock comment. =back If PATH has no lock, returns undef. =head2 B Returns the log message of the revision/transaction. =head2 B PROPNAME PATH Returns the value of PROPNAME in PATH. =head2 B PATH Returns a reference to a hash containing the properties associated with PATH. =head2 B [PATH_IN_REPOS, OPTS, ...] Returns the repository tree as a list of paths, starting at PATH_IN_REPOS (if supplied, at the root of the tree otherwise), optionally showing node revision ids. =over =item C<--full-paths> show full paths instead of indenting them. =item C<--show-ids> Returns the node revision ids for each path. =item C<--non-recursive> Operate on single directory only. =back =head2 B Returns the repository's UUID. =head2 B Returns the repository's youngest revision number. =head1 AUTHOR Gustavo L. de M. Chaves =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by CPqD. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut SVN-Look-0.39/META.yml0000644000423100042310000000146112231063752014403 0ustar gustavognustavo--- abstract: 'A caching wrapper around the svnlook command.' author: - 'Gustavo L. de M. Chaves ' build_requires: Cwd: 0 File::Copy: 0 File::Path: 0 File::Temp: 0 Test::More: 0 URI::file: 0 lib: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.131560' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: SVN-Look requires: Carp: 0 File::Spec::Functions: 0 List::MoreUtils: 0 XML::Simple: 0 perl: 5.008_000 strict: 0 warnings: 0 resources: bugtracker: https://github.com/gnustavo/SVN-Look/issues homepage: http://search.cpan.org/dist/SVN-Look/ repository: git://github.com/gnustavo/SVN-Look.git version: 0.39 SVN-Look-0.39/MANIFEST0000644000423100042310000000032512231063752014261 0ustar gustavognustavoChanges LICENSE MANIFEST META.yml Makefile.PL README dist.ini lib/SVN/Look.pm t/00-load.t t/01-commands.t t/author-critic.t t/release-kwalitee.t t/release-pod-coverage.t t/release-pod-syntax.t t/test-functions.pl SVN-Look-0.39/Changes0000644000423100042310000000634012231063752014426 0ustar gustavognustavoRevision history for SVN-Look. -*- text -*- 0.39 2013-10-20 21:31:50 America/Sao_Paulo 0.38 2012-06-19 14:00:00 America/Sao_Paulo Method "changed" now returns the entries sorted and with no duplicates. 0.37 2012-06-18 14:34:31 America/Sao_Paulo Revert previous proplist fix. It wasn't really a fix. 0.36 2012-06-18 14:05:44 America/Sao_Paulo Fix proplist, which died when invoked on an artifact with no properties. Now it returns an empty hash. Improve error messages upon svnlook command failure. 0.35 2012-04-21 21:13:18 America/Sao_Paulo Moved from Google Code to GitHub. 0.34 2012-03-05 11:35:50 America/Sao_Paulo Corrects RT#75545 and RT#75546 to make it supported in Windows. (Thanks Mike Brimer!) 0.33 2012-02-27 20:48:45 America/Sao_Paulo Require Perl 5.8.0. 0.32 2012-02-26 18:54:21 America/Sao_Paulo Reinsert check for svn command in Makefile.PL. 0.31 2012-02-25 22:02:07 America/Sao_Paulo 0.30 2011-11-02 Change the call to svnlook to use execvp directly and avoiding the shell. Moved the repository to git (http://code.google.com/p/svn-look/source). 0.29 2011-10-12 Implement method 'filesize', new with Subversion 1.7.0. 0.28 2011-10-10 Reimplementing methods 'repo', 'rev', and 'txn'. They are used by SVN::Hooks::Notify, as I have been kindly reminded by Bill Moseley. Thanks! 0.27 2011-09-17 Make the arguments -r/-t optional. Remove unecessary methods 'repo', 'rev', and 'txn'. Implement methods 'date', 'info', and 'propget'. 0.26 2011-08-27 Requiring at least svnlook version 1.4.0. 0.25 2011-08-21 Method ::cat don't chomp the file contents when called in scalar context anymore. Don't append hardcoded paths to $ENV{PATH} anymore. 0.24 2011-07-30 Tests grok username using svnlook to be sure. 0.23 2011-07-27 Porting Makefile.PL to Windows. Adding URI::file to the dependencies. 0.22 2011-07-21 Avoiding dependency from File::Slurp in the tests. 0.21 2011-07-20 Ported to Windows with Strawberry Perl and also with Active Perl. 0.20 2010-12-12 Fix methods copied_from and copied_to. 0.19 2010-12-12 Implements the method tree. 0.18 2010-04-28 Being more careful during tests. 0.17 2010-02-24 Minor error correction. 0.16 2010-02-16 Implements the methods: youngest, uuid, and lock. Bypasses an issue in the testing of method author. Croaks instead of dying. 0.15 2009-10-24 Drops the sub-minor version. Now it's just M.mm. Implements the kwalitee test. Implements the --author-tests flag to Makefile.PL, which enables the pod and kwalitee tests. 0.13 2008-11-06 Changing the LICENSE from GPL to Perl. 0.12 2008-10-09 Removing dependency from SVN::Hooks from the tests. 0.11 2008-10-04 Using File::Spec to be a little more portable. 0.10 2008-09-27 Implemented the 'diff' method. 0.09 2008-09-27 Removed dependency from Switch.pm. Look for the svnlook command in a bunch of directories. Now the module can be built without the svn commands but the tests will check this and be skipped. Added tests: t/pod.t and t/pod-coverage.t Private functions got the _ prefix to avoid complaints from pod-coverage.t. 0.08 2008-09-25/23:00:00 First version released independently of SVN::Hooks. SVN-Look-0.39/t/0000755000423100042310000000000012231063752013373 5ustar gustavognustavoSVN-Look-0.39/t/release-kwalitee.t0000644000423100042310000000061712231063752017007 0ustar gustavognustavo#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # This test is generated by Dist::Zilla::Plugin::Test::Kwalitee use strict; use warnings; use Test::More; # needed to provide plan. eval "use Test::Kwalitee"; plan skip_all => "Test::Kwalitee required for testing kwalitee" if $@; SVN-Look-0.39/t/00-load.t0000755000423100042310000000033212231063752014715 0ustar gustavognustavouse strict; use warnings; use lib 't'; use Test::More; require "test-functions.pl"; if (can_svn()) { plan tests => 1; } else { plan skip_all => 'Cannot find or use svn commands.'; } require_ok('SVN::Look'); SVN-Look-0.39/t/release-pod-syntax.t0000644000423100042310000000045012231063752017303 0ustar gustavognustavo#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); SVN-Look-0.39/t/release-pod-coverage.t0000644000423100042310000000076512231063752017561 0ustar gustavognustavo#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod::Coverage 1.08"; plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@; eval "use Pod::Coverage::TrustPod"; plan skip_all => "Pod::Coverage::TrustPod required for testing POD coverage" if $@; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); SVN-Look-0.39/t/test-functions.pl0000755000423100042310000000526512231063752016730 0ustar gustavognustavo# Copyright (C) 2008-2011 by CPqD use strict; use warnings; use Cwd; use File::Temp qw/tempdir/; use File::Spec::Functions; use File::Path; use File::Copy; use URI::file; # Make sure the svn messages come in English. $ENV{LC_MESSAGES} = 'C'; sub can_svn { CMD: for my $cmd (qw/svn svnadmin svnlook/) { eval { open my $pipe, '-|', "$cmd --version" or die; local $/ = undef; # slurp mode <$pipe>; close $pipe or die; }; return 0 if $@; } return 1; } our $T; sub newdir { my $num = 1 + Test::Builder->new()->current_test(); my $dir = catdir($T, $num); mkdir $dir; $dir; } sub do_script { my ($dir, $cmd) = @_; my $script = catfile($dir, 'script'); my $stdout = catfile($dir, 'stdout'); my $stderr = catfile($dir, 'stderr'); { open my $fd, '>', $script or die; print $fd $cmd; close $fd; chmod 0755, $script; } copy(catfile($T, 'repo', 'hooks', 'svn-hooks.pl') => catfile($dir, 'svn-hooks.pl')); copy(catfile($T, 'repo', 'conf', 'svn-hooks.conf') => catfile($dir, 'svn-hooks.conf')); system("$script 1>$stdout 2>$stderr"); } sub read_file { my ($file) = @_; open my $fd, '<', $file or die "Can't open '$file': $!\n"; local $/ = undef; # slurp mode return <$fd>; } sub work_ok { my ($tag, $cmd) = @_; my $dir = newdir(); ok((do_script($dir, $cmd) == 0), $tag) or diag("work_ok command failed with following stderr:\n", scalar(read_file(catfile($dir, 'stderr')))); } sub work_nok { my ($tag, $error_expect, $cmd) = @_; my $dir = newdir(); my $exit = do_script($dir, $cmd); if ($exit == 0) { fail($tag); diag("work_nok command worked but it shouldn't!\n"); return; } my $stderr = scalar(read_file(catfile($dir, 'stderr'))); if (! ref $error_expect) { ok(index($stderr, $error_expect) >= 0, $tag) or diag("work_nok:\n '$stderr'\n does not contain\n '$error_expect'\n"); } elsif (ref $error_expect eq 'Regexp') { like($stderr, $error_expect, $tag); } else { fail($tag); diag("work_nok: invalid second argument to test.\n"); } } sub get_author { my ($t) = @_; my $repo = catfile($t, 'repo'); open my $cmd, '-|', "svnlook info $repo" or die "Can't exec svn info\n"; chomp(my $author = <$cmd>); local $/ = undef; <$cmd>; close $cmd; return $author; } sub reset_repo { my $cleanup = exists $ENV{REPO_CLEANUP} ? $ENV{REPO_CLEANUP} : 1; $T = tempdir('t.XXXX', DIR => getcwd(), CLEANUP => $cleanup); my $repo = catfile($T, 'repo'); my $wc = catfile($T, 'wc'); system("svnadmin create $repo"); my $repouri = URI::file->new($repo); system("svn co -q $repouri $wc"); return $T; } 1; SVN-Look-0.39/t/author-critic.t0000644000423100042310000000066612231063752016345 0ustar gustavognustavo#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use warnings; use Test::More; use English qw(-no_match_vars); eval "use Test::Perl::Critic"; plan skip_all => 'Test::Perl::Critic required to criticise code' if $@; Test::Perl::Critic->import( -profile => "perlcritic.rc" ) if -e "perlcritic.rc"; all_critic_ok(); SVN-Look-0.39/t/01-commands.t0000755000423100042310000000371712231063752015612 0ustar gustavognustavouse strict; use warnings; use lib 't'; use SVN::Look; use Test::More; require "test-functions.pl"; if (can_svn()) { plan tests => 14; } else { plan skip_all => 'Cannot find or use svn commands.'; } my $t = reset_repo(); my $repo = catfile($t, 'repo'); my $wcfile = catfile($t, 'wc', 'file'); system("echo first >$wcfile"); system("svn add -q --no-auto-props $wcfile"); system("svn ps -q svn:mime-type text/plain $wcfile"); system("svn ci -q -mlog $wcfile"); my $look = SVN::Look->new($repo, -r => 1); ok(defined $look, 'constructor'); # Grok the author name ok(my $author = get_author($t), 'grok author'); cmp_ok($look->author(), 'eq', $author, 'author'); cmp_ok($look->log_msg(), 'eq', "log\n", 'log_msg'); cmp_ok(($look->added())[0], 'eq', 'file', 'added'); system("echo second >>$wcfile"); system("svn ci -q -mlog $wcfile"); $look = SVN::Look->new($repo, -r => 2); cmp_ok($look->diff(), '=~', qr/\+second/, 'diff'); my $ab = catfile($t, 'wc', 'a b.txt'); system("echo space_in_name >\"$ab\""); system("svn add -q --no-auto-props \"$ab\""); system("svn ps -q svn:mime-type text/plain \"$ab\""); system("svn ci -q -mlog \"$ab\""); # Try without specifying a revision or a transaction $look = SVN::Look->new($repo); my $pl = eval { $look->proplist('a b.txt') }; ok(defined $pl, 'can call proplist in a file with spaces in the name'); ok(exists $pl->{'svn:mime-type'}, 'proplist finds the expected property'); is($pl->{'svn:mime-type'}, 'text/plain', 'proplist finds the correct property value'); my $youngest = eval { $look->youngest() }; cmp_ok($youngest, '=~', qr/^\d+$/, 'youngest'); my $uuid = eval { $look->uuid() }; cmp_ok($uuid, '=~', qr/^[0-9a-f-]+$/, 'uuid'); my $lock = eval { $look->lock('file') }; ok(! defined $lock, 'no lock'); system("svn lock -m \"lock comment\" $wcfile"); $lock = eval { $look->lock('file') }; ok(defined $lock && ref $lock eq 'HASH', 'lock'); my @tree = eval { $look->tree('--full-paths') }; is(scalar(@tree), 3, 'tree'); SVN-Look-0.39/dist.ini0000644000423100042310000000103612231063752014574 0ustar gustavognustavo; See this to understand: http://dzil.org/tutorial/convert-dist.html name = SVN-Look author = Gustavo L. de M. Chaves license = Perl_5 copyright_holder = CPqD [GatherDir] exclude_match = ~$ [@Filter] -bundle = @Basic -remove = GatherDir -remove = Readme -remove = MakeMaker [MakeMaker::Custom] [NextRelease] [@Git] [AutoPrereqs] [Prereqs] XML::Simple = 0 [PodWeaver] [Git::NextVersion] [PkgVersion] [PodSyntaxTests] [PodCoverageTests] [Test::Perl::Critic] [Test::Kwalitee] [GitHub::Update] [GitHub::Meta]