[svk-commit] r2648 - in branches/bm: . lib/SVK lib/SVK/Command lib/SVK/Editor t

nobody at bestpractical.com nobody at bestpractical.com
Tue Dec 18 19:41:42 EST 2007


Author: clsung
Date: Tue Dec 18 19:41:40 2007
New Revision: 2648

Modified:
   branches/bm/   (props changed)
   branches/bm/lib/SVK/Command.pm
   branches/bm/lib/SVK/Command/Copy.pm
   branches/bm/lib/SVK/Command/Ignore.pm
   branches/bm/lib/SVK/Editor/Merge.pm
   branches/bm/lib/SVK/Help/Environment.pod
   branches/bm/lib/SVK/Merge.pm
   branches/bm/lib/SVK/Util.pm
   branches/bm/t/07smerge-copy.t
   branches/bm/t/07smerge-cpreplace.t

Log:
 r2642 at going04 (orig r2633):  clkao | 2007-12-15 21:22:32 +0800
 When merging a copy with modification to the copied source, it
 may cause a checksum error because we are using the current active
 txn as inspector, where it doesn't really account for local
 modification for the copy source.
 
  r3839 at mtl (orig r2630):  clkao | 2007-12-15 17:10:49 +0800
  - Create branch smcp-base-bug
  r3840 at mtl (orig r2631):  clkao | 2007-12-15 17:12:21 +0800
  make resolve_base returns an appropriate inspector and use it.
  r3841 at mtl (orig r2632):  clkao | 2007-12-15 21:02:14 +0800
  when using inspector to check with the copysource base paths, we need to
  use non-txn inspector so we don't get fooled by nodes we touch during
  the current merge.
  
 
 r2647 at going04 (orig r2638):  jesse | 2007-12-17 09:28:13 +0800
  r73235 at pinglin:  jesse | 2007-12-16 20:28:02 -0500
  * First implementation of an SVKBATCHMODE environemt variable
 
 r2649 at going04 (orig r2640):  jesse | 2007-12-18 05:01:43 +0800
  r73736 at pinglin:  jesse | 2007-12-17 09:30:21 -0800
  * Added a note to docs for 'svk ignore' about how to unignore something
 


Modified: branches/bm/lib/SVK/Command.pm
==============================================================================
--- branches/bm/lib/SVK/Command.pm	(original)
+++ branches/bm/lib/SVK/Command.pm	Tue Dec 18 19:41:40 2007
@@ -1034,6 +1034,10 @@
 		      );
     }
     else {
+        if ($ENV{'SVKBATCHMODE'}) {
+            die(loc("This command needs to be run interactively\n"));
+        }
+
 	$prompt = loc ("Enter a depot path to %1 into (under // if no leading '/'): ",
 		       loc($action));
     }

Modified: branches/bm/lib/SVK/Command/Copy.pm
==============================================================================
--- branches/bm/lib/SVK/Command/Copy.pm	(original)
+++ branches/bm/lib/SVK/Command/Copy.pm	Tue Dec 18 19:41:40 2007
@@ -52,7 +52,7 @@
 use strict;
 use SVK::Version;  our $VERSION = $SVK::VERSION;
 use base qw( SVK::Command::Mkdir );
-use SVK::Util qw( get_anchor get_prompt abs2rel splitdir is_uri make_path is_path_inside);
+use SVK::Util qw( get_anchor abs2rel splitdir is_uri make_path is_path_inside);
 use SVK::I18N;
 use SVK::Logger;
 

Modified: branches/bm/lib/SVK/Command/Ignore.pm
==============================================================================
--- branches/bm/lib/SVK/Command/Ignore.pm	(original)
+++ branches/bm/lib/SVK/Command/Ignore.pm	Tue Dec 18 19:41:40 2007
@@ -129,3 +129,5 @@
 if the entry is already there may not be what you expected.  Currently
 it will not try to escape any such entries before adding them.)
 
+To tell svk to start paying attention to a file again, use the command
+'svk pe svn:ignore' to manually edit the ignore list.

Modified: branches/bm/lib/SVK/Editor/Merge.pm
==============================================================================
--- branches/bm/lib/SVK/Editor/Merge.pm	(original)
+++ branches/bm/lib/SVK/Editor/Merge.pm	Tue Dec 18 19:41:40 2007
@@ -58,7 +58,7 @@
 use autouse 'SVK::Util'
     => qw( slurp_fh md5_fh tmpfile devnull abs2rel );
 
-__PACKAGE__->mk_accessors(qw(inspector notify storage ticket cb_merged));
+__PACKAGE__->mk_accessors(qw(inspector static_inspector notify storage ticket cb_merged));
 
 use Class::Autouse qw(SVK::Inspector::Root SVK::Notify
 		      Data::Hierarchy IO::Digest);
@@ -280,7 +280,7 @@
 	if (defined $arg[0]) {
 	    $self->{notify}->hist_status ($path, '+');
 	    @arg = $self->resolve_copy($path, @arg);
-	    $self->{info}{$path}{baseinfo} = [$self->_resolve_base($path)];
+	    $self->{info}{$path}{baseinfo} = [$self->resolve_base($path, 0, $pool)];
 	    $self->{info}{$path}{fpool} = $pool;
 	}
 	$self->{storage_baton}{$path} =
@@ -307,13 +307,24 @@
 	    $entry->{".${key}_rev"});
 }
 
+sub resolve_base {
+    my ($self, $path, $orig, $pool) = @_;
+    my ($basepath, $fromrev) = $self->_resolve_base($path, $orig);
+    if ($basepath) {
+	# if the inspector is involving copy base, we can't use
+	# $self->inspector, as it represent the current txn
+	return ($basepath, $fromrev, $self->static_inspector);
+    }
+
+    return ($path, undef, $self->inspector) 
+}
+
 sub open_file {
     my ($self, $path, $pdir, $rev, $pool) = @_;
     # modified but rm locally - tag for conflict?
-    my ($basepath, $fromrev) = $self->_resolve_base($path);
-    $basepath = $path unless defined $basepath;
-    if (defined $pdir && $self->inspector->exist($basepath, $pool) == $SVN::Node::file) {
-	$self->{info}{$path}{baseinfo} = [$basepath, $fromrev]
+    my ($basepath, $fromrev, $inspector) = $self->resolve_base($path);
+    if (defined $pdir && $inspector->exist($basepath, $pool) == $SVN::Node::file) {
+	$self->{info}{$path}{baseinfo} = [$basepath, $fromrev, $inspector]
 	    if defined $fromrev;
 	$self->{info}{$path}{open} = [$pdir, $rev];
 	$self->{info}{$path}{fpool} = $pool;
@@ -420,10 +431,10 @@
     return unless $path;
 
     my $info = $self->{info}{$path};
-    my ($basepath, $fromrev) = $info->{baseinfo} ? @{$info->{baseinfo}} : ($path);
+    my ($basepath, $fromrev, $inspector) = $info->{baseinfo} ? @{$info->{baseinfo}} : ($path, undef, $self->inspector);
     my $fh = $info->{fh} = {};
     my $pool = $info->{fpool};
-    if ($pool && ($fh->{local} = $self->inspector->localmod($basepath, $checksum || '', $pool))) {
+    if ($pool && ($fh->{local} = $inspector->localmod($basepath, $checksum || '', $pool))) {
 	# retrieve base
 	unless ($info->{addmerge}) {
 	    $fh->{base} = [$self->_retrieve_base($path, $pool)];
@@ -541,7 +552,7 @@
     my $fh = $info->{fh};
     my $iod;
 
-    my ($basepath, $fromrev) = $info->{baseinfo} ? @{$info->{baseinfo}} : ($path);
+    my ($basepath, $fromrev, $inspector) = $info->{baseinfo} ? @{$info->{baseinfo}} : ($path, undef, $self->inspector);
     no warnings 'uninitialized';
     my $storagebase_checksum = $fh->{local}[CHECKSUM];
     if ($fromrev) {
@@ -555,7 +566,7 @@
 	$self->_merge_file_unchanged ($path, $checksum, $pool), return
 	    if $checksum eq $storagebase_checksum;
 
-	my $eol = $self->inspector->localprop($basepath, 'svn:eol-style', $pool);
+	my $eol = $inspector->localprop($basepath, 'svn:eol-style', $pool);
 	my $eol_layer = SVK::XD::get_eol_layer({'svn:eol-style' => $eol}, '>');
 	$eol_layer = '' if $eol_layer eq ':raw';
 	$self->prepare_fh ($fh, $eol_layer);
@@ -589,7 +600,7 @@
 	    if ($basepath ne $path) {
 		$checksum = $self->{base_root}->fs->revision_root($fromrev, $pool)->file_md5_checksum($basepath, $pool);
 	    }
-	    elsif (my $local = $self->inspector->localmod($basepath, $checksum, $pool)) {
+	    elsif (my $local = $inspector->localmod($basepath, $checksum, $pool)) {
 		$checksum = $local->[CHECKSUM];
 		close $local->[FH];
 	    }
@@ -668,10 +679,9 @@
     unless ($self->{open_nonexist}) {
 	return undef unless defined $pdir;
 
-	my ($basepath, $fromrev) = $self->_resolve_base($path);
-	$basepath = $path unless defined $basepath;
+	my ($basepath, $fromrev, $inspector) = $self->resolve_base($path);
 
-	unless ($self->inspector->exist($basepath, $pool) || $self->{open_nonexist}) {
+	unless ($inspector->exist($basepath, $pool) || $self->{open_nonexist}) {
 	    ++$self->{skipped};
 	    $self->{notify}->flush ($path);
 	    return undef;
@@ -708,22 +718,21 @@
 sub _merge_file_delete {
     my ($self, $path, $rpath, $pdir, $pool) = @_;
 
-    my ($basepath, $fromrev) = $self->_resolve_base($path);
-    $basepath = $path unless defined $basepath;
+    my ($basepath, $fromrev, $inspector) = $self->resolve_base($path);
     
     my $no_base;
     my $md5 = $self->{base_root}->check_path ($rpath, $pool)?
         $self->{base_root}->file_md5_checksum ($rpath, $pool)
         : do { $no_base = 1; require Digest::MD5; Digest::MD5::md5_hex('') };
 
-    return undef unless $self->inspector->localmod ($basepath, $md5, $pool);
+    return undef unless $inspector->localmod ($basepath, $md5, $pool);
     return {} unless $self->{resolve};
 
     my $fh = $self->{info}{$path}->{fh} || {};
     $fh->{base} ||= [$no_base? (tmpfile('base-')): ($self->_retrieve_base($path, $pool))];
     $fh->{new} = [tmpfile('new-')];
     $fh->{local} = [tmpfile('local-')];
-    my ($tmp) = $self->inspector->localmod($basepath, '', $pool);
+    my ($tmp) = $inspector->localmod($basepath, '', $pool);
     slurp_fh ( $tmp->[FH], $fh->{local}[FH]);
     seek $fh->{local}[FH], 0, 0;
     $fh->{local}[CHECKSUM] = $tmp->[CHECKSUM];
@@ -888,10 +897,9 @@
     my ($self, $path, $revision, $pdir, $pool) = @_;
     no warnings 'uninitialized';
     $pool = SVN::Pool->new_default($pool);
-    my ($basepath, $fromrev) = $self->_resolve_base($path);
-    $basepath = $path unless defined $basepath;
+    my ($basepath, $fromrev, $inspector) = $self->resolve_base($path);
 
-    return unless defined $pdir && $self->inspector->exist($basepath);
+    return unless defined $pdir && $inspector->exist($basepath);
     my $rpath = $basepath =~ m{^/} ? $basepath :
 	$self->{base_anchor} eq '/' ? "/$basepath" : "$self->{base_anchor}/$basepath";
     my $torm;

Modified: branches/bm/lib/SVK/Help/Environment.pod
==============================================================================
--- branches/bm/lib/SVK/Help/Environment.pod	(original)
+++ branches/bm/lib/SVK/Help/Environment.pod	Tue Dec 18 19:41:40 2007
@@ -140,6 +140,12 @@
 C<svk log> command.  The value of this variable can be anything that you can
 pass to C<svk log>'s C<--output> option.
 
+=item SVKBATCHMODE
+
+When you set this variable to a true value, SVK should never prompt the user for an 
+interactive response. 
+
+
 =item $SVKPGP
 
 svk supports signing and verifying changesets using the Gnu Privacy Guard.

Modified: branches/bm/lib/SVK/Merge.pm
==============================================================================
--- branches/bm/lib/SVK/Merge.pm	(original)
+++ branches/bm/lib/SVK/Merge.pm	Tue Dec 18 19:41:40 2007
@@ -569,6 +569,7 @@
     my $meditor = SVK::Editor::Merge->new
 	( anchor => $src->path_anchor,
 	  repospath => $src->repospath, # for stupid copyfrom url
+	  static_inspector => $self->{dst}->inspector,
 	  base_anchor => $base->path_anchor,
 	  base_root => $base_root,
 	  target => $target,

Modified: branches/bm/lib/SVK/Util.pm
==============================================================================
--- branches/bm/lib/SVK/Util.pm	(original)
+++ branches/bm/lib/SVK/Util.pm	Tue Dec 18 19:41:40 2007
@@ -173,6 +173,8 @@
 sub get_prompt { {
     my ($prompt, $pattern) = @_;
 
+    return '' if ($ENV{'SVKBATCHMODE'});
+
     local $| = 1;
     print $prompt;
 
@@ -266,70 +268,76 @@
 =cut
 
 sub get_buffer_from_editor {
-    my ($what, $sep, $content, $file, $anchor, $targets_ref) = @_;
+    my ( $what, $sep, $content, $file, $anchor, $targets_ref ) = @_;
     my $fh;
-    if (defined $content) {
-	($fh, $file) = tmpfile ($file, TEXT => 1, UNLINK => 0);
-	print $fh $content;
-	close $fh;
-    }
-    else {
-	open $fh, $file or die $!;
-	local $/;
-	$content = <$fh>;
-    close $fh;
+    if ( defined $content ) {
+        ( $fh, $file ) = tmpfile( $file, TEXT => 1, UNLINK => 0 );
+        print $fh $content;
+        close $fh;
+    } else {
+        open $fh, $file or die $!;
+        local $/;
+        $content = <$fh>;
+        close $fh;
     }
 
     my $time = time;
 
-    while (1) {
+    while (!$ENV{'SVKBATCHMODE'} && 1) {
         open my $fh, '<', $file or die $!;
         my $md5 = md5_fh($fh);
         close $fh;
 
-	edit_file ($file);
+        edit_file($file);
 
         open $fh, '<', $file or die $!;
-        last if ($md5 ne md5_fh($fh));
+        last if ( $md5 ne md5_fh($fh) );
         close $fh;
 
-	my $ans = get_prompt(
-	    loc("%1 not modified: a)bort, e)dit, c)ommit?", ucfirst($what)),
-	    qr/^[aec]/,
-	);
-	last if $ans =~ /^c/;
-	# XXX: save the file somewhere
-	unlink ($file), die loc("Aborted.\n") if $ans =~ /^a/;
+        my $ans = get_prompt(
+            loc( "%1 not modified: a)bort, e)dit, c)ommit?", ucfirst($what) ),
+            qr/^[aec]/,
+        );
+        last if $ans =~ /^c/;
+
+        # XXX: save the file somewhere
+        unlink($file), die loc("Aborted.\n") if $ans =~ /^a/;
     }
 
     open $fh, $file or die $!;
     local $/;
-    my @ret = defined $sep ? split (/\n\Q$sep\E\n/, <$fh>, 2) : (<$fh>);
+    my @ret = defined $sep ? split( /\n\Q$sep\E\n/, <$fh>, 2 ) : (<$fh>);
     close $fh;
     unlink $file;
 
     die loc("Cannot find separator; aborted.\n")
-        if defined($sep) and !defined($ret[1]);
+        if defined($sep)
+            and !defined( $ret[1] );
 
     return $ret[0] unless wantarray;
 
     # Compare targets in commit message
-    my $old_targets = (split (/\n\Q$sep\E\n/, $content, 2))[1];
-    $old_targets =~ s/^\?.*//mg; # remove unversioned files
+    my $old_targets = ( split( /\n\Q$sep\E\n/, $content, 2 ) )[1];
+    $old_targets =~ s/^\?.*//mg;    # remove unversioned files
 
-    my @new_targets =
-               map {
-                   s/^\s+//; # proponly change will have leading spacs
-			       [split(/[\s\+]+/, $_, 2)]}
-               grep {!/^\?/m} # remove unversioned fils
-               grep {/\S/}
-               split(/\n+/, $ret[1]);
-
-    if ($old_targets ne $ret[1]) {
-        # Assign new targets 
-	@$targets_ref = map abs2rel($_->[1], $anchor, undef, '/'), @new_targets;
+    my @new_targets
+        = map {
+        s/^\s+//;                   # proponly change will have leading spacs
+        [ split( /[\s\+]+/, $_, 2 ) ]
+        }
+        grep {
+        !/^\?/m
+        }    # remove unversioned fils
+        grep {/\S/}
+        split( /\n+/, $ret[1] );
+
+    if ( $old_targets ne $ret[1] ) {
+
+        # Assign new targets
+        @$targets_ref = map abs2rel( $_->[1], $anchor, undef, '/' ),
+            @new_targets;
     }
-    return ($ret[0], \@new_targets);
+    return ( $ret[0], \@new_targets );
 }
 
 =head3 get_encoding

Modified: branches/bm/t/07smerge-copy.t
==============================================================================
--- branches/bm/t/07smerge-copy.t	(original)
+++ branches/bm/t/07smerge-copy.t	Tue Dec 18 19:41:40 2007
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-use Test::More tests => 25;
+use Test::More tests => 26;
 use strict;
 use File::Path;
 use Cwd;
@@ -215,6 +215,11 @@
 	   qr'New merge ticket: .*:/local-many:40',
 	   qr'New merge ticket: .*:/trunk:3',
 	   'Committed revision 41.']);
+is_output($svk, 'cat', ['//trunk-3/B/de'],
+	  ['modify on D/de',
+	   'modify on B/de',
+	   'file de added later',
+	   'modify this on trunk']);
 
 is_output($svk, 'diff', ['-sr40:41', '//'],
 	  ['M + trunk-3/B/de',

Modified: branches/bm/t/07smerge-cpreplace.t
==============================================================================
--- branches/bm/t/07smerge-cpreplace.t	(original)
+++ branches/bm/t/07smerge-cpreplace.t	Tue Dec 18 19:41:40 2007
@@ -17,28 +17,24 @@
 
 # r2 - remove file B
 
-$svk->rm(-m => 'r5 - remove file A/me', "//V/A/me");
+#$svk->rm(-m => 'r5 - remove file A/me', "//V/A/me");
 
 $svk->checkout('//V',$copath);
 # r3 - cp B at 1 to C with modification,
 $svk->cp('//V/A/me' => "$copath/Cme", -r => 4 );
 
-append_file("$copath/Cme", "mmmmmm\n");
+append_file("$copath/Cme", "mmmmmmxx\n");
 $svk->ci(-m => 'r8 - modify Cme', $copath);
-# cp A at 2 to B
-$svk->cp('//V/A/D/de' => "$copath/A/me", -r => 5);
+# cp A at 2 to B, if we comment these two out, 
+#$svk->cp('//V/A/D/de' => "$copath/A/me", -r => 5);
 append_file("$copath/A/me", "mmmmmm\n");
-
 $svk->ci(-m => 'some copy with mods', $copath);
 
-TODO: {
-    local $TODO = 'not yet';
 is_output($svk, 'smerge', [-m => 'go', '//V', '//X'],
-	  ['Auto-merging (3, 7) /V to /X (base /V:3).',
-	   'R + A/me',
-	   'R + Cme',
-	   qr'New merge ticket: .*:/V:7',
-	   'Committed revision 8']);
-}
+	  ['Auto-merging (3, 6) /V to /X (base /V:3).',
+	   'U   A/me',
+	   'A + Cme',
+	   qr'New merge ticket: .*:/V:6',
+	   'Committed revision 7.']);
 
 1;


More information about the svk-commit mailing list