qpkorr / vim-renamer

Git repo for http://www.vim.org/scripts/script.php?script_id=1721
MIT License
82 stars 11 forks source link

rename using subversion's 'svn mv' #6

Open mgr2000 opened 7 years ago

mgr2000 commented 7 years ago

I have the issue of having to rename a lot of files under subversion control. So the renaming has to be done with 'svn mv' instead of system's copy and rename. Could you add the option to rename this way or make the rename command configurable? Or even detect if a file is under subversion control and then use then 'svn mv' automatically?

qpkorr commented 7 years ago

Hi - apologies for not responding for... months - I certainly hope you've found a solution long ago! I guess your request is quite doable - with one caveat. Suppose you have two files, A and B, and you wish to swap their names - ie, A -> B, and B -> A. Given renames happen one at a time, we can't rename A to B without overwriting the original B, and we can't rename B to A without overwriting original A. To get around this issue, renamer works by renaming A to 1_GOING_TO_B, and B to 2_GOING_TO_A, before doing a final rename to B and A, respectively. This is always done, in case of temporary conflicts. But I'm guessing you don't really want those intermediate names in subversion - so would it therefore be necessary instead to analyse if there's any files swapping names, and use intermediate files for those renames, but to do all other renames directly? Right now, that feels like more work than I'm keen to invest.

Ha - the other question I should ask - my work uses subversion too - but I've been exceedingly happy using git-svn instead, and thus interacting using git procedures. In that case - git mv is identical to mv or rename I believe - so you could use renamer, and let git-svn convert the renames to svn mv's automatically - perhaps? Not so good for huge repositories though...

mgr2000 commented 7 years ago

Hi John, thanks for asking! Yes, I already solved the problem. I patched your code to test for subversion control of the directory before moving. If you like I'll try to create a pull request. Renaming to a temporary file and then to the real target file with svn mv seems not to be a problem, the final commit to subversion does only contain the "real" renaming without the temporary.

qpkorr commented 7 years ago

Hi - good job! Re a pull request - I figure it's entirely your call. I don't expect to need svn support any time soon, but others might well benefit from your work if you've got the time to share it. (Feel free to add an attribution in the docs/renamer.txt file too)