Commits

m...@mm-laptop  committed e7af528

Push is now possible

  • Participants
  • Parent commits f180e03

Comments (0)

Files changed (3)

 use Padre::Plugin::HG::StatusTree;
 use Padre::Plugin::HG::ProjectCommit;
 use Padre::Plugin::HG::ProjectClone;
+use Padre::Plugin::HG::UserPassPrompt;
 my %projects;
 our $VERSION = '0.01';
 our @ISA     = 'Padre::Plugin';
 		diff => 'hg diff $path',
 		clone=> 'hg clone $path',
 		pull =>'hg pull --update --noninteractive  ',
-		push =>'hg push');
+		push =>'hg push $path');
 		
 my %HGStatus = ( M => 'File Modified', 
 A => 'File Added not Committed',
 	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;
+	print "path $path";
 	my $command = eval "qq\0$VCSCommand{push}\0";
 	my $result = $self->vcs_execute($command, $dir);
 	$main->message( $result, "$VCS Pushing $path" );

File HG/StatusTree.pm

 use Wx qw/WXK_UP WXK_DOWN wxTR_HAS_BUTTONS  wxTR_HIDE_ROOT  /;
 use base 'Wx::Panel';
 use Padre::Plugin::My;
-use Padre::Plugin::HG;
 use File::Spec;
 use File::Basename;
 my $HG;

File HG/UserPassPrompt.pm

+package Padre::Plugin::HG::UserPassPrompt;
+
+=pod
+
+=head1 NAME
+
+Module::Name - My author was too lazy to write an abstract
+
+=head1 SYNOPSIS
+
+  my $object = Module::Name->new(
+      foo  => 'bar',
+      flag => 1,
+  );
+  
+  $object->dummy;
+
+=head1 DESCRIPTION
+
+The author was too lazy to write a description.
+
+=head1 METHODS
+
+=cut
+
+use 5.006;
+use strict;
+use warnings;
+use Wx qw[:everything];
+use Wx::Event qw( EVT_BUTTON );
+use base 'Wx::Panel';
+our $VERSION = '0.01';
+
+=pod
+
+=head2 new
+
+  my $object = Module::Name->new(
+      title => 'project X',
+      default_username => 'fred',
+      default_password => 'XXXX',
+      
+  );
+
+The C<new> constructor lets you create a new B<Module::Install> object.
+
+So no big surprises there...
+
+Returns a new B<Module::Install> or dies on error.
+
+=cut
+
+sub new
+{
+    my ($class, %params) = @_; 
+    my $self       = $class->SUPER::new( Padre::Current->main);
+    
+    my $user_name = Wx::TextEntryDialog->new(undef, 'Enter your User Name',$params{title},$params{default_username});
+    $user_name->ShowModal();
+    $self->{username} =  $user_name->GetValue();
+    
+    my $user_pass = Wx::PasswordEntryDialog->new(undef, 'Enter your Password',$params{title},$params{default_password},wxOK|wxCANCEL);
+    $user_pass->ShowModal();
+    $self->{password} =  $user_pass->GetValue();
+    
+    return $self;
+}
+
+
+
+1;
+
+=pod
+
+=head1 SUPPORT
+
+No support is available
+
+=head1 AUTHOR
+
+Copyright 2008 Anonymous.
+
+=cut