copy-paste file leads to svn copy
已回答
Hi,
When copy-ing & paste-ing a file in the project or grails view, the new file is added to svn as an svn copy, i.e. the new file shares the history with the original. This is often not what you want, e.g. people tend to copy-paste just because as an easy start, not because the files are related.
Is there an option, setting, configuration item to switch this off? I'd like IntelliJ to just "svn add" all new files, no matter where they came from...
Thanks,
Peter.
请先登录再写评论。
Hello Peter,
No, there is no setting for that, and we don't plan to add one. IDEA won't
use an 'svn copy' if you create a new file at the new location and then copy
the contents over.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Too bad....
I know about the work around, but people tend to forget that copy-paste-file has this (in my opinion nasty) side-effect.
Thanks anyway for your reply.
> This is often not what you want
interesting opinion
as for me - I almost always wanna do svn copy when copying files
Peter, Can you share your workaround? I ran into same issue and would like to know the workaround.
Thanks
IDEA won't use an 'svn copy' if you create a new file at the new location and then copy the contents over.
Will 'svn copy' still be used if I refactor -> copy (F5)?
Thanks
Yes. As described above, this behavior is by design and we don't have any plans to change it.
I just got bit by this one today- I almost always start a new file by copy-paste into the new package as a blank start.
For example, a controller implementing a bunch of REST endpoints for a new type. The quick copy-paste into the new package handles a lot of things for you (like the logging class is the pasted-class and all the many annotations are there -- in this case maybe 5 annotations per method. Then I prune out or change the methods to the suit the new implementation.
How long has IntelliJ worked this way? I don't remember this being the behavior in previous versions although I might not remember due to other projects using GIT vs. SVN.
The work around is annoying, however. I have to create a new file with the new name. Then copy-paste the contents into the new file. Doesn't seem so bad, but it is clunkier than simply cntl-c on one file and cntl-v into another package and letting IntelliJ doing the package refactoring. Plus it is something else I have to remember :).
FYI: I found this out in a code review - so what has been happening is the SVN log has been littered with "svn cp" history where 99% of the time the developer meant to simply copy-paste the file as a template and NOT as a true "Hey, I'm refactoring this system and want to save the history of all files moved.". I conclude from this that the behavior is behaving correctly only for a very, very small number of use cases.
I was told to not use IntelliJ copy-paste for files so I came looking for the setting to turn it off...
The Subversion integration has behaved this way since version 7 at least. In Git, copy/rename tracking is done by Git itself and there is no separate copy command, so the issue does not apply.
The correct solution for this case is to save the controller as a file template and to create other controllers from that template. You can also define live templates for individual methods in your controller.
This behavior annoying me too, I'd would prefer a 'clean' copy.
Workaround: After copying the file, when the confirmation dialog appears ("Settings/Version Control/Confirmation" to change behavior) prompting to add to VCS, select "Cancel". Then manually add it to VCS (Ctrl+Alt+A). This method can bypass the SVN copy action.