[svk-commit] r2873 - in trunk: lib/SVK lib/SVK/Command

nobody at bestpractical.com nobody at bestpractical.com
Mon May 12 12:17:47 EDT 2008


Author: sartak
Date: Mon May 12 12:17:47 2008
New Revision: 2873

Modified:
   trunk/   (props changed)
   trunk/lib/SVK/Command/Add.pm
   trunk/lib/SVK/XD.pm

Log:
 r55654 at onn:  sartak | 2008-05-12 12:17:08 -0400
 Move add-file logic from Add command to XD->do_add


Modified: trunk/lib/SVK/Command/Add.pm
==============================================================================
--- trunk/lib/SVK/Command/Add.pm	(original)
+++ trunk/lib/SVK/Command/Add.pm	Mon May 12 12:17:47 2008
@@ -88,60 +88,13 @@
 	}
     }
 
-    $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},
+    );
 
-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: trunk/lib/SVK/XD.pm
==============================================================================
--- trunk/lib/SVK/XD.pm	(original)
+++ trunk/lib/SVK/XD.pm	Mon May 12 12:17:47 2008
@@ -783,6 +783,68 @@
     rmtree (\@paths) if @paths;
 }
 
+sub do_add {
+    my ($self, $target, %arg) = @_;
+
+    $self->checkout_delta(
+        $target->for_checkout_delta,
+        xdroot => $target->create_xd_root,
+        delete_verbose => 1,
+        unknown_verbose => $arg{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 !$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);


More information about the svk-commit mailing list