NAME
App::SVN::Bisect - binary search through svn revisions
SYNOPSIS
my $bisect = App::SVN::Bisect->new(
Action => $action,
Min => $min,
Max => $max
);
$bisect->do_something_intelligent(@ARGV);
DESCRIPTION
This module implements the backend of the "svn-bisect" command line tool. See the POD documentation of that tool, for usage details.
API METHODS
new
$self = App::SVN::Bisect->new(Action => "bad", Min => 0, Max => undef);
Create an App::SVN::Bisect object. The arguments are typically parsed from the command line.
The Action argument must be listed in the %actions table. The "read_config" attribute of the action determines whether the metadata file (typically named .svn/bisect.yaml) will be read.
do_something_intelligent
$self->do_something_intelligent(@ARGV);
Executes the action specified by the user. See the "Action methods" section, below, for the details.
If the action's "write_config" bit is set in the %actions table, the metadata file will be written after executing the action. If the bit was not set, the metadata file is removed.
ACTION METHODS
start
Begins a bisect session. Sets up the parameters, queries some stuff about the subversion repository, and starts the user off with the first bisect.
before
Sets the "min" parameter to the specified (or current) revision, and then moves the user to the middle of the resulting range.
after
Sets the "max" parameter to the specified (or current) revision, and then moves the user to the middle of the resulting range.
reset
Cleans up after a bisect session. If --back is passed, it also moves the working tree back to the original revision it had when "start" was first called.
skip
Tells svn-bisect to ignore the specified (or current) revision, and then moves the user to another, strategically useful revision.
You may specify as many revisions at once as you like.
unskip
Tells svn-bisect to stop ignoring the specified revision, then moves the user to another, strategically useful revision.
You may specify as many revisions at once as you like.
run
Runs a command repeatedly to automate the bisection process.
We run the command and arguments until a conclusion is reached. The command (usually a shell script) tells us about the current revision by way of its return code. The following return codes are handled:
0: This revision is before the change we're looking for
1-124, 126-127: This revision includes the change we're looking for
125: This revision is untestable and should be skipped
any other value: The command failed to run, abort bisection.
The normal caveats apply. In particular, if your script makes any changes, don't forget to clean up afterwards.
help
Allows the user to get some descriptions and usage information.
This function calls exit() directly, to prevent do_something_intelligent() from removing the metadata file.
view
Allows the user to get some information about the current state of things.
This function calls exit() directly, to prevent do_something_intelligent() from removing the metadata file.
INTERNAL METHODS
cmd
my $stdout = $self->cmd("svn info");
Runs a command, returns its output.
ready
$self->next_rev() if $self->ready();
Returns a true value if we have enough information to begin bisecting. Specifically, this returns true if we have been given at least one "bad" and one "good" revision. These can be specified as arguments to the "before" and "after" commands, or as --min and --max arguments to the "start" command.
next_rev
$self->next_rev();
Find a spot in the middle of the current "suspect revisions" list, and calls "svn update" to move the checkout directory to that revision.
list_revs
my @revs = $self->list_revs();
Returns the set of valid revisions between the current "min" and "max" values, exclusive.
This is smart about revisions that don't affect the current tree (because they won't be returned by fetch_log_revs, below) and about skipped revisions (which the user may specify with the "skip" command).
stdout
$self->stdout("Hello, world!\n");
Output a message to stdout. This is basically just the "print" function, but we use a method so the testsuite can override it through subclassing.
verbose
$self->verbose("Hello, world!\n");
Output a message to stdout, if the user specified the --verbose option. This is basically just a conditional wrapper around the "print" function.
exit
$self->exit(0);
Exits. This allows the test suite to override exiting; it does not provide any other features above and beyond what the normal exit system call provides.
SUBVERSION ACCESSOR METHODS
update_to
$self->update_to(25000);
Calls 'svn update' to move to the specified revision.
fetch_log_revs
my $hashref = $self->fetch_log_revs();
Calls "svn log" and parses the output. Returns a hash reference whose keys are valid revision numbers; so you can use exists() to find out whether a number is in the list. This hash reference is used by list_revs(), above.
find_max
my $rev = $self->find_max();
Plays some tricks with "svn log" to figure out the latest revision contained within the repository.
find_cur
my $rev = $self->find_cur();
Parses the output of "svn info" to figure out what the current revision is.
AUTHOR
Mark Glines <mark-cpan@glines.org>
THANKS
* Thanks to the git-bisect author(s), for coming up with a user interface that I actually like.
* Thanks to Will Coleda for inspiring me to actually write and release this.
* Thanks to the Parrot project for having so much random stuff going on as to make a tool like this necessary.
SEE ALSO
App::SVNBinarySearch by Will Coleda: http://search.cpan.org/dist/App-SVNBinarySearch/
COPYRIGHT AND LICENSE
This software is copyright (c) 2008-2009 Mark Glines.
It is distributed under the terms of the Artistic License 2.0. For details, see the "LICENSE" file packaged alongside this module.