You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Karl Fogel <kf...@red-bean.com> on 2008/09/08 02:40:45 UTC

Should propset on a schedule-delete target work?

While working on issue #3282, I discovered that the propset below did
not error:

   $ svn rm some_versioned_file
   $ svn propset pname pval some_versioned_file

Instead, it just set 'pname' to 'pval' on 'some_versioned_file'.

That seemed wrong!  If a file is scheduled for delete, should we
really allow further data-adding operations on it, like propset?
(This is tangentially related to issue #3282, by the way, though I
don't think it is necessary to change this behavior to fix #3282.)

So I came up with a patch (see end of this mail).  Unfortunately, my
patch causes three merge tests to fail:

   FAIL: merge_tests.py 61: merge fails if subtree is deleted on src
   FAIL: merge_tests.py 93: dont merge revs into a subtree that predate it
   FAIL: merge_tests.py 98: subtree merge source might not exist

Let's look at the first test (61) as an example.  It fails because it
gets a new error (the one I intended, though not one the test expects).
Here's the relevant excerpt from running 'merge_tests.py -v 61':

   --- Merging r3 through r5 into \
       'svn-test-work/working_copies/merge_tests-61/A_copy':
   D    svn-test-work/working_copies/merge_tests-61/A_copy/D/gamma
   subversion/libsvn_wc/props.c:2497: (apr_err=155023)
   svn: 'svn-test-work/working_copies/merge_tests-61/A_copy/D/gamma' \
        is scheduled for deletion; cannot set property 'svn:mergeinfo' on it

Hmmm.  There are a couple of different ways we could go from here:

   1) I could tweak my patch to move the schedule-delete check up to
      somewhere "higher" than libsvn_wc (maybe libsvn_client?  I'm not
      sure what entry point the mergeinfo code is using...)

   2) We could ask ourselves whether setting new mergeinfo on a
      schedule-delete target really makes sense.  If it doesn't, we
      could trap and clear the error, or maybe detect that the entry
      is schedule-delete and not attempt to set the mergeinfo in the
      first place.

   3) Something I haven't thought of.

I lean toward (2), but I'm not knowledgeable enough to be confident
that's the right way to go.  Thoughts?

My initial patch is below.

-Karl

[[[
Fix bug whereby a schedule-delete file could still receive propsets.
(Found while debugging issue #3282, but does not fix that issue.)

    #############################################################
    ###                                                       ###
    ###   NOTE: DO NOT COMMIT THIS PATCH, IT CAUSES TESTS TO  ###
    ###   FAIL (merge_tests.py 61, 93, 98).                   ###
    ###                                                       ###
    #############################################################

* subversion/libsvn_wc/props.c
  (svn_wc_prop_set2): Error out if the file is scheduled for deletion.

* subversion/tests/cmdline/prop_tests.py
  (propset_on_schedule_delete_target): New test.
  (test_list): Run it.
]]]

Index: subversion/libsvn_wc/props.c
===================================================================
--- subversion/libsvn_wc/props.c	(revision 32961)
+++ subversion/libsvn_wc/props.c	(working copy)
@@ -2493,6 +2493,12 @@
   /* Get the entry and name for this path. */
   SVN_ERR(svn_wc__entry_versioned(&entry, path, adm_access, FALSE, pool));
 
+  if (entry->schedule == svn_wc_schedule_delete)
+    return svn_error_createf
+      (SVN_ERR_WC_INVALID_SCHEDULE, NULL,
+       _("'%s' is scheduled for deletion; cannot set property '%s' on it"),
+       path, name);
+
   /* Get the access baton for the entry's directory. */
   if (entry->kind == svn_node_dir)
     SVN_ERR(svn_wc_adm_retrieve(&adm_access, adm_access, path, pool));

Index: subversion/tests/cmdline/prop_tests.py
===================================================================
--- subversion/tests/cmdline/prop_tests.py	(revision 32962)
+++ subversion/tests/cmdline/prop_tests.py	(working copy)
@@ -1679,7 +1679,18 @@
   svntest.actions.run_and_verify_svn(None, expected_out, [],
                                      'proplist', '-v', foo_url)
 
+def propset_on_schedule_delete_target(sbox):
+  "propset on schedule-delete target should fail"
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  iota_path = os.path.join(wc_dir, 'iota')
+  svntest.main.run_svn(None, 'rm', iota_path)
+  expected_stderr = ".*iota' is scheduled for deletion; " \
+                    + "cannot set property 'pname' on it.*"
+  svntest.actions.run_and_verify_svn(None, [], expected_stderr,
+                                     'propset', 'pname', 'pval', iota_path)
 
+
 ########################################################################
 # Run the tests
 
@@ -1717,6 +1728,7 @@
               SkipUnless(XFail(invalid_propvalues, svntest.main.is_ra_type_dav),
                     svntest.main.server_enforces_date_syntax),
               XFail(same_replacement_props),
+              propset_on_schedule_delete_target,
              ]
 
 if __name__ == '__main__':

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Should propset on a schedule-delete target work?

Posted by Karl Fogel <kf...@red-bean.com>.
Julian Foad <ju...@btopenworld.com> writes:
> On Sun, 2008-09-07 at 22:40 -0400, Karl Fogel wrote:
>> While working on issue #3282, I discovered that the propset below did
>> not error:
>> 
>>    $ svn rm some_versioned_file
>>    $ svn propset pname pval some_versioned_file
>> 
>> Instead, it just set 'pname' to 'pval' on 'some_versioned_file'.
>> 
>> That seemed wrong!  If a file is scheduled for delete, should we
>> really allow further data-adding operations on it, like propset?
>
> It's certainly wrong. I looked at this before (can't find any email I
> may have written about it though), and I think I found "svn"
> inconsistent: I think more than one of the property commands have this
> bug (pretending to read or write properties of a schedule-delete item)
> while the majority of commands correctly treat a schedule-delete state
> as a state that does not and cannot have properties at all.

Ed Price pointed out this catch-all issue to me:

   http://subversion.tigris.org/issues/show_bug.cgi?id=2526

(I've linked to this thread from the issue now.)

>> Hmmm.  There are a couple of different ways we could go from here:
>> 
>>    1) I could tweak my patch to move the schedule-delete check up to
>>       somewhere "higher" than libsvn_wc (maybe libsvn_client?  I'm not
>>       sure what entry point the mergeinfo code is using...)
>> 
>>    2) We could ask ourselves whether setting new mergeinfo on a
>>       schedule-delete target really makes sense.  If it doesn't, we
>>       could trap and clear the error, or maybe detect that the entry
>>       is schedule-delete and not attempt to set the mergeinfo in the
>>       first place.
>> 
>>    3) Something I haven't thought of.
>> 
>> I lean toward (2), but I'm not knowledgeable enough to be confident
>> that's the right way to go.  Thoughts?
>
> Yes, (2). I'm confident that any attempt to read or manipulate a
> property on a schedule-delete item is an error, at both the WC and
> client levels, regardless of what the current implementation does.

Oy.  Okay.  I want to finish issue #3282 first -- it's a genuine
wc-corruption bug, and takes precedence.  I'll try to look at #2526
afterwards, if no one beats me to it.

Thanks for the feedback, Julian

-Karl

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Should propset on a schedule-delete target work?

Posted by Ed Price <ed...@gmail.com>.
On Mon, Sep 8, 2008 at 12:25 PM, Julian Foad <ju...@btopenworld.com> wrote:
> On Sun, 2008-09-07 at 22:40 -0400, Karl Fogel wrote:
[...]
>> That seemed wrong!  If a file is scheduled for delete, should we
>> really allow further data-adding operations on it, like propset?
>
> It's certainly wrong. I looked at this before (can't find any email I
> may have written about it though), and I think I found "svn"
> inconsistent: I think more than one of the property commands have this
> bug (pretending to read or write properties of a schedule-delete item)
> while the majority of commands correctly treat a schedule-delete state
> as a state that does not and cannot have properties at all.

I believe your (Julian's) emails are in the thread starting here:

http://svn.haxx.se/dev/archive-2006-03/0519.shtml

and here's the issue:

http://subversion.tigris.org/issues/show_bug.cgi?id=2526

HTH :)
-Ed

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Should propset on a schedule-delete target work?

Posted by Julian Foad <ju...@btopenworld.com>.
On Sun, 2008-09-07 at 22:40 -0400, Karl Fogel wrote:
> While working on issue #3282, I discovered that the propset below did
> not error:
> 
>    $ svn rm some_versioned_file
>    $ svn propset pname pval some_versioned_file
> 
> Instead, it just set 'pname' to 'pval' on 'some_versioned_file'.
> 
> That seemed wrong!  If a file is scheduled for delete, should we
> really allow further data-adding operations on it, like propset?

It's certainly wrong. I looked at this before (can't find any email I
may have written about it though), and I think I found "svn"
inconsistent: I think more than one of the property commands have this
bug (pretending to read or write properties of a schedule-delete item)
while the majority of commands correctly treat a schedule-delete state
as a state that does not and cannot have properties at all.

> (This is tangentially related to issue #3282, by the way, though I
> don't think it is necessary to change this behavior to fix #3282.)
> 
> So I came up with a patch (see end of this mail).  Unfortunately, my
> patch causes three merge tests to fail:
> 
>    FAIL: merge_tests.py 61: merge fails if subtree is deleted on src
>    FAIL: merge_tests.py 93: dont merge revs into a subtree that predate it
>    FAIL: merge_tests.py 98: subtree merge source might not exist
> 
> Let's look at the first test (61) as an example.  It fails because it
> gets a new error (the one I intended, though not one the test expects).
> Here's the relevant excerpt from running 'merge_tests.py -v 61':
> 
>    --- Merging r3 through r5 into \
>        'svn-test-work/working_copies/merge_tests-61/A_copy':
>    D    svn-test-work/working_copies/merge_tests-61/A_copy/D/gamma
>    subversion/libsvn_wc/props.c:2497: (apr_err=155023)
>    svn: 'svn-test-work/working_copies/merge_tests-61/A_copy/D/gamma' \
>         is scheduled for deletion; cannot set property 'svn:mergeinfo' on it
> 
> Hmmm.  There are a couple of different ways we could go from here:
> 
>    1) I could tweak my patch to move the schedule-delete check up to
>       somewhere "higher" than libsvn_wc (maybe libsvn_client?  I'm not
>       sure what entry point the mergeinfo code is using...)
> 
>    2) We could ask ourselves whether setting new mergeinfo on a
>       schedule-delete target really makes sense.  If it doesn't, we
>       could trap and clear the error, or maybe detect that the entry
>       is schedule-delete and not attempt to set the mergeinfo in the
>       first place.
> 
>    3) Something I haven't thought of.
> 
> I lean toward (2), but I'm not knowledgeable enough to be confident
> that's the right way to go.  Thoughts?

Yes, (2). I'm confident that any attempt to read or manipulate a
property on a schedule-delete item is an error, at both the WC and
client levels, regardless of what the current implementation does.

- Julian



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org