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

clkao at bestpractical.com clkao at bestpractical.com
Mon Jul 28 10:06:28 EDT 2008


Author: clkao
Date: Mon Jul 28 10:06:27 2008
New Revision: 14569

Modified:
   Pushmi/branches/lock/lib/Pushmi/Command/Runhook.pm
   Pushmi/branches/lock/t/lock.t

Log:
commit with locks through slave should work with latest
svn patches and svk.

Modified: Pushmi/branches/lock/lib/Pushmi/Command/Runhook.pm
==============================================================================
--- Pushmi/branches/lock/lib/Pushmi/Command/Runhook.pm	(original)
+++ Pushmi/branches/lock/lib/Pushmi/Command/Runhook.pm	Mon Jul 28 10:06:27 2008
@@ -29,6 +29,23 @@
     my $t = $pushmi->root_svkpath;
     $pushmi->ensure_consistency;
 
+    my $locks;
+    if (!eof(\*STDIN)) {
+        if ((scalar <STDIN>) =~ m'^LOCKS-TOKENS:') {
+            while (<STDIN>) {
+                chomp;
+                last unless $_;
+                my ($path, $token) = split('\|', $_, 2);
+                $locks->{$path} = $token;
+            }
+
+            # turn lock path into relative
+            $locks = { map { my $token = $locks->{$_};
+                             substr($_, 0, 1, '');
+                             $_ => $token; } keys %$locks};
+        }
+    }
+
     # XXX: if we reentrant, the mirror will be in deadlock.
     $AUTHOR = $txn->prop('svn:author');
     $logger->info("[$repospath] committing from txn $self->{txnname} by $AUTHOR");
@@ -38,6 +55,7 @@
     my ($editor, $inspector, %arg) = $t->get_editor(notee => 1,
 						    callback => sub {},
 						    caller => '',
+                                                    lock_tokens => $locks,
 						    message  => $txn->prop('svn:log'));
     my $mirror = $pushmi->master;
 

Modified: Pushmi/branches/lock/t/lock.t
==============================================================================
--- Pushmi/branches/lock/t/lock.t	(original)
+++ Pushmi/branches/lock/t/lock.t	Mon Jul 28 10:06:27 2008
@@ -9,7 +9,7 @@
 plan skip_all => 'requires 1.6.0 for lock'
     if $SVN::Core::VERSION lt '1.6.0';
 
-plan tests => 18;
+plan tests => 21;
 
 my $user = $ENV{USER};
 
@@ -36,6 +36,7 @@
 $lock = $lock->token if $lock;
 ok($lock, 'has lock on slave');
 my $lock2 = $srepos->fs->get_lock('/fromsvn.txt');
+is($lock && $lock2->comment, 'lock from slave');
 $lock2 = $lock2->token if $lock;
 ok($lock2, 'has lock on master');
 
@@ -61,3 +62,11 @@
               ["'fromsvn.txt' locked by user '$user'."]);
 
 is($repos->fs->get_lock('/fromsvn.txt')->token, $srepos->fs->get_lock('/fromsvn.txt')->token, 'lock identical after stealing');
+
+is_svn_output(['lock', '--force', -m => 'lock from again', 'fromsvn.txt'],
+              ["'fromsvn.txt' locked by user '$user'."]);
+append_file('fromsvn.txt', "more content\n");
+is_svn_output(['ci', -m => 'yatta'],
+              ['Sending        fromsvn.txt',
+               'Transmitting file data .',
+               'Committed revision 3.' ], 'commit through slave holding lock, verified by master');



More information about the Bps-public-commit mailing list