Commits

Anonymous committed 6a5e89b

init() was just plain broken

Comments (0)

Files changed (1)

 use 5.10.1;
 
 use Hg::Lib::Client;
+use Hg::Lib::Utils 'prep_cmd';
 
+use Capture::Tiny 'capture';
 use Type::Params qw[ compile ];
 use Types::Standard qw[ Str Dict slurpy Optional HashRef Bool Num];
 use Hg::Lib::Types -all;
 
+use Hg::Lib::Exception qw[ ECommand ];
+
 our $VERSION = '0.01_05';
 
 my @common_args = (
 
     my ( $opts ) = $check->( @_ );
 
-    my $cmd = $self->_prep_cmd( init => [ delete $opts->{dest} ], $opts );
+    my $hg = delete $opts->{hg} // 'hg';
 
-    my ( $stdout, $stderr, $exit ) = capture { system( @$cmd ) };
+    my $cmd = prep_cmd(
+        init => [  delete $opts->{dest} // () ],
+        $opts
+    );
+
+    my ( $stdout, $stderr, $exit ) = capture { system( $hg, @$cmd ) };
 
     ECommand->throw(
         cmd    => $cmd,
         error  => $stderr
     ) if $exit;
 
-    return Hg::Lib::Client->new(
-        @{$opts}{ keys %{ Hg::Lib::Client->shadowed_attrs } } );
-
+    return Hg::Lib::Client->new( %$opts, hg => $hg );
 }