pf-tools/pf-tools: HG Well... erm... Mercurial Good I mean

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Wed Aug 6 13:55:24 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/7ba4d61a3f51
changeset: 1299:7ba4d61a3f51
user:      shad
date:      Wed Aug 06 15:55:19 2014 +0200
description:
HG Well... erm... Mercurial Good I mean

diffstat:

 conf/pf-tools.conf       |  13 +++++++++++--
 doc/pf-tools.conf.sample |   1 +
 lib/PFTools/VCS/CVS.pm   |  33 ++++++++++++++++++++-------------
 lib/PFTools/VCS/HG.pm    |  35 +++++++++++++++++++++++++----------
 lib/PFTools/VCS/SVN.pm   |  10 ++++------
 5 files changed, 61 insertions(+), 31 deletions(-)

diffs (194 lines):

diff -r 06bfbf25d7e1 -r 7ba4d61a3f51 conf/pf-tools.conf
--- a/conf/pf-tools.conf	Tue Aug 05 13:01:29 2014 +0200
+++ b/conf/pf-tools.conf	Wed Aug 06 15:55:19 2014 +0200
@@ -16,13 +16,21 @@
     ipv6            = 0
     update          = 1
 
-[vcs]
+#[vcs]
+#    type            = hg
+#    method          = ssh
+#    vcsroot         = /var/lib/hg/
+#    server          = 10.128.2.5
+#    module          = config
+#    rsh             = /usr/bin/ssh -i /var/lib/cvsguest/.ssh/id_rsa
+#[vcs]
 #    type            = svn
 #    method          = svn+ssh
 #    vcsroot         = /var/lib/svn/
 #    server          = 10.128.2.5
 #    module          = trunk
-#    rsh             = ssh -i /var/lib/cvsguest/.ssh/id_rsa
+#    rsh             = /usr/bin/ssh -i /var/lib/cvsguest/.ssh/id_rsa
+[vcs]
     type            = cvs
     method          = rsh
     vcsroot         = /var/lib/cvs/repository
@@ -41,3 +49,4 @@
 [regex]
 #   deploy_hosts = '(deploy|[a-z]{3}\d-(?:rdeploy|spawn))'
     hostname_model = (?<HOSTTYPE>((?<POPNAME>[a-z]{3}\d{1})-)?([a-z0-9-]+[a-z0-9-]+))%*_*
+
diff -r 06bfbf25d7e1 -r 7ba4d61a3f51 doc/pf-tools.conf.sample
--- a/doc/pf-tools.conf.sample	Tue Aug 05 13:01:29 2014 +0200
+++ b/doc/pf-tools.conf.sample	Wed Aug 06 15:55:19 2014 +0200
@@ -18,6 +18,7 @@
 	# if you want to connect via ssh restricted keys, you'll have to put in authorized_keys
 	# for cvs:	command="/usr/bin/cvs server"
 	# for svn:	command="/usr/bin/svnserve -t"
+	# for gh:	command="/usr/bin/hg-ssh /path/to/your/repository"
 	type	= cvs
 	user	= cvsguest
 	method	= rsh
diff -r 06bfbf25d7e1 -r 7ba4d61a3f51 lib/PFTools/VCS/CVS.pm
--- a/lib/PFTools/VCS/CVS.pm	Tue Aug 05 13:01:29 2014 +0200
+++ b/lib/PFTools/VCS/CVS.pm	Wed Aug 06 15:55:19 2014 +0200
@@ -34,21 +34,28 @@
 
 sub checkout {
     my ( $hostname, $pf_config, $options ) = @_;
+
+    if ( !$hostname ) {
+        croak q{ERROR: Invalid undefined or empty $hostname};
+    }
+    if ( !$pf_config ) {
+        croak q{ERROR: Invalid undefined or empty $pf_config};
+    }
+    if ( !$options ) {
+        croak q{ERROR: Invalid undefined or empty $options};
+    }
+    if ( ref $hostname ) {
+        croak q{ERROR: Invalid non-scalar $hostname};
+    }
+    if ( ref $pf_config ne 'HASH' ) {
+        croak q{ERROR: Invalid non-hashref $pf_config};
+    }
+    if ( ref $options ne 'HASH' ) {
+        croak q{ERROR: Invalid non-hashref $options};
+    }
+
     my $cvs_cmd = $pf_config->{'vcs'}->{'command'};
 
-    if ( ref $hostname ) {
-        carp q{ERROR: $hostname MUST BE a string};
-        return;
-    }
-    unless ( $pf_config or $options ) {
-        carp q{ERROR: invalid parameter};
-        return;
-    }
-    unless ( ref $pf_config eq 'HASH' || ref $options eq 'HASH' ) {
-        carp q{ERROR: non-ref $pf_config and/or $options};
-        return;
-    }
-
     if ( defined $options->{'branch'} && $options->{'branch'} ne q{} ) {
         if ( $cvs_cmd ne q{} ) {
             carp
diff -r 06bfbf25d7e1 -r 7ba4d61a3f51 lib/PFTools/VCS/HG.pm
--- a/lib/PFTools/VCS/HG.pm	Tue Aug 05 13:01:29 2014 +0200
+++ b/lib/PFTools/VCS/HG.pm	Wed Aug 06 15:55:19 2014 +0200
@@ -36,13 +36,13 @@
 sub checkout {
     my ( $hostname, $pf_config, $options ) = @_;
 
-    unless ($hostname) {
+    if ( !$hostname ) {
         croak q{ERROR: Invalid undefined or empty $hostname};
     }
-    unless ($pf_config) {
+    if ( !$pf_config ) {
         croak q{ERROR: Invalid undefined or empty $pf_config};
     }
-    unless ($options) {
+    if ( !$options ) {
         croak q{ERROR: Invalid undefined or empty $options};
     }
     if ( ref $hostname ) {
@@ -70,14 +70,30 @@
         $options->{'branch'} = q{};
     }
 
-    my $ret;
     my $umask = umask( oct( $pf_config->{'vcs'}->{'umask'} ) );
 
     if ( !$hg_cmd ) {
-        $hg_cmd
-            = q{hg clone }
-            . $pf_config->{'vcs'}->{'server'} . q{/}
-            . $pf_config->{'vcs'}->{'module'};
+        if ( $hostname =~ /^$pf_config->{'regex'}->{'deploy_hosts'}/ ) {
+            $hg_cmd = q{hg clone } . q{/};
+        }
+        else {
+            if ( $options->{'verbose'} ) {
+                print $hostname ## no critic(RequireBracedFileHandleWithPrint);
+                    . q{ doesn't match }
+                    . $pf_config->{'regex'}->{'deploy_hosts'} . "\n";
+            }
+            $hg_cmd
+                = q{hg clone }
+                . $pf_config->{'vcs'}->{'method'} . q{://}
+                . $pf_config->{'vcs'}->{'user'} . q{@}
+                . $pf_config->{'vcs'}->{'server'} . q{/};
+
+        }
+        $hg_cmd .= $pf_config->{'vcs'}->{'vcsroot'} . q{/};
+        $hg_cmd .= $pf_config->{'vcs'}->{'module'};
+        if ( $pf_config->{'vcs'}->{'method'} eq 'ssh' ) {
+            $hg_cmd .= qq{ -e "$pf_config->{'vcs'}->{'rsh'}"};
+        }
     }
     if ( $options->{'debug'} || $options->{'verbose'} ) {
         print $hg_cmd. "\n";
@@ -103,9 +119,8 @@
         carp qq{ERROR: unable to checkout : $stderr};
         return;
     }
-
     umask $umask;
-    return !$ret;
+    return 1;
 }
 
 1;
diff -r 06bfbf25d7e1 -r 7ba4d61a3f51 lib/PFTools/VCS/SVN.pm
--- a/lib/PFTools/VCS/SVN.pm	Tue Aug 05 13:01:29 2014 +0200
+++ b/lib/PFTools/VCS/SVN.pm	Wed Aug 06 15:55:19 2014 +0200
@@ -35,13 +35,13 @@
 sub checkout {
     my ( $hostname, $pf_config, $options ) = @_;
 
-    unless ($hostname) {
+    if ( !$hostname ) {
         croak q{ERROR: Invalid undefined or empty $hostname};
     }
-    unless ($pf_config) {
+    if ( !$pf_config ) {
         croak q{ERROR: Invalid undefined or empty $pf_config};
     }
-    unless ($options) {
+    if ( !$options ) {
         croak q{ERROR: Invalid undefined or empty $options};
     }
     if ( ref $hostname ) {
@@ -69,7 +69,6 @@
         $options->{'branch'} = q{};
     }
 
-    my $ret;
     my $umask = umask( oct( $pf_config->{'vcs'}->{'umask'} ) );
 
     if ( $pf_config->{'vcs'}->{'method'} eq 'svn+ssh' ) {
@@ -125,9 +124,8 @@
         carp qq{ERROR: unable to checkout : $stderr};
         return;
     }
-
     umask $umask;
-    return !$ret;
+    return 1;
 }
 
 1;



More information about the pf-tools-commits mailing list