On the fsx branch: final sync with /trunk.
Conflicts in spillbuf.c and spillbuf-test.c resolved.

git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/fsx@1509911 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/build/generator/gen_base.py b/build/generator/gen_base.py
index f50fea6..24907c8 100644
--- a/build/generator/gen_base.py
+++ b/build/generator/gen_base.py
@@ -261,7 +261,8 @@
     # ###
     # ### Currently it's only used by maintainer-mode builds.  If this
     # ### functionality ever moves to release builds, it will have to move
-    # ### to configure-time.
+    # ### to configure-time (but remember that Python cannot be assumed to
+    # ### be available from 'configure').
     import errno
 
     lines = [
diff --git a/subversion/include/private/svn_subr_private.h b/subversion/include/private/svn_subr_private.h
index 10a4f60..e21f795 100644
--- a/subversion/include/private/svn_subr_private.h
+++ b/subversion/include/private/svn_subr_private.h
@@ -179,15 +179,6 @@
                             apr_size_t maxsize,
                             apr_pool_t *result_pool);
 
-/* Create a spill-buffer with extra parameters, and a reader for it. */
-svn_spillbuf_reader_t *
-svn_spillbuf__reader_create_extended(apr_size_t blocksize,
-                                     apr_size_t maxsize,
-                                     svn_boolean_t delete_on_close,
-                                     svn_boolean_t spill_all_contents,
-                                     const char *dirpath,
-                                     apr_pool_t *result_pool);
-
 /* Read @a len bytes from @a reader into @a data. The number of bytes
    actually read is stored in @a amt. If the content is exhausted, then
    @a amt is set to zero. It will always be non-zero if the spill-buffer
@@ -226,16 +217,6 @@
 svn_stream_t *
 svn_stream__from_spillbuf(svn_spillbuf_t *buf,
                           apr_pool_t *result_pool);
-/* Return a stream built on top of a spillbuf, using the same arguments as
-   svn_spillbuf__create_extended(). */
-svn_stream_t *
-svn_stream__from_spillbuf_extended(apr_size_t blocksize,
-                                   apr_size_t maxsize,
-                                   svn_boolean_t delete_on_close,
-                                   svn_boolean_t spill_all_contents,
-                                   const char *dirpath,
-                                   apr_pool_t *result_pool);
-
 
 /** @} */
 
diff --git a/subversion/libsvn_subr/spillbuf.c b/subversion/libsvn_subr/spillbuf.c
index 3beaa42..703596c 100644
--- a/subversion/libsvn_subr/spillbuf.c
+++ b/subversion/libsvn_subr/spillbuf.c
@@ -531,23 +531,6 @@
   return sbr;
 }
 
-svn_spillbuf_reader_t *
-svn_spillbuf__reader_create_extended(apr_size_t blocksize,
-                                     apr_size_t maxsize,
-                                     svn_boolean_t delete_on_close,
-                                     svn_boolean_t spill_all_contents,
-                                     const char *dirpath,
-                                     apr_pool_t *result_pool)
-{
-  svn_spillbuf_reader_t *sbr = apr_pcalloc(result_pool, sizeof(*sbr));
-  sbr->buf = svn_spillbuf__create_extended(blocksize, maxsize,
-                                           delete_on_close,
-                                           spill_all_contents, dirpath,
-                                           result_pool);
-  return sbr;
-}
-
-
 svn_error_t *
 svn_spillbuf__reader_read(apr_size_t *amt,
                           svn_spillbuf_reader_t *reader,
@@ -694,14 +677,15 @@
 }
 
 
-/* Wrap a spillbuf reader into a stream. */
-static svn_stream_t *
-stream_from_reader(svn_spillbuf_reader_t *reader, apr_pool_t *result_pool)
+svn_stream_t *
+svn_stream__from_spillbuf(svn_spillbuf_t *buf,
+                          apr_pool_t *result_pool)
 {
   svn_stream_t *stream;
   struct spillbuf_baton *sb = apr_palloc(result_pool, sizeof(*sb));
 
-  sb->reader = reader;
+  sb->reader = apr_pcalloc(result_pool, sizeof(*sb->reader));
+  sb->reader->buf = buf;
   sb->scratch_pool = svn_pool_create(result_pool);
 
   stream = svn_stream_create(sb, result_pool);
@@ -711,28 +695,3 @@
 
   return stream;
 }
-
-svn_stream_t *
-svn_stream__from_spillbuf(svn_spillbuf_t *buf,
-                          apr_pool_t *result_pool)
-{
-  svn_spillbuf_reader_t *reader = apr_pcalloc(result_pool, sizeof(*reader));
-  reader->buf = buf;
-
-  return stream_from_reader(reader, result_pool);
-}
-
-svn_stream_t *
-svn_stream__from_spillbuf_extended(apr_size_t blocksize,
-                                   apr_size_t maxsize,
-                                   svn_boolean_t delete_on_close,
-                                   svn_boolean_t spill_all_contents,
-                                   const char *dirpath,
-                                   apr_pool_t *result_pool)
-{
-  return stream_from_reader(
-      svn_spillbuf__reader_create_extended(
-          blocksize, maxsize, delete_on_close,
-          spill_all_contents, dirpath, result_pool),
-      result_pool);
-}
diff --git a/subversion/tests/libsvn_subr/spillbuf-test.c b/subversion/tests/libsvn_subr/spillbuf-test.c
index f7960ff..29e6a2c 100644
--- a/subversion/tests/libsvn_subr/spillbuf-test.c
+++ b/subversion/tests/libsvn_subr/spillbuf-test.c
@@ -305,8 +305,11 @@
 }
 
 static svn_error_t *
-test_spillbuf__reader(apr_pool_t *pool, svn_spillbuf_reader_t *sbr)
+test_spillbuf_reader(apr_pool_t *pool)
 {
+  svn_spillbuf_reader_t *sbr = svn_spillbuf__reader_create(4 /* blocksize */,
+                                                           100 /* maxsize */,
+                                                           pool);
   apr_size_t amt;
   char buf[10];
 
@@ -331,29 +334,12 @@
 }
 
 static svn_error_t *
-test_spillbuf_reader(apr_pool_t *pool)
+test_spillbuf_stream(apr_pool_t *pool)
 {
-  svn_spillbuf_reader_t *sbr = svn_spillbuf__reader_create(4 /* blocksize */,
-                                                           100 /* maxsize */,
-                                                           pool);
-  return test_spillbuf__reader(pool, sbr);
-}
-
-static svn_error_t *
-test_spillbuf_reader_spill_all(apr_pool_t *pool)
-{
-  svn_spillbuf_reader_t *sbr = svn_spillbuf__reader_create_extended(
-                          4 /* blocksize */,
-                          100 /* maxsize */,
-                          TRUE /* delte on close */,
-                          TRUE /* spill all data */,
-                          NULL, pool);
-  return test_spillbuf__reader(pool, sbr);
-}
-
-static svn_error_t *
-test_spillbuf__stream(apr_pool_t *pool, svn_stream_t *stream)
-{
+  svn_spillbuf_t *buf = svn_spillbuf__create(4 /* blocksize */,
+                                             100 /* maxsize */,
+                                             pool);
+  svn_stream_t *stream = svn_stream__from_spillbuf(buf, pool);
   char readbuf[256];
   apr_size_t readlen;
   apr_size_t writelen;
@@ -397,28 +383,6 @@
 }
 
 static svn_error_t *
-test_spillbuf_stream(apr_pool_t *pool)
-{
-  svn_spillbuf_t *buf = svn_spillbuf__create(8 /* blocksize */,
-                                             15 /* maxsize */,
-                                             pool);
-  svn_stream_t *stream = svn_stream__from_spillbuf(buf, pool);
-  return test_spillbuf__stream(pool, stream);
-}
-
-static svn_error_t *
-test_spillbuf_stream_spill_all(apr_pool_t *pool)
-{
-  svn_stream_t *stream = svn_stream__from_spillbuf_extended(
-                          8 /* blocksize */,
-                          15 /* maxsize */,
-                          TRUE /* delte on close */,
-                          TRUE /* spill all data */,
-                          NULL, pool);
-  return test_spillbuf__stream(pool, stream);
-}
-
-static svn_error_t *
 test_spillbuf__rwfile(apr_pool_t *pool, svn_spillbuf_t *buf)
 {
   SVN_ERR(svn_spillbuf__write(buf, "abcdef", 6, pool));
@@ -613,11 +577,7 @@
     SVN_TEST_PASS2(test_spillbuf_interleaving_spill_all,
                    "interleaving reads and writes (spill-all-data)"),
     SVN_TEST_PASS2(test_spillbuf_reader, "spill buffer reader test"),
-    SVN_TEST_PASS2(test_spillbuf_reader_spill_all,
-                   "spill buffer reader test (spill-all-data)"),
     SVN_TEST_PASS2(test_spillbuf_stream, "spill buffer stream test"),
-    SVN_TEST_PASS2(test_spillbuf_stream_spill_all,
-                   "spill buffer stream test (spill-all-data)"),
     SVN_TEST_PASS2(test_spillbuf_rwfile, "read/write spill file"),
     SVN_TEST_PASS2(test_spillbuf_rwfile_spill_all,
                    "read/write spill file (spill-all-data)"),
diff --git a/tools/dist/backport.pl b/tools/dist/backport.pl
index d04233f..62ee653 100755
--- a/tools/dist/backport.pl
+++ b/tools/dist/backport.pl
@@ -25,7 +25,7 @@
 use File::Basename qw/basename/;
 use File::Copy qw/copy move/;
 use File::Temp qw/tempfile/;
-use POSIX qw/ctermid/;
+use POSIX qw/ctermid strftime/;
 
 ############### Start of reading values from environment ###############
 
@@ -165,7 +165,9 @@
   my ($logmsg_fh, $logmsg_filename) = tempfile();
   my ($mergeargs, $pattern);
 
-  my $backupfile = "backport_pl.$$.tmp";
+  # Include the time so it's easier to find the interesting backups.
+  my $backupfile = strftime "backport_pl.%Y%m%d-%H%M%S.$$.tmp", localtime;
+  die if -s $backupfile;
 
   if ($entry{branch}) {
     my $vim_escaped_branch = 
@@ -177,22 +179,24 @@
                  $vim_escaped_branch;
     if ($SVNvsn >= 1_008_000) {
       $mergeargs = "$BRANCHES/$entry{branch}";
-      say $logmsg_fh "Merge the $entry{header}:";
+      say $logmsg_fh "Merge $entry{header}:";
     } else {
       $mergeargs = "--reintegrate $BRANCHES/$entry{branch}";
-      say $logmsg_fh "Reintegrate the $entry{header}:";
+      say $logmsg_fh "Reintegrate $entry{header}:";
     }
     say $logmsg_fh "";
   } elsif (@{$entry{revisions}}) {
     $pattern = '^ [*] \V' . 'r' . $entry{revisions}->[0];
-    $mergeargs = join " ", (map { "-c$_" } @{$entry{revisions}}), '^/subversion/trunk';
-    if (@{$entry{revisions}} > 1) {
-      say $logmsg_fh "Merge the $entry{header} from trunk:";
-      say $logmsg_fh "";
-    } else {
-      say $logmsg_fh "Merge r$entry{revisions}->[0] from trunk:";
-      say $logmsg_fh "";
-    }
+    $mergeargs = join " ",
+      ($entry{accept} ? "--accept=$entry{accept}" : ()),
+      (map { "-c$_" } @{$entry{revisions}}),
+      '--',
+      '^/subversion/trunk';
+    say $logmsg_fh
+      "Merge $entry{header} from trunk",
+      $entry{accept} ? ", with --accept=$entry{accept}" : "",
+      ":";
+    say $logmsg_fh "";
   } else {
     die "Don't know how to call $entry{header}";
   }
@@ -284,6 +288,7 @@
   my $raw = shift;
   my @lines = @_;
   my $depends;
+  my $accept;
   my (@revisions, @logsummary, $branch, @votes);
   # @lines = @_;
 
@@ -312,33 +317,62 @@
   unshift @votes, pop until $_[-1] =~ /^\s*Votes:/ or not defined $_[-1];
   pop;
 
-  # depends
-  # TODO: parse the value of this.
-  $depends = grep /^Depends:/, @_;
-
-  # branch
+  # depends, branch, notes
   while (@_) {
-    shift and next unless $_[0] =~ s/^\s*Branch:\s*//;
-    $branch = sanitize_branch (shift || shift || die "Branch header found without value");
+    given (shift) {
+      when (/^Depends:/) {
+        $depends++;
+      }
+      if (s/^Branch:\s*//) {
+        $branch = sanitize_branch ($_ || shift || die "Branch header found without value");
+      }
+      if (s/^Notes:\s*//) {
+        my $notes = $_;
+        $notes .= shift while @_ and $_[0] !~ /^\w/;
+        my %accepts = map { $_ => 1 } ($notes =~ /--accept[ =]([a-z-]+)/g);
+        given (scalar keys %accepts) {
+          when (0) { } 
+          when (1) { $accept = [keys %accepts]->[0]; } 
+          default  {
+            warn "Too many --accept values at '",
+                 logsummarysummary({ logsummary => [@logsummary] }),
+                 "'";
+          }
+        }
+      }
+    }
   }
 
   # Compute a header.
   my ($header, $id);
-  $header = "r$revisions[0] group" if @revisions;
-  $id = "r$revisions[0]"           if @revisions;
-  $header = "$branch branch"       if $branch;
-  $id = $branch                    if $branch;
-  warn "No header for [@lines]" unless $header;
+  if ($branch) {
+    $header = "the $branch branch";
+    $id = $branch;
+  } elsif (@revisions == 1) {
+    $header = "r$revisions[0]";
+    $id = "r$revisions[0]";
+  } elsif (@revisions) {
+    $header = "the r$revisions[0] group";
+    $id = "r$revisions[0]";
+  } else {
+    die "Entry '$raw' has neither revisions nor branch";
+  }
+  my $header_start = ($header =~ /^the/ ? ucfirst($header) : $header);
+
+  warn "Entry has both branch '$branch' and --accept=$accept specified\n"
+    if $branch and $accept;
 
   return (
     revisions => [@revisions],
     logsummary => [@logsummary],
     branch => $branch,
     header => $header,
+    header_start => $header_start,
     depends => $depends,
     id => $id,
     votes => [@votes],
     entry => [@lines],
+    accept => $accept,
     raw => $raw,
     digest => digest_string($raw),
   );
@@ -449,12 +483,12 @@
        ? (
          ( $_->{vote} eq 'edit'
            ? "Edit$words_edit the $_->{entry}->{id} entry"
-           : "Vote $_->{vote} on the $_->{entry}->{header}$words_vote"
+           : "Vote $_->{vote} on $_->{entry}->{header}$words_vote"
          )
          . "."
          )
       : # exists only in $approved
-        "Approve the $_->{entry}->{header}."
+        "Approve $_->{entry}->{header}."
       } @votesarray;
     (@sentences == 1)
     ? $sentences[0]
@@ -512,9 +546,9 @@
   warn "Warning summary\n";
   warn "===============\n";
   warn "\n";
-  for my $header (keys %ERRORS) {
-    my $title = logsummarysummary $ERRORS{$header}->[0];
-    warn "$header ($title): $ERRORS{$header}->[1]\n";
+  for my $id (keys %ERRORS) {
+    my $title = logsummarysummary $ERRORS{$id}->[0];
+    warn "$id ($title): $ERRORS{$id}->[1]\n";
   }
 }
 
@@ -580,33 +614,34 @@
                                       @conflicts),
                                      ']' x !!$#conflicts,
                                   ];
-          say STDERR "Conflicts merging the $entry{header}!";
+          say STDERR "Conflicts merging $entry{header}!";
           say STDERR "";
           say STDERR $output;
           system "$SVN diff -- @conflicts";
         } elsif (!@conflicts and $entry{depends}) {
           # Not a warning since svn-role may commit the dependency without
           # also committing the dependent in the same pass.
-          print "No conflicts merging $entry{id}, but conflicts were "
+          print "No conflicts merging $entry{header}, but conflicts were "
               ."expected ('Depends:' header set)\n";
         } elsif (@conflicts) {
-          say "Conflicts found merging $entry{id}, as expected.";
+          say "Conflicts found merging $entry{header}, as expected.";
         }
         revert;
       }
     }
   } elsif ($state->{$entry{digest}}) {
     print "\n\n";
-    say "Skipping the $entry{header} (remove $STATEFILE to reset):";
+    say "Skipping $entry{header} (remove $STATEFILE to reset):";
     say logsummarysummary \%entry;
   } else {
     # This loop is just a hack because 'goto' panics.  The goto should be where
     # the "next PROMPT;" is; there's a "last;" at the end of the loop body.
     PROMPT: while (1) {
     say "";
-    say "\n>>> The $entry{header}:";
+    say "\n>>> $entry{header_start}:";
     say join ", ", map { "r$_" } @{$entry{revisions}} if @{$entry{revisions}};
     say "$BRANCHES/$entry{branch}" if $entry{branch};
+    say "--accept=$entry{accept}" if $entry{accept};
     say "";
     say for @{$entry{logsummary}};
     say "";
@@ -632,6 +667,12 @@
                 or warn "diff failed ($?): $!";
               next;
             }
+            when (/^N/i) {
+              # fall through.
+            }
+            default {
+              next;
+            }
           }
           revert;
           next PROMPT;