[Bps-public-commit] r14309 - in Pushmi/branches/lock: . lib/Pushmi lib/Pushmi/Command

clkao at bestpractical.com clkao at bestpractical.com
Fri Jul 18 22:35:20 EDT 2008


Author: clkao
Date: Fri Jul 18 22:35:20 2008
New Revision: 14309

Added:
   Pushmi/branches/lock/lib/Pushmi/Command/Rununlock.pm
Modified:
   Pushmi/branches/lock/MANIFEST
   Pushmi/branches/lock/lib/Pushmi/Command/Runlock.pm
   Pushmi/branches/lock/lib/Pushmi/Mirror.pm
   Pushmi/branches/lock/t/lock.t

Log:
unlock support

Modified: Pushmi/branches/lock/MANIFEST
==============================================================================
--- Pushmi/branches/lock/MANIFEST	(original)
+++ Pushmi/branches/lock/MANIFEST	Fri Jul 18 22:35:20 2008
@@ -25,6 +25,7 @@
 lib/Pushmi/Command/Sync.pm
 lib/Pushmi/Command/Tryauth.pm
 lib/Pushmi/Command/Unlock.pm
+lib/Pushmi/Command/Ununlock.pm
 lib/Pushmi/Command/Verify.pm
 lib/Pushmi/Config.pm
 lib/Pushmi/Editor/Locker.pm

Modified: Pushmi/branches/lock/lib/Pushmi/Command/Runlock.pm
==============================================================================
--- Pushmi/branches/lock/lib/Pushmi/Command/Runlock.pm	(original)
+++ Pushmi/branches/lock/lib/Pushmi/Command/Runlock.pm	Fri Jul 18 22:35:20 2008
@@ -25,6 +25,7 @@
     my $lock_path = substr($self->{path}, 1);
     $ra->lock({ $lock_path => -1 }, $self->{comment}, $self->{steal},
           sub { my ($path, $locked, $lock, $err, $pool) = @_;
+                die $err->expanded_message."\n" if $err;
                 print $lock->token if $lock;
             });
     exit 0;

Added: Pushmi/branches/lock/lib/Pushmi/Command/Rununlock.pm
==============================================================================
--- (empty file)
+++ Pushmi/branches/lock/lib/Pushmi/Command/Rununlock.pm	Fri Jul 18 22:35:20 2008
@@ -0,0 +1,53 @@
+package Pushmi::Command::Rununlock;
+use strict;
+use warnings;
+use base 'Pushmi::Command';
+my $logger = Pushmi::Config->logger('pushmi.runlock');
+
+sub options {
+    ( 'path=s'  => 'path',
+      'user=s'  => 'user',
+      'token=s' => 'token',
+      'break'   => 'break' );
+}
+
+sub run {
+    my ($self, $repospath) = @_;
+    die "repospath required" unless $repospath;
+
+    my $pushmi = Pushmi::Mirror->new( path => $repospath );
+    $pushmi->ensure_consistency;
+
+    my $t = $pushmi->root_svkpath;
+
+    my ($mirror) = $t->is_mirrored;
+    my $ra = $mirror->_backend->_new_ra;
+    my $lock_path = substr($self->{path}, 1);
+    $ra->unlock({ $lock_path => $self->{token} }, $self->{break},
+          sub { my ($path, $locked, $lock, $err, $pool) = @_;
+                die $err->expanded_message."\n" if $err;
+            });
+    exit 0;
+}
+
+=head1 NAME
+
+Pushmi::Command::Rununlock - svn lock preprocessing
+
+=head1 SYNOPSIS
+
+ runlock
+
+=head1 OPTIONS
+
+
+=head1 DESCRIPTION
+
+The command tries to lock the master and output the token on success
+to be used by the replica.
+
+This is not intended to be invoked manually.
+
+=cut
+
+1;

Modified: Pushmi/branches/lock/lib/Pushmi/Mirror.pm
==============================================================================
--- Pushmi/branches/lock/lib/Pushmi/Mirror.pm	(original)
+++ Pushmi/branches/lock/lib/Pushmi/Mirror.pm	Fri Jul 18 22:35:20 2008
@@ -129,6 +129,17 @@
 
 END
 
+    _install_hook( $self->path, 'pre-unlock', << "END");
+#!/bin/sh
+export SVKNOSVNCONFIG=1
+export PUSHMI_CONFIG=$ENV{PUSHMI_CONFIG}
+export LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}
+export DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}
+export PATH=$ENV{PATH}
+$perl $pushmi rununlock "\$1" --path "\$2" --user "\$3" --token "\$4" --break "\$5"
+
+END
+
 }
 
 sub _install_hook {

Modified: Pushmi/branches/lock/t/lock.t
==============================================================================
--- Pushmi/branches/lock/t/lock.t	(original)
+++ Pushmi/branches/lock/t/lock.t	Fri Jul 18 22:35:20 2008
@@ -9,7 +9,7 @@
 plan skip_all => 'requires 1.6.0 for lock'
     if $SVN::Core::VERSION lt '1.6.0';
 
-plan tests => 10;
+plan tests => 13;
 
 my ($svk,
     $uri, $srepos, undef, undef, $scorpath,
@@ -38,3 +38,9 @@
 ok($lock2, 'has lock on master');
 
 is($lock, $lock2, 'lock token are identical');
+
+is_svn_output(['unlock', 'fromsvn.txt'],
+              ["'fromsvn.txt' unlocked."]);
+
+ok(!$repos->fs->get_lock('/fromsvn.txt'), 'unlocked for slave');
+ok(!$srepos->fs->get_lock('/fromsvn.txt'), 'unlocked for msater');



More information about the Bps-public-commit mailing list