/plugins/SVNPlugin/tags/0.5/src/ise/plugin/svn/command/Status.java

# · Java · 74 lines · 55 code · 13 blank · 6 comment · 7 complexity · 0630192c175b1fe2f1fd6e36d85dd54e MD5 · raw file

  1. package ise.plugin.svn.command;
  2. import java.io.*;
  3. import java.util.*;
  4. import java.text.BreakIterator;
  5. import java.text.DateFormat;
  6. import java.text.SimpleDateFormat;
  7. import org.tmatesoft.svn.cli.command.SVNCommandEventProcessor;
  8. import org.tmatesoft.svn.cli.SVNArgument;
  9. import org.tmatesoft.svn.cli.SVNCommand;
  10. import org.tmatesoft.svn.core.SVNException;
  11. import org.tmatesoft.svn.core.SVNLock;
  12. import org.tmatesoft.svn.core.SVNNodeKind;
  13. import org.tmatesoft.svn.core.SVNURL;
  14. import org.tmatesoft.svn.core.internal.util.SVNFormatUtil;
  15. import org.tmatesoft.svn.core.internal.util.SVNPathUtil;
  16. import org.tmatesoft.svn.core.wc.ISVNInfoHandler;
  17. import org.tmatesoft.svn.core.wc.ISVNOptions;
  18. import org.tmatesoft.svn.core.wc.SVNClientManager;
  19. import org.tmatesoft.svn.core.wc.SVNInfo;
  20. import org.tmatesoft.svn.core.wc.SVNRevision;
  21. import org.tmatesoft.svn.core.wc.SVNWCClient;
  22. import org.tmatesoft.svn.core.wc.SVNWCUtil;
  23. import org.tmatesoft.svn.core.wc.xml.SVNXMLInfoHandler;
  24. import org.tmatesoft.svn.core.wc.xml.SVNXMLSerializer;
  25. import org.tmatesoft.svn.core.wc.SVNStatus;
  26. import org.tmatesoft.svn.core.wc.SVNStatusClient;
  27. import ise.plugin.svn.data.SVNData;
  28. import ise.plugin.svn.data.StatusData;
  29. public class Status {
  30. public StatusData getStatus( SVNData cd ) throws CommandInitializationException, SVNException {
  31. // validate data values
  32. if ( cd.getPaths() == null ) {
  33. return null; // nothing to do
  34. }
  35. if ( cd.getOut() == null ) {
  36. throw new CommandInitializationException( "Invalid output stream." );
  37. }
  38. if ( cd.getErr() == null ) {
  39. cd.setErr( cd.getOut() );
  40. }
  41. List<String> paths = cd.getPaths();
  42. // use default svn config options
  43. ISVNOptions options = SVNWCUtil.createDefaultOptions( true );
  44. // use the svnkit client manager
  45. SVNClientManager clientManager = SVNClientManager.newInstance( options, cd.getUsername(), cd.getPassword() );
  46. // get a client
  47. SVNStatusClient client = clientManager.getStatusClient();
  48. // set an event handler so that messages go to the streams for display
  49. client.setEventHandler( new SVNCommandEventProcessor( cd.getOut(), cd.getErr(), false ) );
  50. // actually fetch the info
  51. StatusHandler handler = new StatusHandler(cd.getOut(), true);
  52. long revision = -1;
  53. for ( String path : paths ) {
  54. File localPath = new File( path );
  55. revision = client.doStatus( localPath, true, true, false, false, handler );
  56. }
  57. StatusData status_data = handler.getResults();
  58. status_data.setRevision(revision);
  59. return status_data;
  60. }
  61. }