Vcs.pm -- a simple abstraction for version control systems.
use Vcs::Svn; my $vcs = Vcs::Svn->new($project, "repo_url", "commit_db_file", \&_co_hook); sub _co_hook { my ($vcs, $revision_id, $work_dir) = @_; # do some post processing }
The provided default implementations may be overriden to provide specific behavior. In most cases it is sufficient to override the following abstract subroutines to provide a vcs-specific command:
_checkout_cmd(revision_id, work_dir)
Returns the command to checkout revision_id
to the working directory work_dir.
_apply_cmd(work_dir, patch_file)
Returns the command to apply the patch in file patch_file to the working directory work_dir.
_diff_cmd(rev1, rev2, path)
Returns the command to compute a diff between two revisions rev1
and rev2
. The optional path path
is relative to the working directory and used to diff between certain files or directories.
_get_parent_revisions()
TODO
This module provides a simple abstraction for version control systems.
A Vcs object has to be instantiated with:
The commit-db (csv) file has the structure: bug_id,revision_buggy,revision_fixed
.
Example for Svn:
1,1024,1025 2,1064,1065
Example for Git:
1,788193a54e0f1aaa428ccfdd3bb45e32c311c18b,c96ae569bbe0167cfa15caa7f784fdb2e1ecdc12 2,ab333482c629d33d5484b4af6eb27918382ccc28,f77c5101df42f501d96d0363084dcc9c17400fce
$vcs->lookup(vid)
Queries the commit database (commit-db) and returns the revision_id
for the given version id vid
. Format of vid
: \d+[bf]
.
$vcs->num_revision_pairs()
Returns the number of revision pairs in the commit-db
.
$project->get_bug_ids()
Returns an array of all bug ids in the commit-db
.
$vcs->B<contains_version_id> C<contains_version_id(vid)
Given a valid version id (vid
), this subroutine returns true if vid
exists in the commit-db
and false otherwise. Format of vid
: \d+[bf]
This subroutine dies if vid
is invalid.
$vcs->checkout_vid(vid, work_dir)
Performs a lookup of vid
in the commit-db
followed by a checkout of the corresponding revision with revision_id
to work_dir. Format of vid
: \d+[bf]
.
Always performs a clean checkout, i.e., the working directory is deleted before the checkout, if it already exists.
$vcs->diff(revision_id_1, revision_id_2 [, path])
Returns the diff between revision_id_1
and revision_id_2
or undef
if the diff failed. The path argument is optional and can be used to compute a diff between certain files or directories. Note that path
is relative to the working directory.
$vcs->export_diff(revision_id_1, revision_id_2, out_file [, path])
Exports the diff between revision_id_1
and revision_id_2
to out_file. The path argument is optional and can be used to compute a diff between certain files or directories. Note that path is relative to the working directory.
$vcs->apply_patch(work_dir, patch_file)
Applies the patch provided in patch_file to the working directory work_dir.