A project I’m working on desperately needs refactoring. The problem is that there are typically multiple branches (maintenance, new features, etc.) and I’m not so sure we can easily move, rename and delete files and directories and merge the changes. My fear is that I’d move a file in a refactoring branch while someone else is updating the file in another branch. I’ve been hoping for a small window where the trunk has everything and no branches are needed, but the business is always needing changes (either immediately or as part of a minor release).
Our source control is managed with Subversion. Is it easy/possible to drastically change the project in one branch while keeping the changes in synch with others? I’m pretty good about merging changes to keep branches up-to-date and maybe just making small refactoring changes at a time will work. Otherwise, can this really only be done by setting aside some time where we’ll only work on refactoring (i.e., no other branches)? I’ve been trying to convince business owners that we need some time to refactor and, while they agree, it just doesn’t seem possible right now.
One of the important things about refactoring is that it should always be done (not just once-in-a-while). That seems doable with actual code (breaking up functions, removing duplicate code, etc.) but I’m not so confident about appropriately renaming and grouping files.
It is do-able in SVN, but I can tell you that you will face a lot of different issue. Think twice if you really want the refactoring goes to every branch? It don’t seems to be reasonable to merge the refactored code to release branches (which is the maintenance branches for releasing minor fixes for production versions).
Although SVN can let you merge from any branch to any branch, it is always more reasonable to merge between a branch and the originated branch. Therefore, if you have something like this:
Instead of doing the refactoring job in Refactor and merge it to every other branch, it is more reasonable to reintegrate the change in Refactor branch to Trunk (assume in revision X), and then merge revision X from Trunk to other branches that need this change. For Release Branches (Rel-1.0, Rel-1.1), it will most likely be a cherry-pick. For feature branches A/B, it will be catching up with Trunk (by merging all things in Trunk).
Please be noted that, merge become harder if your branch deviate from trunk more. Therefore think twice if you really need to merge refactored code to release branches (which is most likely very deviated from the trunk).
Please also note that, tracking of rename in SVN is not that well implemented. For example, you renamed file F in trunk to FNew, what SVN treat is adding FNew by copying from F, and delete F. If you merge it to the branch, afaik, what SVN does is adding branch/FNew by copying from trunk/F, and delete branch/F. Therefore if you have ever modified branch/F, for newer version of SVN (probably >=1.5) it will generate a tree conflict, while in older version of SVN you will even lost the modification. Though newer version handles a bit better, none of them is handling the merge for renaming “correctly” (which move branch/F to branch/FNew). This will cause you extra effort in merging, and cause merging even more difficult in case two branches deviate a lot.