You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Alexey Yudichev <ay...@newmail.ru> on 2006/01/06 23:03:20 UTC
Merge of deleted file with a modified one
I am preparing a subversion demo for company developers and
architects. The demo includes merge with some files changed, some
deleted, some moved etc.
I discovered that if I
1) create a branch from trunk via svn copy
2) delete a file in branch and commit
3) modify the same file in trunk and commit
4) merge branch to trunk
I get the file deleted. Which means I lose my changes made in trunk. A
deletion, according to universal diff view, is equivalent to removal
of all lines of the file. I wonder if merge is diff-and-apply, how can
this diff cleanly apply to a modified file? Not all lines are the same
any more, there should be a conflict!
Is it a normal behaviour or am I missing something?
P.S. If I delete the file in the trunk and modify it in the branch, I
get "missing file ..." error, which is better than nothing and alerts
the user that there is a conflict.
Will be delighted to hear any comments. Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: Re[6]: Merge of deleted file with a modified one
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 1/8/06, Alexey Yudichev <ay...@newmail.ru> wrote:
> I am sorry I still don't understand the difference. Assume a file was renamed
> in the branch and modified in the trunk. During merge the old file
> name will be deleted locally and scheduled for deletion in repository
> (ignoring changes made in the trunk) and its copy will be added under
> a new name. This copy will not contain changes made in trunk. So
> again, the changes are silently lost.
I totally agree with you that in the rename case that is the RIGHT
thing to do, the problem is that we can't tell the difference between
the rename case and an actual delete. If you really meant to delete
the file, then the subsequent modifications to it on the trunk are
pointless, and a conflict will just slow things down. Why should we
break that functionality when what we really want is to add the
underlying framework to allow us to actually detect the case where we
really need a conflict (or actually, where we want to be able to merge
the trunk changes into the renamed file or something). If we have
actual renames that gives us the ability to have the correct behavior
here, without that we can only fix this in half-assed ways that aren't
satisfying in all cases.
-garrett
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re[6]: Merge of deleted file with a modified one
Posted by Alexey Yudichev <ay...@newmail.ru>.
> Sure, it makes sense for your particular use case, but not for all use
> cases, that's what I'm trying to say. In order to know for sure if we
> should consider this a conflict or not Subversion really needs some
> concept of a "rename", as a distinct operation from "copy and delete".
> If something was renamed, then yes, I'm perfectly willing to
> stipulare that something should be done to ensure that changes made to
> it on the trunk persist after the merge, but Subversion doesn't do
> that right now, it copies it and deletes it, which means it's
> impossible to tell the difference between a "I deleted it because we
> don't need it anymore" and a "I renamed it".
I am sorry I still don't understand the difference. Assume a file was renamed
in the branch and modified in the trunk. During merge the old file
name will be deleted locally and scheduled for deletion in repository
(ignoring changes made in the trunk) and its copy will be added under
a new name. This copy will not contain changes made in trunk. So
again, the changes are silently lost.
>> >> Couple of our developers called this feature a show stopper for
>> >> employing subversion in our company.
>>
>> > Out of curiosity, do you know of another system that avoids this
>> > issue? If so, what kind of behavior does it have?
>> I am curious myself how it is done in CVS. If it isn't any better I
>> would be satisfied, because this would sound like an argument :)
> CVS doesn't handle it at all, as CVS doesn't have the ability to
> rename files ;-)
Just tried the equivalent scenario with CVS (see below). CVS perfectly
recognises the situation when file was modifed in the trunk and
deleted in the branch and produces an error during merge.
============================================
C:\temp\2\prj>cvs -d/home/cvsroot co prj
cvs.EXE checkout: Updating prj
U prj/file1.txt
U prj/file2.txt
C:\temp\2\prj>cvs tag -b demo-branch
cvs.EXE tag: Tagging .
T file1.txt
T file2.txt
C:\temp\2\prj>notepad file1.txt
C:\temp\2\prj>cvs commit file1.txt
Checking in file1.txt;
/home/cvsroot/prj/file1.txt,v <-- file1.txt
new revision: 1.2; previous revision: 1.1
done
C:\temp\2\prj>cvs up -rdemo-branch
cvs.EXE update: Updating .
U file1.txt
C:\temp\2\prj>del file1.txt
C:\temp\2\prj>cvs rm file1.txt
cvs.EXE remove: Removing `file1.txt'
cvs.EXE remove: scheduling `file1.txt' for removal
cvs.EXE remove: use 'cvs.EXE commit' to remove this file permanently
C:\temp\2\prj>cvs commit -m"removed file1.txt in demo-branch"
cvs.EXE commit: Examining .
Removing file1.txt;
/home/cvsroot/prj/file1.txt,v <-- file1.txt
new revision: delete; previous revision: 1.1.1.1.2
done
C:\temp\2\prj>cvs up -A
cvs.EXE update: Updating .
U file1.txt
C:\temp\2\prj>cvs up -j demo-branch
cvs.EXE update: Updating .
cvs.EXE update: file file1.txt has been modified, but has been removed in revision demo-branch
============================================
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: Re[4]: Merge of deleted file with a modified one
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 1/6/06, Alexey Yudichev <ay...@newmail.ru> wrote:
> But it seems that all the information is at hand. Subversion knows
> that the file was changed in the target tree since starting revision.
> I understand however that currently this information is not used.\
> Another option would be, before deleting the file, build a diff between staring
> revision and an empty file (which will look like all the lines of the
> starting revision removed) and try to apply this diff to the local
> (trunk) version of the file? In case file was not changed in the trunk
> since starting point, this patch would apply cleanly which is the sign
> of safe deletion, otherwise it would create a conflict which can and
> should be reported. (Hope the idea makes sense).
Sure, it makes sense for your particular use case, but not for all use
cases, that's what I'm trying to say. In order to know for sure if we
should consider this a conflict or not Subversion really needs some
concept of a "rename", as a distinct operation from "copy and delete".
If something was renamed, then yes, I'm perfectly willing to
stipulare that something should be done to ensure that changes made to
it on the trunk persist after the merge, but Subversion doesn't do
that right now, it copies it and deletes it, which means it's
impossible to tell the difference between a "I deleted it because we
don't need it anymore" and a "I renamed it".
> >> Couple of our developers called this feature a show stopper for
> >> employing subversion in our company.
>
> > Out of curiosity, do you know of another system that avoids this
> > issue? If so, what kind of behavior does it have?
> I am curious myself how it is done in CVS. If it isn't any better I
> would be satisfied, because this would sound like an argument :)
CVS doesn't handle it at all, as CVS doesn't have the ability to
rename files ;-)
-garrett
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re[4]: Merge of deleted file with a modified one
Posted by Alexey Yudichev <ay...@newmail.ru>.
>> change. In a big project with many files removed "correctly", i.e.
>> removed in the branch and unchanged in the trunk, this "incorrect"
>> deletion will be lost among them. This can be sometimes acceptable,
>> for example if removal is a result of a large scale refactoring, and
>> the change made in the trunk is no more relevant. In other cases, this
>> can create a long outstanding problem, for example, if the deletion in
>> the branch was made by mistake.
> Sure it can be sometimes unacceptable, but it can also be sometimes
> correct, this is why you have to verify a merge is correct before you
> commit it. Renames and merges are tricky business, but I honestly
> can't see how subversion can do the right thing in 100% of the cases,
> at some point a user needs to look at the diff and say "yep, that
> looks right".
But it seems that all the information is at hand. Subversion knows
that the file was changed in the target tree since starting revision.
I understand however that currently this information is not used.\
Another option would be, before deleting the file, build a diff between staring
revision and an empty file (which will look like all the lines of the
starting revision removed) and try to apply this diff to the local
(trunk) version of the file? In case file was not changed in the trunk
since starting point, this patch would apply cleanly which is the sign
of safe deletion, otherwise it would create a conflict which can and
should be reported. (Hope the idea makes sense).
> One idea that did occur to me is that you can avoid some such issues
> by merging changes from the trunk into the branch prior to merging
> back into the trunk, but in this case you're likely to fall into the
> trap of merge not being especially smart about renames. Hopefully
> that will be fixed in the future, when the work on atomic renames
> within the filesystem happens.
In our case, merging trunk into branch is not acceptable: branch
should not have any changes made in the trunk.
>> Couple of our developers called this feature a show stopper for
>> employing subversion in our company.
> Out of curiosity, do you know of another system that avoids this
> issue? If so, what kind of behavior does it have?
I am curious myself how it is done in CVS. If it isn't any better I
would be satisfied, because this would sound like an argument :)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: Re[2]: Merge of deleted file with a modified one
Posted by Bart Robinson <lo...@pobox.com>.
On 2006-1-6 Garrett Rooney <ro...@electricjellyfish.net> wrote:
> Out of curiosity, do you know of another system that avoids this
> issue? If so, what kind of behavior does it have?
For comparison (don't shoot the messenger, etc) in this case,
perforce complains and requires the user to pass a flag to allow
the delete.
For the reverse case, a file deleted in main but edited in the
new-branch, the merge from new-branch->main will also require a
flag. (Adding it will re-branch the file. I.e., it appears as
a copy from the branch.) Svn reports "Skipped missing target:
'foo'".
-- bart
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: Re[2]: Merge of deleted file with a modified one
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 1/6/06, Alexey Yudichev <ay...@newmail.ru> wrote:
> > Anyway, I'm pretty sure that deleting the file was the right thing for
> > merge to do in this case, as it was applying the tree delta to the
> > trunk. If you didn't want the file deleted, you have a chance to
> > revert that part of the change before committing.
>
> From point of view of a developer working in a trunk, this is a lost
> change. In a big project with many files removed "correctly", i.e.
> removed in the branch and unchanged in the trunk, this "incorrect"
> deletion will be lost among them. This can be sometimes acceptable,
> for example if removal is a result of a large scale refactoring, and
> the change made in the trunk is no more relevant. In other cases, this
> can create a long outstanding problem, for example, if the deletion in
> the branch was made by mistake.
Sure it can be sometimes unacceptable, but it can also be sometimes
correct, this is why you have to verify a merge is correct before you
commit it. Renames and merges are tricky business, but I honestly
can't see how subversion can do the right thing in 100% of the cases,
at some point a user needs to look at the diff and say "yep, that
looks right".
One idea that did occur to me is that you can avoid some such issues
by merging changes from the trunk into the branch prior to merging
back into the trunk, but in this case you're likely to fall into the
trap of merge not being especially smart about renames. Hopefully
that will be fixed in the future, when the work on atomic renames
within the filesystem happens.
> Couple of our developers called this feature a show stopper for
> employing subversion in our company.
Out of curiosity, do you know of another system that avoids this
issue? If so, what kind of behavior does it have?
-garrett
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re[2]: Merge of deleted file with a modified one
Posted by Alexey Yudichev <ay...@newmail.ru>.
> Anyway, I'm pretty sure that deleting the file was the right thing for
> merge to do in this case, as it was applying the tree delta to the
> trunk. If you didn't want the file deleted, you have a chance to
> revert that part of the change before committing.
Re: Merge of deleted file with a modified one
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 1/6/06, Ryan Schmidt <su...@ryandesign.com> wrote:
> On Jan 7, 2006, at 00:03, Alexey Yudichev wrote:
>
> [snip]
> > I discovered that if I
> > 1) create a branch from trunk via svn copy
> > 2) delete a file in branch and commit
> > 3) modify the same file in trunk and commit
> > 4) merge branch to trunk
> > I get the file deleted. Which means I lose my changes made in trunk.
> [snip]
>
> The file should not get deleted; rather, it should become unversioned
> in your working copy. If that's not what happens, please provide a
> transcript showing what you did.
I'm not sure that's correct. It certainly shouldn't delete it if all
you did was modify the file in your working copy, since that would be
deleting data that does not exist elsewhere and Subversion tries very
hard to never do that, but this is data that had already been
committed, which is not the same thing. No data is lost in this case,
so it's not a violation of our "don't delete unversioned data" rule.
As for the difference between "deleting a file" and "removing all the
lines in a file", they are in fact two different things from
Subversion's point of view. The first is a tree delta, which means a
change to the parent directory node in the filesystem, the second is
merely a text delta (change to the file contents). If you'd wanted to
remove all the content of the file, but not delete it, that's what you
should have done on the branch, committed an empty file, not deleted
it.
Anyway, I'm pretty sure that deleting the file was the right thing for
merge to do in this case, as it was applying the tree delta to the
trunk. If you didn't want the file deleted, you have a chance to
revert that part of the change before committing.
-garrett
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re[2]: Merge of deleted file with a modified one
Posted by Alexey Yudichev <ay...@newmail.ru>.
> [snip]
>> I discovered that if I
>> 1) create a branch from trunk via svn copy
>> 2) delete a file in branch and commit
>> 3) modify the same file in trunk and commit
>> 4) merge branch to trunk
>> I get the file deleted. Which means I lose my changes made in trunk.
> [snip]
> The file should not get deleted; rather, it should become unversioned
> in your working copy. If that's not what happens, please provide a
> transcript showing what you did.
Similar discussion is here:
http://svn.haxx.se/users/archive-2005-03/0739.shtml
http://svn.haxx.se/users/archive-2005-03/0744.shtml (same thread,
just different posting)
Here is my transcript:
==================================================
C:\temp\1>svn co http://localhost/repos/prj/trunk .
A 123.txt
A new-branch4-file.txt
A new-trunk-file.txt
A 12345.xml
Checked out revision 31.
C:\temp\1>svn copy http://localhost/repos/prj/trunk http://localhost/repos/prj/branches/demo-branch -m"created demo branch"
Committed revision 32.
C:\temp\1>notepad 123.txt
C:\temp\1>svn commit 123.txt -m"edited 123.txt"
Sending 123.txt
Transmitting file data .
Committed revision 33.
C:\temp\1>svn switch http://localhost/repos/prj/branches/demo-branch
U 123.txt
Updated to revision 33.
C:\temp\1>svn delete 123.txt
D 123.txt
C:\temp\1>svn commit 123.txt -m"deleted 123.txt"
Deleting 123.txt
Committed revision 34.
C:\temp\1>svn switch http://localhost/repos/prj/trunk
A 123.txt
Updated to revision 34.
C:\temp\1>svn merge -r32:34 http://localhost/repos/prj/branches/demo-branch --dry-run
D 123.txt
C:\temp\1>svn merge -r32:34 http://localhost/repos/prj/branches/demo-branch
D 123.txt
=============================
here 123.txt gets silently deleted locally and marked for deletion in
repository. If I commit, my changes to 123.txt would be silently lost.
By "lost" I mean that there would be no warnings, no conflicts etc.
Which in a big project with many correctly removed files, this
deletion will be lost among them.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: Merge of deleted file with a modified one
Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jan 7, 2006, at 00:03, Alexey Yudichev wrote:
[snip]
> I discovered that if I
> 1) create a branch from trunk via svn copy
> 2) delete a file in branch and commit
> 3) modify the same file in trunk and commit
> 4) merge branch to trunk
> I get the file deleted. Which means I lose my changes made in trunk.
[snip]
The file should not get deleted; rather, it should become unversioned
in your working copy. If that's not what happens, please provide a
transcript showing what you did.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org