[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Bug? Patch can duplicate file contents

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: 2007-10-05 20:14:35 CEST

Matt Southall wrote:
> Hi,
>
> I may have discovered a bug that I cannot find mention of when
> searching this list or the issue tracker. Apologies if this is
> already known about and/or is not a bug.
>
> TortoiseSVN 1.4.5, Build 10425 - 32 Bit , 2007/08/26 11:14:13
> Subversion 1.4.5,
> apr 0.9.12
> apr-iconv 0.9.7
> apr-utils 0.9.12
> berkeley db 4.4.20
> neon 0.26.3
> OpenSSL 0.9.8d 28 Sep 2006
> zlib 1.2.3
>
> 1) Check out a working copy of something
> 2) Create a new file in there but don't add or commit it.
> 3) Create a patch against the working copy.
> 4) Check out another working copy of the same thing.
> 5) Copy the new file from the first working copy to the second.
> 6) Apply the patch to the second working copy.
> 7) The new file in the second working copy now contains two
> concatenated copies of itself
>
> Admittedly, copying the file AND applying the patch was a bit daft,
> but I did it by mistake and there was no warning generated. I only
> noticed when I opened a file and found I had twice as many lines of
> code as I was expecting. Personally, I would have expected the patch
> to fail due to the target already existing.

The problem here is: the behavior is correct! I know that you think it's
wrong, but let me try to explain:

When you create a patch from an added file, *all* lines of that file are
marked as 'added' in the patch. Since the file is new (added), there's
also no so called context lines available (the ones you usually see
neither marked as removed or added, the ones which are not modified).
Now, when you apply that patch, TortoiseMerge can't see that all the
added lines shouldn't be added because there are no context lines in the
patch to compare to. And since all lines are marked as 'added' and
starting at line 0, TortoiseMerge inserts those added lines as requested
at position 0.

Oh, and error out if the target exists doesn't work either: a patch is
usually applied to *existing* files.

Yes, there are ways around which could improve the situation. But the
unified diff format (which is used for Subversion patches) doesn't have
a mark for 'whole file added' but deals only with lines. We have to live
with the limitations of the format.

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.net
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Fri Oct 5 20:14:53 2007

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.