package VCI::VCS::Bzr; use Moose; use MooseX::Method; use VCI::Util qw(taint_fail); use VCI::VCS::Bzr::Repository; use IPC::Cmd; use Scalar::Util qw(tainted); extends 'VCI'; our $VERSION = '0.5.2'; # The path to the bzr binary. has 'x_bzr' => (is => 'ro', isa => 'Str', default => sub { shift->_build_x_bzr }); sub BUILD { my $self = shift; taint_fail("The x_bzr argument '$self->{x_bzr}' is tainted") if tainted($self->{x_bzr}); } sub _build_x_bzr { my $cmd = IPC::Cmd::can_run('bzr') || confess('Could not find "bzr" in your path'); taint_fail("We found '$cmd' for bzr, but that string is tainted." . ' This probably means $ENV{PATH} is tainted') if tainted($cmd); return $cmd; } method 'x_do' => named ( args => { isa => 'ArrayRef', required => 1 }, errors_undef => { isa => 'ArrayRef', default => [] }, errors_ignore => { isa => 'ArrayRef', default => [] }, errors_undef_regex => { isa => 'RegexpRef' }, errors_ignore_regex => { isa => 'RegexpRef' }, ) => sub { my ($self, $params) = @_; my $args = $params->{args}; my $full_command = $self->x_bzr . ' ' . join(' ', @$args); if ($self->debug) { print STDERR "Command: $full_command\n"; } # See http://rt.cpan.org/Ticket/Display.html?id=31738 local $IPC::Cmd::USE_IPC_RUN = 1; my ($success, $errorcode, $all, $stdout, $stderr) = IPC::Cmd::run(command => [$self->x_bzr, @$args]); print STDERR "Exit Code: $errorcode\n" if $self->debug; if (!$success) { my $err_string = join('', @$stderr); if (!grep {$_ == $errorcode} @{$params->{errors_ignore}}) { my $re = $params->{errors_undef_regex}; if (grep {$_ == $errorcode} @{$params->{errors_undef}} || (defined $re && $err_string =~ $re)) { return undef; } my $ignore_re = $params->{errors_ignore_regex}; unless (defined $ignore_re && $err_string =~ $ignore_re) { my $error_output = join('', @$stderr); chomp($error_output); confess("$full_command failed: $error_output"); } } } my $output_string = join('', @$stdout); chomp($output_string); if ($self->debug > 1) { print STDERR "Results:\n" . join('', @$all); } return $output_string; }; 1; __END__ =head1 NAME VCI::VCS::Bzr - The Bazaar implementation of VCI =head1 DESCRIPTION This is a "driver" for L for the Bazaar version-control system. You can find out more about Bazaar at L. For information on how to use VCI::VCS::Bzr, see L. =head1 CONNECTING TO A BZR REPOSITORY For the L argument to L, choose the directory above where your branches are kept. For example, if I have a branch C, then the C would be C. Bzr's C also takes one optional extra argument: =over =item C The path to the C binary on your system. If not specified, we will search your C and throw an error if C isn't found. B: VCI will throw an error if this argument is tainted, because VCI just runs this command blindly, and we wouldn't want to run something like C. =back =head1 REQUIREMENTS VCI::VCS::Bzr requires that the following be installed on your system: =over =item bzr C Must be installed and accessible to VCI. If it's not in your path, you should specify an C argument to L, which should contain the full path to the C executable, such as F. =item bzrtools The C extension package must be installed. Usually this is available as a package (RPM or deb) in your distrubution, or you can download it from here: L. =item bzr-xmloutput Because VCI::VCS::Bzr processes the output of bzr, it needs it in a machine-readable format like XML. For bzr, this is accomplished by the C plugin, which is available here: L. You can read about how to install it at L. =back This is in addition to any perl module requirements listed when you install VCI::VCS::Bzr. =head1 LIMITATIONS AND EXTENSIONS These are limitations of VCI::VCS::Bzr compared to the general API specified in the C modules. =head2 VCI::VCS::Bzr::Repository =over =item C On some repositories, L<"projects"|VCI::Abstract::Repository/projects> will return an empty array, even though there are branches there. This only happens for repositories where we can't list the directories. For example, HTTP repositories without a directory listing. However, L will still work on those repositories. =back =head2 VCI::VCS::Bzr::Directory When constructing a Directory, you cannot specify C