NAME
Slaughter::Transport::revisionControl - Transport base-class.
SYNOPSIS
This is a base-class for a generic revision control based transport.
DESCRIPTION
This module implements the primitives which our transport API demands, but it does so in an abstract fashion with the intention that sub-classes will provide the missing configuration to allow it to be used.
This module may be used by any revision-control system, or other tool, that allows a fetch of a remote repository to be carried out by a simple command such as:
$cmd repository-location destination-path
In our derived Mercurical class we set the command to "hg clone
", similarly in the GIT class we use "git clone
". Finally although it isn't a revision control system our rsync implementation works via a subclass precisely because it is possible to fetch a remote tree using a simple command, in that case it is:
rsync -qazr repository-location destination-path
NOTE: A full checkout of the remote repository is always inititated by this module.
It is possible that a future extension to this module will allow an existing repository to be uploaded in-place.
SUBCLASSING
If you wish to write your own transport for a revision control tool, or similar command that will fetch a remote repository, you must subclass this class and implement the _init
method.
The following parameters should be populated in your derived class:
cmd_clone
-
The command to clone the repository. This will have the repository location, as specified by "
--prefix
", and the destination directory appended to it.The command will have with the strings "
#SRC#
" and "#DST#
" replaced with the source of the fetch and the destination into which to fetch it repectively.The following, taken from
Slaughter::Transport::hg
, demonstrates this:$self->{ 'cmd_clone' } = "hg clone #SRC# #DST#";
cmd_update
-
A command to call to update an existing repository. Currently each time slaughter runs it will pull the remote repository from scratch to a brand new temporary directory, it is possible in the future we will work with a local directory that persists - at that point having the ability to both checkout and update a remote repository will be useful.
cmd_version
-
A command to call which will output the version of the revision control system. This may be any command which outputs text, as the output is discarded. The purposes is to ensure that the binary required for cloning is present on the system.
name
-
The name of the transport.
For a sample implementation please consult Slaughter::Transport::hg
.
METHODS
Now follows documentation on the available methods.
new
Create a new instance of this object.
This constructor calls the "_init
" method of any derived class, if present, which is where we'll expect the setup menioned in "SUBCLASSING" to take place.
isAvailable
Is this module available? This uses the details from the derived class to determine whether that transport is available.
We regard the transport as available if the execution of the command stored in "cmd_version" succeeds.
error
Return the last error from the transport, this is set in "isAvailable".
name
Return the name of this transport. This will be setup in the derived class, via the "name" parameter.
fetchContents
Fetch a file from within the checked-out repository.
Given a root repository of /path/to/repo/ the file is looked for beneath /path/to/repo/files.
AUTHOR
Steve Kemp <steve@steve.org.uk>
LICENSE
Copyright (c) 2010-2014 by Steve Kemp. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The LICENSE file contains the full text of the license.