title: How to rename Java packages without breaking Subversion history?
body: <p>The company I'm working for is starting up and they changed their name in the process. So we still use the package name com.oldname because we are afraid of breaking the file change history, or the ancestry links between versions, or whatever we could break (I don't think I use the right terms, but you get the concept).</p>
  
  <p>We use: Eclipse, TortoiseSVN, Subversion</p>
  
  <p>I found <a href="http://www.basilv.com/psd/blog/2006/my-experience-with-subversion" rel="noreferrer">somewhere</a> that I should do it in many steps to prevent incoherence between content of .svn folders and package names in java files:</p>
  
  <ul>
  <li>First use TortoiseSVN to rename the directory, updating the .svn directories.</li>
  <li>Then, manually rename the directory back to the original name.</li>
  <li>To finally use Eclipse to rename the packages (refactor) back to the new name, updating the java files.</li>
  </ul>
  
  <p>That seems good to me, but I need to know if the ancestry and history and everything else will still be coherent and working well.</p>
  
  <p>I don't have the keys to that server, that's why I don't hastily backup things and try one or two things. I would like to come up with a good reason not to do it, or a way of doing it which works.</p>
  
  <p>Thank you for your help,</p>
  
  <p>M. Joanis</p>
  
  <hr>
  
  <p><strong>Package rename test</strong></p>
  
  <p>Procedure:</p>
  
  <ol>
  <li>Create a new package com.oldname.test.renametest.subpackage.</li>
  <li><p>Add a new class under renametest called RenameTest0.java and containing:</p>
  
  <pre>class RenameTest0 {
      public RenameTest0() {
          showMessage();
          new RenameTest1();
      }
      public static void showMessage() {
          System.out.println("RenameTest0!");
      }
      public static void main(String[] args) {
          new RenameTest0();
      }
  }</pre></li>
  <li><p>Add a new class under renametest.subpackage containing:</p>
  
  <pre>class RenameTest1 {
      public RenameTest1() {
          showMessage();
          RenameTest0.showMessage();
      }
      public static void showMessage() {
          System.out.println("RenameTest1!");
      }
  }</pre></li>
  <li><p>Test that RenameTest0 runs fine.</p></li>
  <li>Commit.</li>
  <li>Change the messages of both of the classes.</li>
  <li>Commit.</li>
  <li>Again, change the message of one class and commit (just creating some history).</li>
  <li>Apply procedure proposed above (the three steps in the original message) for renaming package renametest to testrename.</li>
  <li>Commit.</li>
  <li>Test run.</li>
  <li>Modify the messages again and test.</li>
  <li>Commit.</li>
  <li>Try to roll back to the version when both messages have been changed simultaneously the first time.</li>
  <li>If everything worked fine to this point, it looks good, no?</li>
  </ol>
  
  <p>Result of test:</p>
  
  <ul>
  <li>Note on step 9: Had to do it in <em>reverse order</em> (Eclipse rename THEN TortoiseSVN rename.), else it was getting complicated, as TSVN create a new folder/package and marks the old one for deletion... So you can't rename for Eclipse unless you put the old package somewhere else in the meantime to prevent losing .svn folders, etc. etc. Didn't look like a good idea to go further with this method. (Note to myself: don't forget to tick the checkbox for recursive package renaming!)</li>
  <li>Note on step 14: Worked! We can see previous versions; all we have to do is tell not to break on copy/move and it's ok. Once reverted to a version before the rename, <em>the package names are not back to the good name though</em>, probably that refactoring it again would do it.</li>
  <li>End note: I was surprised to have to do the critical steps in reverse order. To do that right in the middle of this first package rename try, I had to roll back some TSVN and manual modifications, casting a little doubt on the repeatable nature of the exact results of this procedure. I will have to do a second test to confirm it's validity. <em>To sum up: it looks good, but needs further testing.</em></li>
  </ul>