You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2012/02/27 03:30:38 UTC

svn commit: r1293998 - /subversion/trunk/subversion/libsvn_repos/replay.c

Author: danielsh
Date: Mon Feb 27 02:30:37 2012
New Revision: 1293998

URL: http://svn.apache.org/viewvc?rev=1293998&view=rev
Log:
Fix issue #4121: svnsync of a copy followed by delete of was-unreadable child.

* subversion/libsvn_repos/replay.c
  (was_readable): New helper.
  (path_driver_cb_func):
    Use new helper to determine whether to replay or discard deletions.

Modified:
    subversion/trunk/subversion/libsvn_repos/replay.c

Modified: subversion/trunk/subversion/libsvn_repos/replay.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/replay.c?rev=1293998&r1=1293997&r2=1293998&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/replay.c (original)
+++ subversion/trunk/subversion/libsvn_repos/replay.c Mon Feb 27 02:30:37 2012
@@ -352,6 +352,65 @@ is_within_base_path(const char *path, co
   return FALSE;
 }
 
+/* Given PATH deleted under ROOT, return in READABLE whether the path was
+   readable prior to the deletion.  Consult COPIES (a stack of 'struct
+   copy_info') and AUTHZ_READ_FUNC. */
+static svn_error_t *
+was_readable(svn_boolean_t *readable,
+             svn_fs_root_t *root,
+             const char *path,
+             apr_array_header_t *copies,
+             svn_repos_authz_func_t authz_read_func,
+             void *authz_read_baton,
+             apr_pool_t *result_pool,
+             apr_pool_t *scratch_pool)
+{
+  svn_fs_root_t *inquire_root;
+  const char *inquire_path;
+  struct copy_info *info;
+  const char *relpath;
+
+  /* Short circuit. */
+  if (! authz_read_func)
+    {
+      *readable = TRUE;
+      return SVN_NO_ERROR;
+    }
+
+  if (copies->nelts != 0)
+    info = &APR_ARRAY_IDX(copies, copies->nelts - 1, struct copy_info);
+
+  /* Are we under a copy? */
+  if (info && (relpath = svn_relpath_skip_ancestor(info->path, path)))
+    {
+      SVN_ERR(svn_fs_revision_root(&inquire_root, svn_fs_root_fs(root),
+                                   info->copyfrom_rev, scratch_pool));
+      inquire_path = svn_fspath__join(info->copyfrom_path, relpath,
+                                      scratch_pool);
+    }
+  else
+    {
+      /* Compute the revision that ROOT is based on.  (Note that ROOT is not
+         r0's root, since this function is only called for deletions.)
+         ### Need a more succinct way to express this */
+      svn_revnum_t inquire_rev = SVN_INVALID_REVNUM;
+      if (svn_fs_is_txn_root(root))
+        inquire_rev = svn_fs_txn_root_base_revision(root);
+      if (svn_fs_is_revision_root(root))
+        inquire_rev =  svn_fs_revision_root_revision(root)-1;
+      SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(inquire_rev));
+
+      SVN_ERR(svn_fs_revision_root(&inquire_root, svn_fs_root_fs(root),
+                                   inquire_rev, scratch_pool));
+      inquire_path = path;
+    }
+
+  SVN_ERR(authz_read_func(readable, inquire_root, inquire_path,
+                          authz_read_baton, result_pool));
+
+  return SVN_NO_ERROR;
+}
+
 /* Initialize COPYFROM_ROOT, COPYFROM_PATH, and COPYFROM_REV with the
    revision root, fspath, and revnum of the copyfrom of CHANGE, which
    corresponds to PATH under ROOT.  If the copyfrom info is valid
@@ -469,8 +528,18 @@ path_driver_cb_func(void **dir_baton,
 
   /* Handle any deletions. */
   if (do_delete)
-    SVN_ERR(editor->delete_entry(edit_path, SVN_INVALID_REVNUM,
-                                 parent_baton, pool));
+    {
+      svn_boolean_t readable;
+
+      /* Issue #4121: delete under under a copy, of a path that was unreadable
+         at its pre-copy location. */
+      SVN_ERR(was_readable(&readable, root, edit_path, cb->copies,
+                            cb->authz_read_func, cb->authz_read_baton,
+                            pool, pool));
+      if (readable)
+        SVN_ERR(editor->delete_entry(edit_path, SVN_INVALID_REVNUM,
+                                     parent_baton, pool));
+    }
 
   /* Fetch the node kind if it makes sense to do so. */
   if (! do_delete || do_add)



Re: svn commit: r1293998 - /subversion/trunk/subversion/libsvn_repos/replay.c

Posted by Philip Martin <ph...@codematters.co.uk>.
Philip Martin <ph...@wandisco.com> writes:

> Daniel Shahaf <da...@elego.de> writes:
>
>> I am also attaching an attempt at an equivalent Python test.  For me the
>> Python test passes against r1293997.  Can anyone spot the difference?
>
> The Python test uses ra_local to access the source repo, so no authz.

No, I'm wrong. ra_local is used for the destination.

-- 
Philip

Re: svn commit: r1293998 - /subversion/trunk/subversion/libsvn_repos/replay.c

Posted by Philip Martin <ph...@wandisco.com>.
Daniel Shahaf <da...@elego.de> writes:

> I am also attaching an attempt at an equivalent Python test.  For me the
> Python test passes against r1293997.  Can anyone spot the difference?

The Python test uses ra_local to access the source repo, so no authz.

-- 
uberSVN: Apache Subversion Made Easy
http://www.uberSVN.com

Re: svn commit: r1293998 - /subversion/trunk/subversion/libsvn_repos/replay.c

Posted by Daniel Shahaf <da...@elego.de>.
Julian Foad wrote on Mon, Feb 27, 2012 at 10:19:35 +0000:
> Daniel Shahaf wrote:
> >>  danielsh@apache.org wrote:
> >>  > Fix issue #4121: svnsync of a copy followed by delete of 
> >> > was-unreadable child.
> >> >  http://subversion.tigris.org/issues/show_bug.cgi?id=4121
> >>  > 
> >>  > * subversion/libsvn_repos/replay.c
> >>  >   (was_readable): New helper.
> >>  >   (path_driver_cb_func):
> >>  >     Use new helper to determine whether to replay or discard 
> >> > deletions.
> >> 
> >>  I've been trying to write a regression test for this, but got stuck
> >>  converting my shell script to Python.
> >> 
> >>  I have a shellscript (attached) that reproduces the issue for me: with
> >>  r1293997 it outputs
> >> 
> >>      Copied properties for revision 1.
> >>      subversion/libsvn_ra_svn/client.c:2440: (apr_err=210008)
> >>      svnsync: E210008: Error while replaying commit
> >>      zsh: exit 1     ./01repro
> >> 
> >>  I am also attaching an attempt at an equivalent Python test.  For me the
> >>  Python test passes against r1293997.  Can anyone spot the difference?
> 
> Your Python test fails against r1293997 and passes against r1293998 for me.  The fail against r1293997 looks like:
> 
> [...]
...
> /home/julianfoad/src/subversion-c/subversion/libsvn_ra_neon/replay.c:181: (apr_err=160028)
...
> svnsync: E160028: '/branch/A' is out of date
> [...]
> 
> - Julian

Thanks for your help.  Between this and discussions with philipm on IRC,
we've tracked down the problem to a difference in svnserve/mod_dav_svn's
expectations from authz files which the test suite didn't account for.
(More precisely, teh test I modeled my new test after was in itself
silently broken; the other svnsync_tests were fine.)

All fixed now, and I'll see about updating docs too.

Thanks to you and Philip for the help.

Daniel


Re: svn commit: r1293998 - /subversion/trunk/subversion/libsvn_repos/replay.c

Posted by Julian Foad <ju...@btopenworld.com>.
Daniel Shahaf wrote:
>>  danielsh@apache.org wrote:
>>  > Fix issue #4121: svnsync of a copy followed by delete of 
>> > was-unreadable child.
>> >  http://subversion.tigris.org/issues/show_bug.cgi?id=4121
>>  > 
>>  > * subversion/libsvn_repos/replay.c
>>  >   (was_readable): New helper.
>>  >   (path_driver_cb_func):
>>  >     Use new helper to determine whether to replay or discard 
>> > deletions.
>> 
>>  I've been trying to write a regression test for this, but got stuck
>>  converting my shell script to Python.
>> 
>>  I have a shellscript (attached) that reproduces the issue for me: with
>>  r1293997 it outputs
>> 
>>      Copied properties for revision 1.
>>      subversion/libsvn_ra_svn/client.c:2440: (apr_err=210008)
>>      svnsync: E210008: Error while replaying commit
>>      zsh: exit 1     ./01repro
>> 
>>  I am also attaching an attempt at an equivalent Python test.  For me the
>>  Python test passes against r1293997.  Can anyone spot the difference?

Your Python test fails against r1293997 and passes against r1293998 for me.  The fail against r1293997 looks like:

[...]
CMD: /home/julianfoad/src/subversion-c/bin/svnsync synchronize file:///nobackup/home/julianfoad/build/subversion-c/subversion/tests/cmdline/svn-test-work/repositories/copy-delete-unreadable-child-1 --username jrandom --password rayjandom --config-dir /nobackup/home/julianfoad/build/subversion-c/subversion/tests/cmdline/svn-test-work/local_tmp/config exited with 1
<TIME = 0.337972>
Transmitting file data .
Committed revision 1.
Copied properties for revision 1.
/home/julianfoad/src/subversion-c/subversion/svnsync/main.c:1384: (apr_err=160028)
/home/julianfoad/src/subversion-c/subversion/svnsync/main.c:1330: (apr_err=160028)
/home/julianfoad/src/subversion-c/subversion/libsvn_ra/ra_loader.c:1184: (apr_err=160028)
/home/julianfoad/src/subversion-c/subversion/libsvn_ra_neon/util.c:1324: (apr_err=160028)
/home/julianfoad/src/subversion-c/subversion/libsvn_ra_neon/util.c:1557: (apr_err=160028)
/home/julianfoad/src/subversion-c/subversion/libsvn_ra_neon/replay.c:181: (apr_err=160028)
/home/julianfoad/src/subversion-c/subversion/libsvn_repos/commit.c:136: (apr_err=160028)
/home/julianfoad/src/subversion-c/subversion/libsvn_repos/commit.c:136: (apr_err=160028)
svnsync: E160028: '/branch/A' is out of date
[...]

- Julian

Re: svn commit: r1293998 - /subversion/trunk/subversion/libsvn_repos/replay.c

Posted by Daniel Shahaf <da...@elego.de>.
And with the right MIME types...

Daniel Shahaf wrote on Mon, Feb 27, 2012 at 04:41:42 +0200:
> danielsh@apache.org wrote on Mon, Feb 27, 2012 at 02:30:38 -0000:
> > Author: danielsh
> > Date: Mon Feb 27 02:30:37 2012
> > New Revision: 1293998
> > 
> > URL: http://svn.apache.org/viewvc?rev=1293998&view=rev
> > Log:
> > Fix issue #4121: svnsync of a copy followed by delete of was-unreadable child.
> http://subversion.tigris.org/issues/show_bug.cgi?id=4121
> > 
> > * subversion/libsvn_repos/replay.c
> >   (was_readable): New helper.
> >   (path_driver_cb_func):
> >     Use new helper to determine whether to replay or discard deletions.
> 
> I've been trying to write a regression test for this, but got stuck
> converting my shell script to Python.
> 
> I have a shellscript (attached) that reproduces the issue for me: with
> r1293997 it outputs
> 
>     Copied properties for revision 1.
>     subversion/libsvn_ra_svn/client.c:2440: (apr_err=210008)
>     svnsync: E210008: Error while replaying commit
>     zsh: exit 1     ./01repro
> 
> I am also attaching an attempt at an equivalent Python test.  For me the
> Python test passes against r1293997.  Can anyone spot the difference?
> 
> Thanks,
> 
> Daniel

Re: svn commit: r1293998 - /subversion/trunk/subversion/libsvn_repos/replay.c

Posted by Daniel Shahaf <da...@elego.de>.
danielsh@apache.org wrote on Mon, Feb 27, 2012 at 02:30:38 -0000:
> Author: danielsh
> Date: Mon Feb 27 02:30:37 2012
> New Revision: 1293998
> 
> URL: http://svn.apache.org/viewvc?rev=1293998&view=rev
> Log:
> Fix issue #4121: svnsync of a copy followed by delete of was-unreadable child.
http://subversion.tigris.org/issues/show_bug.cgi?id=4121
> 
> * subversion/libsvn_repos/replay.c
>   (was_readable): New helper.
>   (path_driver_cb_func):
>     Use new helper to determine whether to replay or discard deletions.

I've been trying to write a regression test for this, but got stuck
converting my shell script to Python.

I have a shellscript (attached) that reproduces the issue for me: with
r1293997 it outputs

    Copied properties for revision 1.
    subversion/libsvn_ra_svn/client.c:2440: (apr_err=210008)
    svnsync: E210008: Error while replaying commit
    zsh: exit 1     ./01repro

I am also attaching an attempt at an equivalent Python test.  For me the
Python test passes against r1293997.  Can anyone spot the difference?

Thanks,

Daniel