Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving to a subversion repository from Java

I want to save to a subversion repository.

I am using the command - svn commit -m \"\" ./cms_test/www

My class is:

public int doBackup(){
    int exitVal=-99;
  try
  {            
      Runtime rt = Runtime.getRuntime();
      Process proc = rt.exec("svn commit -m \"\" ./cms_test/www");
      exitVal = proc.exitValue();
      System.out.println("Process exitValue: " + exitVal);
  } catch (Throwable t)
    {
      t.printStackTrace();
    }
  return exitVal;
}

Should this work, or is there something else I need to do.

like image 643
Ankur Avatar asked Aug 14 '26 04:08

Ankur


2 Answers

Why don't you use something like SVNKit?

SVNKit is a pure Java toolkit - it implements all Subversion features and provides APIs to work with Subversion working copies, access and manipulate Subversion repositories - everything within your Java application.

The benefits are:

  • No dependency on subversion binaries being installed;
  • Proper errors propagated to Java code instead of checking for return codes and parsing output;
  • Easier to make more advanced use-cases work;

All that plus the fun factor of learning a new API.

like image 77
Robert Munteanu Avatar answered Aug 16 '26 21:08

Robert Munteanu


It might work, but be sure to be already authenticated to your svn server and call another method where you update your revision before calling your doBackup() method.

like image 28
Rigo Vides Avatar answered Aug 16 '26 21:08

Rigo Vides