You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Ed Price <ed...@gmail.com> on 2006/03/05 20:45:50 UTC

[BUG] Manual conflict removal leads to spurious revert report

This bug has bitten me three times in the last month or so.  After the
second time, I was on the lookout for it...  Finally, the third time,
I had a pre-revert WC snapshot.  I've reduced it to the minimal
reproduction recipe at the end of this message.

I think it's a moderately serious bug because it undermines the user's
trust in Subversion -- in the reliability of "svn status" and "svn
diff" in particular.  When "svn status" and "svn diff" report a
certain set of files as changed, but then "svn revert" reports that it
has reverted an additional file, it is very surprising to the user.
Even though it turns out (as I know now) there is no data loss, it
makes the user *think* there has been data loss.  I certainly got a
nasty jolt the first two times it happened to me.  Of course, since
there's no way to "undo" the revert, the user can't go back and see
what was changed by the unexpected revert.

In fact, revert is just wrongly reporting that it reverted something
when it did not.

This appears to be the result of the identification of "something has
been reverted" with "something has been written to the log" in
"revert_admin_things".  In particular, the removal of the three
conflict entries/files is written to the log, but this does *not*
constitute a reversion.

It seems to me that a reasonable fix would be for revert to output
nothing in the case where it made no changes to the actual file but
maybe removed the conflict info from the entries file, or even removed
the extra suffixed conflict files themselves.  Alternatively, if
people feel that it should output something, it could mention that it
did that "conflict cleanup" but with a different message like "Removed
conflict file foo.r123" instead of "Reverted foo".  Clearly the
message is wrong, at least.  (For some more babbling about how I think
things should work see the comments at the end of the script below.)

I've verified the bug against Fedora Core 4 svn 1.2.3, and trunk
r16714.

A simplistic fix for this bug is to just rip out the "loggy remove" of
the conflict entries/files from libsvn_wc's "revert_admin_things".  I
tried that, and it did fix the bug, and "make check" still passed, but
I assume it's not The Right Thing :)

-- cut here --
Index: subversion/libsvn_wc/adm_ops.c
===================================================================
--- subversion/libsvn_wc/adm_ops.c      (revision 18714)
+++ subversion/libsvn_wc/adm_ops.c      (working copy)
@@ -1497,6 +1497,7 @@
         }
     }

+#if 0
   /* Remove conflict state (and conflict files), if any.
      Handle the three possible text conflict files. */
   if (entry->conflict_old)
@@ -1522,6 +1523,7 @@
       SVN_ERR(svn_wc__loggy_remove(&log_accum, adm_access,
                                    entry->conflict_wrk, pool));
     }
+#endif

   /* Remove the prej-file if the entry lists one (and it exists) */
   if (entry->prejfile)
-- cut here --

I briefly looked at the testsuite code but did not immediately
understand how to write a testcase for this.  I don't know how long it
would take me to do that.

(Also I think a testcase which prevents my bogus patch from passing
the testsuite would be nice too.)

Finally, please note that the book does say (in footnote 4 of the 1.1
version, footnote 5 of the 1.2 nightly, chapter 3) that one *can*
manually remove the conflict files -- which is what I've always done;
I have never once used "svn resolved", nor do I think I should have
to!

Shall I file this as an issue?  Any hints as to how to proceed are
welcome.

Thanks,
-Ed

#!/bin/bash
set -ev

svn --version

svnadmin create repos

svn co file://`pwd`/repos wc
touch wc/foo
svn add wc/foo
svn ci wc -m ""
svn up wc

echo "### Cause a conflict."                           > /dev/null

svn co file://`pwd`/repos wc2
echo "1" > wc/foo
echo "2" > wc2/foo
svn ci wc2 -m ""
svn up wc

echo "### Resolve conflict 'manually'."                > /dev/null

echo "2" > wc/foo
rm wc/foo.*

svn st wc
svn diff wc

echo "### Status and diff agree: No changes."          > /dev/null
echo "### So revert should not revert anything."       > /dev/null
echo "### (We'll snapshot WC here.)"                   > /dev/null

cp -pR wc wc.save

echo "### Revert (nothing to do, right?)"              > /dev/null

svn revert -R wc

echo "### Did it say that it reverted something?"      > /dev/null
echo "### If so, the user panics..."                   > /dev/null
echo "### What was reverted??  Who knows!"             > /dev/null
echo "### Luckily, we happen to have a snapshot..."    > /dev/null
echo "### So let's see what really did change:"        > /dev/null

diff -ur wc.save wc

# It's interesting that only "svn revert" cleans out those conflict
# markers in the entries file.
#
# "svn cleanup" should also clean up these conflict entries.  Its help
# text says "cleanup: Recursively clean up the working copy, removing
# locks, resuming unfinished operations, etc.".  I tried adding "svn
# cleanup wc" just before "svn revert -R wc" but it did not affect the
# result, ie it did not cleanup the conflict entries.
#
# Perhaps "svn up" should do it too.  That would be ideal because, at
# least for me, it is a very frequently executed command, moreso than
# 'revert' and much moreso than 'cleanup'.
#
# Neither "svn status" nor "svn diff" should do it because they should
# be strictly read-only.  (Or if they did try to do it, they should
# silently ignore "harmless" failure to update the entries file, to
# avoid regression against a truly read-only WC.)
#
# I wonder if there could be other bugs due to the leftover conflict
# info in there?  I did try producing another conflict with the
# previous conflict markers still in the file, but it didn't cause any
# problem AFAICT; the conflict markers were updated properly for the
# second conflict.

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


Re: [BUG] Manual conflict removal leads to spurious revert report

Posted by Ed Price <ed...@gmail.com>.
Oops, I forgot to fill in the issue number (2517) in the patch:

+# Test for issue ### ???

If the patch is otherwise good please tweak that?
Otherwise I'll include it in the next rev!
Thanks,
-Ed

On 3/6/06, Ed Price <ed...@gmail.com> wrote:
> > +1 on filing this as an issue (although I think I agree with you
> > that your quick-n-dirty patch is not The Right Fix :-) ).  Can you
> > make sure the issue links back to this email thread, so readers of
> > the issue can find the discussion?
>
> Done.
>
> http://subversion.tigris.org/issues/show_bug.cgi?id=2517
>
> I wasn't sure whether to copy the original message into the issue.  I
> just wrote a short summary instead.
>
> > I think the fix is just a Simple Matter Of Programming, but I don't
> > know where to actually make the changes.  One useful contribution
> > would be an "XFAIL" regression for it, since that can be done right
> > now and reduces the burden on whoever eventually fixes the bug...
>
> I haven't attempted that SMOP yet; it does seem rather awkward...
>
> Meanwhile I've attached a testcase.  Please review/commit/whatever :)
>
> Thanks,
> -Ed
>
> [[[
> Test case for issue #2517.
>
>  * subversion/tests/cmdline/svntest/main.py
>    (file_write): New function.
>
>  * subversion/tests/cmdline/revert_tests.py
>    (revert_after_manual_conflict_resolution): New test.
>    (test_list): Add new test (as XFail).
> ]]]
>
>
>

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


Re: [BUG] Manual conflict removal leads to spurious revert report

Posted by Branko Čibej <br...@xbc.nu>.
Ed Price wrote:
>> This change can leave *reverted in an indeterminate state. That changed
>>     
>
> Not really.  This is not a public API and the function is only called from
> svn_wc_revert2, which does initialize the reverted flag to FALSE.
>   
Ah, good, I didn't notice that.

>> the behaviour of the function, since it always set *reverted to either
>> TRUE or FALSE before (unless it returned an error). I haven't checked if
>> that actually created problems, but I suspect it's wrong that *reverted
>> never gets set to FALSE with this patch.
>>     
>
> That's a reasonable concern but it is actually ok.
>
> The previous code would overwrite the initial value, which isn't
> necessarily correct either.  Note that the comment on the function
> says that it sets the flag *if something is reverted*.  It does not say
> that it sets the flag according to *whether something is reverted*.
> So now the comment is correct :)
>   
Heh. It would be good if the comment was a bit more specific, though.

-- Brane


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

Re: [BUG] Manual conflict removal leads to spurious revert report

Posted by Ed Price <ed...@gmail.com>.
> This change can leave *reverted in an indeterminate state. That changed

Not really.  This is not a public API and the function is only called from
svn_wc_revert2, which does initialize the reverted flag to FALSE.

> the behaviour of the function, since it always set *reverted to either
> TRUE or FALSE before (unless it returned an error). I haven't checked if
> that actually created problems, but I suspect it's wrong that *reverted
> never gets set to FALSE with this patch.

That's a reasonable concern but it is actually ok.

The previous code would overwrite the initial value, which isn't
necessarily correct either.  Note that the comment on the function
says that it sets the flag *if something is reverted*.  It does not say
that it sets the flag according to *whether something is reverted*.
So now the comment is correct :)

Thanks for reviewing!  Any other comments?
-Ed

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


Re: [BUG] Manual conflict removal leads to spurious revert report

Posted by Branko Čibej <br...@xbc.nu>.
Ed Price wrote:
> Index: subversion/libsvn_wc/adm_ops.c
> ===================================================================
> --- subversion/libsvn_wc/adm_ops.c	(revision 18758)
> +++ subversion/libsvn_wc/adm_ops.c	(working copy)
> @@ -1384,6 +1384,7 @@
>            SVN_ERR(svn_wc__loggy_remove
>                    (&log_accum, adm_access,
>                     svn_path_is_child(adm_path, rprop, pool), pool));
> +          *reverted = TRUE;
>          }
>      }
>  
> @@ -1426,6 +1427,7 @@
>      {
>        flags |= SVN_WC__ENTRY_MODIFY_COPIED;
>        tmp_entry.copied = FALSE;
> +      *reverted = TRUE;
>      }
>  
>    /* Deal with the contents. */
> @@ -1494,6 +1496,8 @@
>            SVN_ERR(svn_wc__loggy_set_entry_timestamp_from_wc
>                    (&log_accum, adm_access, name, SVN_WC__ENTRY_ATTR_TEXT_TIME,
>                     pool));
> +
> +          *reverted = TRUE;
>          }
>      }
>  
> @@ -1537,6 +1541,7 @@
>      {
>        flags |= SVN_WC__ENTRY_MODIFY_SCHEDULE;
>        tmp_entry.schedule = svn_wc_schedule_normal;
> +      *reverted = TRUE;
>      }
>  
>    SVN_ERR(svn_wc__loggy_entry_modify(&log_accum, adm_access, name,
> @@ -1547,13 +1552,7 @@
>      {
>        SVN_ERR(svn_wc__write_log(adm_access, 0, log_accum, pool));
>        SVN_ERR(svn_wc__run_log(adm_access, NULL, pool));
> -
> -      *reverted = TRUE;
>      }
> -  else
> -    {
> -      *reverted = FALSE;
> -    }
>  
>    return SVN_NO_ERROR;
>  }
>   
This change can leave *reverted in an indeterminate state. That changed 
the behaviour of the function, since it always set *reverted to either 
TRUE or FALSE before (unless it returned an error). I haven't checked if 
that actually created problems, but I suspect it's wrong that *reverted 
never gets set to FALSE with this patch.

-- Brane


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

Re: [BUG] Manual conflict removal leads to spurious revert report

Posted by Ed Price <ed...@gmail.com>.
> > I think the fix is just a Simple Matter Of Programming, but I don't
> > know where to actually make the changes.  One useful contribution
> > would be an "XFAIL" regression for it, since that can be done right
> > now and reduces the burden on whoever eventually fixes the bug...
>
> I haven't attempted that SMOP yet; it does seem rather awkward...

After a couple false starts I think I have a decent fix.
New patch attached, including both bugfix and testcase.

I await your feedback!
Thanks,
-Ed

[[[
Fix for issue #2517 (manual conflict removal leads to spurious
revert report).

 * subversion/libsvn_wc/adm_ops.c
   (revert_admin_things): Set '*reverted' only on real revert.

 * subversion/tests/cmdline/svntest/main.py
   (file_write): New function.

 * subversion/tests/cmdline/revert_tests.py
   (revert_after_manual_conflict_resolution): New test.
   (test_list): Add new test.
]]]

Re: [BUG] Manual conflict removal leads to spurious revert report

Posted by Ed Price <ed...@gmail.com>.
> +1 on filing this as an issue (although I think I agree with you
> that your quick-n-dirty patch is not The Right Fix :-) ).  Can you
> make sure the issue links back to this email thread, so readers of
> the issue can find the discussion?

Done.

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

I wasn't sure whether to copy the original message into the issue.  I
just wrote a short summary instead.

> I think the fix is just a Simple Matter Of Programming, but I don't
> know where to actually make the changes.  One useful contribution
> would be an "XFAIL" regression for it, since that can be done right
> now and reduces the burden on whoever eventually fixes the bug...

I haven't attempted that SMOP yet; it does seem rather awkward...

Meanwhile I've attached a testcase.  Please review/commit/whatever :)

Thanks,
-Ed

[[[
Test case for issue #2517.

 * subversion/tests/cmdline/svntest/main.py
   (file_write): New function.

 * subversion/tests/cmdline/revert_tests.py
   (revert_after_manual_conflict_resolution): New test.
   (test_list): Add new test (as XFail).
]]]

Re: [BUG] Manual conflict removal leads to spurious revert report

Posted by kf...@collab.net.
"Ed Price" <ed...@gmail.com> writes:
> Shall I file this as an issue?  Any hints as to how to proceed are
> welcome.

+1 on filing this as an issue (although I think I agree with you that
your quick-n-dirty patch is not The Right Fix :-) ).  Can you make
sure the issue links back to this email thread, so readers of the
issue can find the discussion?

I think the fix is just a Simple Matter Of Programming, but I don't
know where to actually make the changes.  One useful contribution
would be an "XFAIL" regression for it, since that can be done right
now and reduces the burden on whoever eventually fixes the bug...

-Karl

> Thanks,
> -Ed
> 
> #!/bin/bash
> set -ev
> 
> svn --version
> 
> svnadmin create repos
> 
> svn co file://`pwd`/repos wc
> touch wc/foo
> svn add wc/foo
> svn ci wc -m ""
> svn up wc
> 
> echo "### Cause a conflict."                           > /dev/null
> 
> svn co file://`pwd`/repos wc2
> echo "1" > wc/foo
> echo "2" > wc2/foo
> svn ci wc2 -m ""
> svn up wc
> 
> echo "### Resolve conflict 'manually'."                > /dev/null
> 
> echo "2" > wc/foo
> rm wc/foo.*
> 
> svn st wc
> svn diff wc
> 
> echo "### Status and diff agree: No changes."          > /dev/null
> echo "### So revert should not revert anything."       > /dev/null
> echo "### (We'll snapshot WC here.)"                   > /dev/null
> 
> cp -pR wc wc.save
> 
> echo "### Revert (nothing to do, right?)"              > /dev/null
> 
> svn revert -R wc
> 
> echo "### Did it say that it reverted something?"      > /dev/null
> echo "### If so, the user panics..."                   > /dev/null
> echo "### What was reverted??  Who knows!"             > /dev/null
> echo "### Luckily, we happen to have a snapshot..."    > /dev/null
> echo "### So let's see what really did change:"        > /dev/null
> 
> diff -ur wc.save wc
> 
> # It's interesting that only "svn revert" cleans out those conflict
> # markers in the entries file.
> #
> # "svn cleanup" should also clean up these conflict entries.  Its help
> # text says "cleanup: Recursively clean up the working copy, removing
> # locks, resuming unfinished operations, etc.".  I tried adding "svn
> # cleanup wc" just before "svn revert -R wc" but it did not affect the
> # result, ie it did not cleanup the conflict entries.
> #
> # Perhaps "svn up" should do it too.  That would be ideal because, at
> # least for me, it is a very frequently executed command, moreso than
> # 'revert' and much moreso than 'cleanup'.
> #
> # Neither "svn status" nor "svn diff" should do it because they should
> # be strictly read-only.  (Or if they did try to do it, they should
> # silently ignore "harmless" failure to update the entries file, to
> # avoid regression against a truly read-only WC.)
> #
> # I wonder if there could be other bugs due to the leftover conflict
> # info in there?  I did try producing another conflict with the
> # previous conflict markers still in the file, but it didn't cause any
> # problem AFAICT; the conflict markers were updated properly for the
> # second conflict.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
> 
> 

-- 

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