[svk-commit] r2877 - in branches/path-resolver: lib/SVK lib/SVK/Command t/bm

nobody at bestpractical.com nobody at bestpractical.com
Tue May 13 00:36:58 EDT 2008


Author: ruz
Date: Tue May 13 00:36:43 2008
New Revision: 2877

Modified:
   branches/path-resolver/   (props changed)
   branches/path-resolver/COMMITTERS
   branches/path-resolver/lib/SVK/Command/Add.pm
   branches/path-resolver/lib/SVK/Command/Branch.pm
   branches/path-resolver/lib/SVK/Command/Commit.pm
   branches/path-resolver/lib/SVK/XD.pm
   branches/path-resolver/t/bm/merge.t
   branches/path-resolver/t/bm/prop-setup-inverse-layout.t
   branches/path-resolver/t/bm/prop-setup.t

Log:
merge from trunk

 r18780 at cubic-pc (orig r2864):  sartak | 2008-05-12 18:28:38 +0400
  r55595 at onn:  sartak | 2008-05-12 10:19:12 -0400
  Do the copath mapping earlier so the files in the svk commit buffer are consistently absolute
 
 r18781 at cubic-pc (orig r2865):  jesse | 2008-05-12 18:31:28 +0400
  r30802 at 120:  jesse | 2008-05-12 10:30:15 -0400
  * reformat branch commadn help to fit on an 80 col screen
 
 r18782 at cubic-pc (orig r2866):  sartak | 2008-05-12 18:34:27 +0400
  r55651 at onn:  sartak | 2008-05-12 10:34:12 -0400
  Add myself to COMMITTERS
 
 r18783 at cubic-pc (orig r2867):  clsung | 2008-05-12 18:35:54 +0400
 - change --setup prompts
 r18784 at cubic-pc (orig r2868):  clsung | 2008-05-12 18:44:45 +0400
 - fix when the project is not placed in the mirror root
 r18785 at cubic-pc (orig r2869):  clkao | 2008-05-12 19:06:58 +0400
 Fix the bug that in non-uptodate checkout, certain commands
 requires the signature cache to be dirty to work correctly,
 because target_from_copath_maybe is setting the associated
 SVK::Path incorrectly that points to the latest revision.
 
 r18786 at cubic-pc (orig r2870):  clsung | 2008-05-12 19:21:20 +0400
 - --from is removd from --push, so did t/merge.t
 - fix bug
 r18787 at cubic-pc (orig r2871):  clsung | 2008-05-12 19:24:48 +0400
 - fix t/bm/merge.t 23rd test
 r18788 at cubic-pc (orig r2872):  clsung | 2008-05-12 19:42:44 +0400
 - TODO can_write_remote_proj_prop in --setup
 - prompt for multi-project props
 - modify related tests
 r18789 at cubic-pc (orig r2873):  sartak | 2008-05-12 20:17:47 +0400
  r55654 at onn:  sartak | 2008-05-12 12:17:08 -0400
  Move add-file logic from Add command to XD->do_add
 
 r18790 at cubic-pc (orig r2874):  sartak | 2008-05-12 22:10:43 +0400
  r55744 at onn:  sartak | 2008-05-12 14:09:58 -0400
  Include arbitrary arguments from Add in do_add
 
 r18791 at cubic-pc (orig r2875):  sartak | 2008-05-12 22:10:51 +0400
  r55745 at onn:  sartak | 2008-05-12 14:10:21 -0400
  Commit what I've got for SVK::Command::Commit. at least it only fails commit tests at this point
 


Modified: branches/path-resolver/COMMITTERS
==============================================================================
--- branches/path-resolver/COMMITTERS	(original)
+++ branches/path-resolver/COMMITTERS	Tue May 13 00:36:43 2008
@@ -23,4 +23,5 @@
        mndrix      Michael Hendricks <michael at ndrix.org>
       nnunley      Norman Nunley <nnunley at gmail.com>
        rbrown
+       sartak      Shawn M Moore <sartak at bestpractical.com>
          stig      Stig Brautaset <stig at brautaset.org>

Modified: branches/path-resolver/lib/SVK/Command/Add.pm
==============================================================================
--- branches/path-resolver/lib/SVK/Command/Add.pm	(original)
+++ branches/path-resolver/lib/SVK/Command/Add.pm	Tue May 13 00:36:43 2008
@@ -88,60 +88,14 @@
 	}
     }
 
-    $self->{xd}->checkout_delta
-	( $target->for_checkout_delta,
-	  xdroot => $target->create_xd_root,
-	  delete_verbose => 1,
-	  unknown_verbose => $self->{recursive},
-	  editor => SVK::Editor::Status->new
-	  ( notify => SVK::Notify->new
-	    ( cb_flush => sub {
-		  my ($path, $status) = @_;
-	          to_native($path, 'path');
-		  my $copath = $target->copath($path);
-		  my $report = $target->report->subdir($path);
-
-		  $target->contains_copath ($copath) or return;
-		  die loc ("%1 already added.\n", $report)
-		      if !$self->{recursive} && ($status->[0] eq 'R' || $status->[0] eq 'A');
-
-		  return unless $status->[0] eq 'D';
-		  lstat ($copath);
-		  $self->_do_add ('R', $copath, $report, !-d _)
-		      if -e _;
-	      })),
-	  cb_unknown => sub {
-	      my ($editor, $path) = @_;
-	      to_native($path, 'path');
-	      my $copath = $target->copath($path);
-	      my $report = $target->report->subdir($path);
-	      lstat ($copath);
-	      $self->_do_add ('A', $copath, $report, !-d _);
-	  },
-	);
-    return;
-}
-
-my %sch = (A => 'add', 'R' => 'replace');
+    $self->{xd}->do_add(
+        $target,
+        recursive       => $self->{recursive},
+        quiet           => $self->{quiet},
+        unknown_verbose => $self->{recursive},
+    );
 
-sub _do_add {
-    my ($self, $st, $copath, $report, $autoprop) = @_;
-    my $newprop;
-    $newprop = $self->{xd}->auto_prop($copath) if $autoprop;
-
-    $self->{xd}{checkout}->store ($copath,
-				  { '.schedule' => $sch{$st},
-				    $autoprop ?
-				    ('.newprop'  => $newprop) : ()});
-    return if $self->{quiet};
-
-    # determine whether the path is binary
-    my $bin = q{};
-    if ( ref $newprop && $newprop->{'svn:mime-type'} ) {
-        $bin = ' - (bin)' if !mimetype_is_text( $newprop->{'svn:mime-type'} );
-    }
-
-    $logger->info( "$st   $report$bin");
+    return;
 }
 
 1;

Modified: branches/path-resolver/lib/SVK/Command/Branch.pm
==============================================================================
--- branches/path-resolver/lib/SVK/Command/Branch.pm	(original)
+++ branches/path-resolver/lib/SVK/Command/Branch.pm	Tue May 13 00:36:43 2008
@@ -531,7 +531,7 @@
 	    die loc("No such branch/tag exists: %1\n", $src->path)
 		if ($SVN::Node::dir != $target->root->check_path($src->path)) ;
 	}
-	$self->{from} = 0;
+	$self->{from}++;
 	$self->{from_path} = $src->depotpath;
     }
 
@@ -718,7 +718,6 @@
 sub run {
     my ($self, $target) = @_;
 
-    my $proj = $self->load_project($target);
     my $local_root = $self->arg_depotpath('/'.$target->depot->depotname.'/');
     my ($trunk_path, $branch_path, $tag_path, $project_name, $preceding_path);
 
@@ -732,25 +731,33 @@
 	last if $trunk_path;
     }
 
+    my $proj = $self->load_project($self->arg_depotpath('/'.$target->depot->depotname.$preceding_path));
+
+    my $ans = 'n';
     if ($proj && $fromProp) {
+	$project_name = $proj->name;
 	$logger->info( loc("Project already set in properties: %1\n", $target->depotpath));
-	my $proplist = $local_root->root->node_proplist('/');
-	if (!exists $proplist->{"svk:project:$project_name:path-trunk"}) {
-	    my $ans = lc (get_prompt(
-		loc("Would you like to pull the project '%1' settings? [Y/n]", $project_name)
-	    ) );
-	    if ($ans ne 'n') {
-		$self->{message} = "- Mirror properties for project $project_name";
-
-		$proplist = $local_root->root->node_proplist($preceding_path);
-		for my $p ( map {'svk:project:'.$project_name.':'.$_}
-		    ('path-trunk', 'path-branches', 'path-tags')) {
-		    $self->do_propset($p,$proplist->{$p}, $local_root);
-		}
-		$self->do_propset("svk:project:$project_name:root",$preceding_path, $local_root);
-	    }
-	}
-    } else {
+	$ans = lc (get_prompt(
+	    loc("Is the project '%1' match? [Y/n]", $project_name)
+	) );
+    }
+#	my $proplist = $local_root->root->node_proplist('/');
+#	if (!exists $proplist->{"svk:project:$project_name:path-trunk"}) {
+#	    my $ans = lc (get_prompt(
+#		loc("Would you like to pull the project '%1' settings? [Y/n]", $project_name)
+#	    ) );
+#	    if ($ans ne 'n') {
+#		$self->{message} = "- Mirror properties for project $project_name";
+	#
+	#	$proplist = $local_root->root->node_proplist($preceding_path);
+	#	for my $p ( map {'svk:project:'.$project_name.':'.$_}
+	#	    ('path-trunk', 'path-branches', 'path-tags')) {
+	#	    $self->do_propset($p,$proplist->{$p}, $local_root);
+	#	}
+	#	$self->do_propset("svk:project:$project_name:root",$preceding_path, $local_root);
+	#    }
+	#}
+    if ($ans eq 'n') {
 	if (!$proj) {
 	    $logger->info( loc("New Project depotpath encountered: %1\n", $target->path));
 	} else {
@@ -764,7 +771,7 @@
 	    $tag_path =~ s{^/?$preceding_path}{};
 	}
 	{
-	    my $ans = get_prompt(
+	    $ans = get_prompt(
 		loc("Specify a project name (enter to use '%1'): ", $project_name),
 		qr/^(?:[A-Za-z][-+_A-Za-z0-9]*|$)/
 	    );
@@ -775,8 +782,8 @@
 	}
 	$trunk_path ||= $target->_to_pclass('/')->subdir('trunk');
 	{
-	    my $ans = get_prompt(
-		loc("It has no trunk, where is the trunk/? (press enter to use %1)\n=>", $trunk_path),
+	    $ans = get_prompt(
+		loc("What directory shall we use for the project's trunk? (Press ENTER to use %1)\n=>", $trunk_path),
 		qr/^(?:\/?[A-Za-z][-+.A-Za-z0-9]*|$)/
 
 	    );
@@ -787,8 +794,8 @@
 	}
 	$branch_path ||= $target->_to_pclass($trunk_path)->parent->subdir('branches');
 	{
-	    my $ans = get_prompt(
-		loc("And where is the branches/? (%1)\n=> ", $branch_path),
+	    $ans = get_prompt(
+		loc("What directory shall we use for the project's branches? (Press ENTER to use %1)\n=>", $branch_path),
 		qr/^(?:\/?[A-Za-z][-+.A-Za-z0-9]*|^\/|$)/
 	    );
 	    if (length($ans)) {
@@ -798,8 +805,8 @@
 	}
 	$tag_path ||= $target->_to_pclass($trunk_path)->parent->subdir('tags');
 	{
-	    my $ans = get_prompt(
-		loc("And where is the tags/? (%1) (or 's' to skip)", $tag_path),
+	    $ans = get_prompt(
+		loc("What directory shall we use for the project's tags? (Press ENTER to use %1, or 's' to skip)\n=>", $tag_path),
 		qr/^(?:\/?[A-Za-z][-+.A-Za-z0-9]*|$)/
 	    );
 	    if (length($ans)) {
@@ -811,12 +818,12 @@
 	#XXX implement setting properties of project here
 	$self->{message} = "- Setup properties for project $project_name";
 	# always set to local first
-	$self->do_propset("svk:project:$project_name:path-trunk",$trunk_path, $local_root);
-	$self->do_propset("svk:project:$project_name:path-branches",$branch_path, $local_root);
-	$self->do_propset("svk:project:$project_name:path-tags",$tag_path, $local_root);
-	$self->do_propset("svk:project:$project_name:root",$preceding_path, $local_root);
+	#$self->do_propset("svk:project:$project_name:path-trunk",$trunk_path, $local_root);
+	#$self->do_propset("svk:project:$project_name:path-branches",$branch_path, $local_root);
+	#$self->do_propset("svk:project:$project_name:path-tags",$tag_path, $local_root);
+	#$self->do_propset("svk:project:$project_name:root",$preceding_path, $local_root);
 	my $root_depot = $self->arg_depotpath('/'.$target->depot->depotname.$preceding_path);
-	if (0) { # how do we ask user to push to remote?
+	if (1) { # how do we ask user to push to remote?
 	    $self->do_propset("svk:project:$project_name:path-trunk",$trunk_path, $root_depot);
 	    $self->do_propset("svk:project:$project_name:path-branches",$branch_path, $root_depot);
 	    $self->do_propset("svk:project:$project_name:path-tags",$tag_path, $root_depot);
@@ -965,21 +972,21 @@
 
 =head1 OPTIONS
 
- -l [--list]            : list branches for this project
- --create               : create a new branch
- --tag                  : create in the tags directory
- --local                : targets in local branch
- --delete               : delete BRANCH(s)
- --checkout             : checkout BRANCH in current directory
- --switch               : switch the current checkout to another branch
+ -l [--list]        : list branches for this project
+ --create           : create a new branch
+ --tag              : create in the tags directory
+ --local            : targets in local branch
+ --delete           : delete BRANCH(s)
+ --checkout         : checkout BRANCH in current directory
+ --switch           : switch the current checkout to another branch
                           (can be paired with --create)
- --merge                : automatically merge all changes from BRANCH1, BRANCH2,
+ --merge            : automatically merge all changes from BRANCH1, BRANCH2,
                           etc, to TARGET
- --project              : specify the target project name 
- --push                 : move changes to wherever this branch was copied from
- --setup                : setup a project for a specified DEPOTPATH
- -C [--check-only]      : try a create, move or merge operation but make no     
-                          changes
+ --project          : specify the target project name 
+ --push             : move changes to wherever this branch was copied from
+ --setup            : setup a project for a specified DEPOTPATH
+ -C [--check-only]  : try a create, move or merge operation but make no     
+                      changes
 
 
 =head1 DESCRIPTION

Modified: branches/path-resolver/lib/SVK/Command/Commit.pm
==============================================================================
--- branches/path-resolver/lib/SVK/Command/Commit.pm	(original)
+++ branches/path-resolver/lib/SVK/Command/Commit.pm	Tue May 13 00:36:43 2008
@@ -356,6 +356,8 @@
         $status_editor = SVK::Editor::Status->new(notify => $notify);
     }
 
+    my %may_need_to_add;
+
     $self->{xd}->checkout_delta
 	( $target->for_checkout_delta,
 	  depth => $self->{recursive} ? undef : 0,
@@ -369,6 +371,7 @@
       cb_unknown  => sub {
           my ($self, $path) = @_;
           $path = $target->copath($path);
+          $may_need_to_add{$path} = 1;
           push @unversioned, "?   $path\n";
       },
 	);
@@ -446,22 +449,17 @@
     $self->decode_commit_message;
 
     my @need_to_add = map  { $_->[1] }
-                      grep {$_->[0] eq 'A'}
+                      grep { $may_need_to_add{ $_->[1] } }
+                      grep { $_->[0] eq 'A' }
                       @$targets;
-    for (@need_to_add)
-    {
-        my $newprop;
-        my $autoprop = !-d $_;
-
-        $newprop = $self->{xd}->auto_prop($_)
-            if $autoprop;
-
-        # seems to work even if the file is already there (say the user changes
-        # an M to an A), but there really should be some kind of check
-        $self->{xd}{checkout}->store ($_,
-                    { '.schedule' => 'add',
-                        $autoprop ?
-                        ('.newprop'  => $newprop) : ()});
+
+    if (@need_to_add) {
+        my $old_targets = $target->{targets};
+        $target->{targets} = \@need_to_add;
+        $self->{xd}->do_add($target,
+            unknown_verbose => 1,
+        );
+        $target->{targets} = $old_targets;
     }
 
     return ($commit_editor, [sort {$a->[1] cmp $b->[1]} @$targets]);

Modified: branches/path-resolver/lib/SVK/XD.pm
==============================================================================
--- branches/path-resolver/lib/SVK/XD.pm	(original)
+++ branches/path-resolver/lib/SVK/XD.pm	Tue May 13 00:36:43 2008
@@ -577,14 +577,15 @@
 	my ($cinfo, $coroot) = $self->{checkout}->get ($copath);
 	die loc("path %1 is not a checkout path.\n", $copath) unless %$cinfo;
 	($repospath, $path, $repos) = $self->find_repos ($cinfo->{depotpath}, 1);
-	my ($rev, $subpath);
-	if (($view, $rev, $subpath) = $path =~ m{^/\^([\w/\-_]+)(?:\@(\d+)(.*))?$}) {
-	    ($path, $view) = SVK::Command->create_view ($repos, $view, $rev, $subpath);
+	my ($view_rev, $subpath);
+	if (($view, $view_rev, $subpath) = $path =~ m{^/\^([\w/\-_]+)(?:\@(\d+)(.*))?$}) {
+	    ($path, $view) = SVK::Command->create_view ($repos, $view, $view_rev, $subpath);
 	}
 
 	$path = abs2rel ($copath, $coroot => $path, '/');
 
 	($depotpath) = $cinfo->{depotpath} =~ m|^/(.*?)/|;
+        $rev = $cinfo->{revision} unless defined $rev;
 	$depotpath = "/$depotpath$path";
     }
 
@@ -782,6 +783,68 @@
     rmtree (\@paths) if @paths;
 }
 
+sub do_add {
+    my ($self, $target, %arg) = @_;
+
+    $self->checkout_delta(
+        $target->for_checkout_delta,
+        %arg,
+        xdroot => $target->create_xd_root,
+        delete_verbose => 1,
+        editor => SVK::Editor::Status->new(
+            notify => SVK::Notify->new(
+                cb_flush => sub {
+                    my ($path, $status) = @_;
+                    to_native($path, 'path');
+                    my $copath = $target->copath($path);
+                    my $report = $target->report->subdir($path);
+
+                    $target->contains_copath ($copath) or return;
+                    die loc ("%1 already added.\n", $report)
+                        if !$arg{recursive} && ($status->[0] eq 'R' || $status->[0] eq 'A');
+
+                    return unless $status->[0] eq 'D';
+                    lstat ($copath);
+                    $self->_do_add('R', $copath, $report, !-d _, %arg)
+                        if -e _;
+                },
+            ),
+        ),
+        cb_unknown => sub {
+            my ($editor, $path) = @_;
+            to_native($path, 'path');
+            my $copath = $target->copath($path);
+            my $report = $target->report->subdir($path);
+            lstat ($copath);
+            $self->_do_add('A', $copath, $report, !-d _, %arg);
+        },
+	);
+    return;
+}
+
+my %sch = (A => 'add', 'R' => 'replace');
+
+sub _do_add {
+    my ($self, $st, $copath, $report, $autoprop, %arg) = @_;
+    my $newprop;
+    $newprop = $self->auto_prop($copath) if $autoprop;
+
+    $self->{checkout}->store($copath, {
+            '.schedule' => $sch{$st},
+            $autoprop ? ('.newprop' => $newprop) : ()
+    });
+
+    return if $arg{quiet};
+
+    # determine whether the path is binary
+    my $bin = q{};
+    if ( ref $newprop && $newprop->{'svn:mime-type'} ) {
+        $bin = ' - (bin)' if !mimetype_is_text( $newprop->{'svn:mime-type'} );
+    }
+
+    $logger->info( "$st   $report$bin");
+}
+
 sub do_propset {
     my ($self, $target, %arg) = @_;
     my ($entry, $schedule) = $self->get_entry($target->copath);

Modified: branches/path-resolver/t/bm/merge.t
==============================================================================
--- branches/path-resolver/t/bm/merge.t	(original)
+++ branches/path-resolver/t/bm/merge.t	Tue May 13 00:36:43 2008
@@ -204,5 +204,5 @@
      "Checking locally against mirror source $uri.", 'U   B/S/Q/qu',
      qr'New merge ticket: [\w\d-]+:/branches/merge/foo3:25']);
 
-is_output ($svk, 'branch', ['--push', '-C', '--from', 'merge/foo3'],
+is_output ($svk, 'branch', ['--push', '-C', 'merge/foo3'],
     [(split /\n/, $pushOutputs)]);

Modified: branches/path-resolver/t/bm/prop-setup-inverse-layout.t
==============================================================================
--- branches/path-resolver/t/bm/prop-setup-inverse-layout.t	(original)
+++ branches/path-resolver/t/bm/prop-setup-inverse-layout.t	Tue May 13 00:36:43 2008
@@ -35,6 +35,7 @@
 is_output_like ($svk, 'branch', ['--create','bar','--project','sushi','//mirror/nomeans'],
     qr'Project branch created: bar');
 is_output ($svk, 'branch', ['--list', '--project', 'sushi', '//mirror/nomeans'], ['bar']);
+$answer = [''];
 is_output ($svk, 'branch', ['--setup', '//mirror/nomeans/trunk/sushi'],
     ['Project already set in properties: //mirror/nomeans/trunk/sushi']);
 

Modified: branches/path-resolver/t/bm/prop-setup.t
==============================================================================
--- branches/path-resolver/t/bm/prop-setup.t	(original)
+++ branches/path-resolver/t/bm/prop-setup.t	Tue May 13 00:36:43 2008
@@ -46,14 +46,16 @@
 is_output ($svk, 'branch', ['--list'], ['bar']);
 is_output ($svk, 'list', ['//mirror/nomeans/A-b/bar'],
     ['Q/' ,'be']);
+$answer = [''];
 is_output ($svk, 'branch', ['--setup', '//mirror/nomeans/A'],
     ['Project already set in properties: //mirror/nomeans/A']);
 
 chdir("..");
 is_output ($svk, 'branch', ['--list', '//mirror/nomeans/projectB'], []);
-$answer = ['', '','',''];
+$answer = ['n','', '','',''];
 is_output_like ($svk, 'branch', ['--setup', '//mirror/nomeans/projectB'],
     qr/Project detected in specified path./);
+$answer = [''];
 is_output ($svk, 'branch', ['--setup', '//mirror/nomeans/projectB'],
     ['Project already set in properties: //mirror/nomeans/projectB']);
 #}


More information about the svk-commit mailing list