diff --git a/.bzrignore b/.bzrignore index 853b28a6..fcbf594b 100644 --- a/.bzrignore +++ b/.bzrignore @@ -7,3 +7,4 @@ release snapshot .DS_Store build +special/percona-toolkit/v-c-internal diff --git a/lib/Percona/Toolkit.pm b/lib/Percona/Toolkit.pm index cec5f22d..492c2fce 100644 --- a/lib/Percona/Toolkit.pm +++ b/lib/Percona/Toolkit.pm @@ -21,6 +21,8 @@ package Percona::Toolkit; our $VERSION = '2.1.8'; +sub bzr_repo { q{~percona-toolkit-dev} } + 1; } # ########################################################################### diff --git a/lib/VersionCheck.pm b/lib/VersionCheck.pm index 3ccae908..6f735f90 100644 --- a/lib/VersionCheck.pm +++ b/lib/VersionCheck.pm @@ -42,6 +42,10 @@ use Sys::Hostname qw(hostname); use File::Basename qw(); use File::Spec; +use IPC::Cmd qw(can_run); +use FindBin qw(); +use Cwd qw(); + eval { require Percona::Toolkit; require HTTPMicro; @@ -106,6 +110,36 @@ sub version_check { return; } + if ( !$ENV{PERCONA_FORCE_VERSION_CHECK} ) { + # Check if we're running from a bzr repo, and that repo is ours. + if ( my $bzr = can_run('bzr') ) { + my $percona_repo = Percona::Toolkit::bzr_repo(); + my $info = `$bzr info 2>/dev/null`; + if ( $info && $info =~ /\Q$percona_repo/ ) { + PTDEBUG && _d('--version-check disabled by running from a bzr checkout'); + return; + } + } + + # Perhaps bzr isn't available, but we're still running from + # a bzr repo. Brian occasionally does this when running in + # his VMs, since it's usually easier than installing bzr. + # So check if $Cwd/.bzrignore or $FindBin::Bin/../.bzrignore + # exist, and if they do, check if it has this line: + # special/percona-toolkit/v-c-internal + for my $dir ( Cwd::cwd(), File::Spec->updir($FindBin::Bin) ) { + my $ignore = File::Spec->catfile($dir, '.bzrignore'); + next unless -r $ignore; + open my $fh, '<', $ignore or next; + chomp(my $file_contents = do { local $/ = undef; <$fh> }); + close $fh; + if ( $file_contents =~ m{special/percona-toolkit/v-c-internal} ) { + PTDEBUG && _d('--version-check disabled by running from a bzr checkout'); + return; + } + } + } + # Name and ID the instances. The name is for debugging, # and the ID is what the code uses to prevent double-checking. foreach my $instance ( @$instances ) { diff --git a/t/lib/VersionCheck.t b/t/lib/VersionCheck.t index 8cb4f836..caaaf2fd 100644 --- a/t/lib/VersionCheck.t +++ b/t/lib/VersionCheck.t @@ -25,6 +25,8 @@ my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp); my $master_dbh = $sb->get_dbh_for('master'); my $slave1_dbh = $sb->get_dbh_for('slave1'); +local $ENV{PERCONA_FORCE_VERSION_CHECK} = 1; + sub test_v { my (%args) = @_;