OmegaT SVN cleanup

Situation

So, you’ve been using OmegaT’s Team Project feature for a while, and recently you’ve noticed that the folder named .svn (which is hidden, and therefore you noticed it rather accidentally) is immensely big compared to all the other files in the project, and keeps growing.

Problem

Taking up space may not be a problem in the short run, but if it’s a longterm project with source files being added and removed to and from the SVN, in a couple weeks this .svn folder can grow uncomfortably big. Deleting .svn folder or its content stops the project from being a team project.

Solution

(Use one of the following)

  1. Redownload the project every time this little .svn monster grows too big to bear with. Doesn’t require any additional software to get it done, but in case you have additional TMX and glossary files not under version control, you’ll have to take care of them manually. Once everything is transfered into the new location, the old project folder along with the outgrown .svn can be deleted.
  2. Run
    svn cleanup project_folder
    in command prompt (svn must be installed). A slight variation would be navigating to the project_folder, running terminal emulator from there and executing
    svn cleanup
    without any parameters. Get the job done, but requires extra actions without OmegaT.
  3. If there’s a command line version of svn installed and it’s in $PATH (or %PATH%) (if installed properly, in Linux and Mac it’s already in $PATH and can be executed without giving the whole path to the executable, in Windows it’s not always the case), you can use this little groovy script (scripting plugin must be installed)
    import javax.swing.JOptionPane;
    def svn = "svn"
    def command = "cleanup"
    def prop = project.getProjectProperties()
    if (prop == null) {
    def title = "SVN cleanup"
    def msg = "Cleaning .svn folder"
    JOptionPane.showMessageDialog(null, msg, title,
    JOptionPane.INFORMATION_MESSAGE);
    } else {
    def folder = prop.getProjectRoot()
    new ProcessBuilder(svn, command, folder).start()
    }
    

    The idea was developed from scripts in masao_kasuya’s Yahoo group post (by Yu Tang)
    Requires svn installed, but can be easily run from the comfort of OmegaT anytime.

  4. UPDATE:
    Yu Tang, the author of original groovy scrips, shared his script that lets you do cleanup using only the built-in OmegaT’s svn client, and thus working on any system without any additional svn software installed. Here it is:

    import org.omegat.core.team.SVNRemoteRepository
    import org.tmatesoft.svn.core.wc.SVNClientManager
    
    if (project.isProjectLoaded()) {
    def prop = project.getProjectProperties()
    def folder = new File(prop.getProjectRoot())
    if (SVNRemoteRepository.isSVNDirectory(folder)) {
    def clientManager = SVNClientManager.newInstance();
    clientManager.getWCClient().doCleanup(folder)
    console.println("cleanup!!")
    }
    }
    
  5. SUPERNEWS:
    Yu Tang’s script is now included in the Scripting plugin. No need to add anything manually.

Tested only on Linux, I’m pretty sure should work on Mac, and it would be awesome to hear if it’s any use on Windows. But as of now,
Good luck!

2 thoughts on “OmegaT SVN cleanup

  1. Thanks for this post.
    I like your script.
    I executed cleanup for my 500MB repo and 5MB now. 🙂

    BTW, script can use OmegaT built-in svn (SVNKit) like this;

    import org.omegat.core.team.SVNRemoteRepository
    import org.tmatesoft.svn.core.wc.SVNClientManager

    if (project.isProjectLoaded()) {
    def prop = project.getProjectProperties()
    def folder = new File(prop.getProjectRoot())
    if (SVNRemoteRepository.isSVNDirectory(folder)) {
    def clientManager = SVNClientManager.newInstance();
    clientManager.getWCClient().doCleanup(folder)
    console.println(“cleanup!!”)
    }
    }

    Bit too long but independent of any external svn client.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s