Padre-Plugin-HG
view release on metacpan or search on metacpan
lib/Padre/Plugin/HG.pm view on Meta::CPAN
# $self->pull_update_project($file, $projectdir);
# Only pulls changes from the default repository, which is normally
# the one you cloned from.
sub pull_update_project
{
my ($self, $path, $dir) = @_;
my $main = Padre->ide->wx->main;
return $main->error('File not in a $VCS Project', "Padre $VCS" ) if not $self->_project_root($path);
my $command = eval "qq\0$VCSCommand{pull}\0";
my $result = $self->vcs_execute($command, $dir);
$main->message( $result, "$VCS Cloning $path" );
return;
}
# Pushes updates to a remote repository.
# Prompts for the username and password.
# $self->push_project($file, $projectdir);
# Only pushes changes to the default remote repository, which is normally
# the one you cloned from.
sub push_project
{
my ($self, $path, $dir) = @_;
my $main = Padre->ide->wx->main;
return $main->error('File not in a $VCS Project', "Padre $VCS" ) if not $self->_project_root($path);
my $config_command = 'hg showconfig';
my $result1 = $self->vcs_execute($config_command, $dir); #overwriting path on purpose.
#overwriting path on purpose.
#gets the configured push path if it exists
($path) = $result1 =~ /paths.default=(.*)/;
return $main->error('No default push path', "Padre $VCS" ) if not $path;
my ($default_username) = $path =~ /\/\/(.*)@/;
my $prompt = Padre::Plugin::HG::UserPassPrompt->new(
title=>'Mecurial Push',
default_username=>$default_username,
default_password =>'');
my $username = $prompt->{username};
my $password = $prompt->{password};
$path =~ s/\/(.*)@/\/\/$username:$password@/g;
my $command = eval "qq\0$VCSCommand{push}\0";
my $result = $self->vcs_execute($command, $dir);
$main->message( $result, "$VCS Pushing $path" );
return;
}
# vcs_execute
#
# Executes a command after changing to the appropriate dir.
# $self->vcs_execute($command, $dir);
# All output is captured and returned as a string.
sub vcs_execute
{
my ($self, $command, $dir) = @_;
print "Command $command\n";
my $busyCursor = Wx::BusyCursor->new();
my $result = capture_merged(sub{chdir($dir);system($command)});
if (!$result){$result = "Action Completed"}
$busyCursor = undef;
return $result;
}
# show_statusTree
#
# Displays a Project Browser in the side pane. The Browser shows the status of the
# files in HG and gives menu options to perform actions.
sub show_statusTree
{
my ($self) = @_;
require Padre::Plugin::HG::StatusTree;
my $main = Padre->ide->wx->main;
my $project_root = $self->_project_root(current_filename());
$self->{project_path} = $project_root;
return $main->error("Not a $VCS Project") if !$project_root;
# we only want to add a tree for projects that don't already have one.
if (!exists($projects{$project_root}) )
{
$projects{$project_root} = Padre::Plugin::HG::StatusTree->new($self,$project_root);
}
}
# close_statusTree
#
# Closes the Project Browser and deletes the Status tree object
sub close_statusTree
{
my ($self) = @_;
my $project_root = $self->_project_root(current_filename());
if (exists($projects{$project_root}) )
{
delete $projects{$project_root} ;
print "deleted $project_root\n";
}
}
#
#
#show_commit_list
#
# Displays a list of all the files that are awaiting commiting. It will include
# not added and deleted files adding and removing them as required.
sub show_commit_list
{
my ($self) = @_;
my $main = Padre->ide->wx->main;
$self->{project_path} = $self->_project_root(current_filename());
( run in 2.976 seconds using v1.01-cache-2.11-cpan-0bb4e1dffa6 )