Reputation: 3744
I have a structure like this in my PyCharm project:
first_package
└───first_package
└───first_file.py
secondpackage
└───secondpackage
└───second_file.py
I want to remove the underscore from first_package
, but this package is used in secondpackage
(and others).
This should be a pretty straightforward task using PyCharm's refactoring tool, however, I'm pretty sure SVN is not going to like it if PyCharm renames both of the first_package
directories to firstpackage
without informing it first.
My understanding of SVN is that I should use svn mv
, followed by svn commit
, for changing the names of files/directories. The trouble is, if I do that I will have renamed the directories outside of PyCharm and then I will no doubt have some error-prone search-and-replace work to do.
Am I overlooking a simple solution?
Upvotes: 0
Views: 173
Reputation: 5002
Starting with your original tree:
.
├── first_package
│ └── first_package
│ └── first_file.py
└── secondpackage
└── secondpackage
└── second_file.py
Go ahead and let your refactoring tool turn your tree into:
.
├── firstpackage
│ └── firstpackage
│ └── first_file.py
└── secondpackage
└── secondpackage
└── second_file.py
Then svn status
gives:
$ svn status
! first_package
! first_package/first_package
! first_package/first_package/first_file.py
? firstpackage
At this point if we try svn mv
to record what happened in SVN we get an error:
$ svn mv first_package firstpackage
svn: E155010: Directory '/tmp/tmp.wlyfVrQasv/repo/firstpackage' is not under version control
That's because svn mv
wants to perform the move action. It doesn't just record something that already happened.
In this solution, you will lose your SVN history. If you don't care about history, and the refactoring is actually super complicated, then this might be the simple option.
svn add
on anything which is marked by svn status
as ?
.svn del
on anything which is marked by svn status
as !
.This solution is better as it retains history.
Leave your code as-is, but undo the file-structure/name changes manually, then use SVN to redo them. In this case we start with the root of the project:
$ svn status | grep -v /
! first_package
? firstpackage
To apply this:
$ mv firstpackage first_package
$ svn mv first_package firstpackage
A firstpackage
D first_package
D first_package/first_package
D first_package/first_package/first_file.py
If we check svn status
and look for the next level of !
and ?
(and filter out the py file) we see:
$ svn status | grep '^[!?]' | grep -v py
! firstpackage/first_package
? firstpackage/firstpackage
Let's handle that next:
$ mv firstpackage/firstpackage firstpackage/first_package
$ svn mv firstpackage/first_package firstpackage/firstpackage
A firstpackage/firstpackage
D firstpackage/first_package
D firstpackage/first_package/first_file.py
Now we have the directory structure you want and SVN is happy:
$ svn status
D first_package
> moved to firstpackage
A + firstpackage
> moved from first_package
D + firstpackage/first_package
> moved to firstpackage/firstpackage
A + firstpackage/firstpackage
> moved from firstpackage/first_package
Now you're ready to svn commit
.
Upvotes: 1