@NotNull
  public SVNStatusClient createStatusClient() {
    SVNStatusClient client = new SVNStatusClient(getPool(), getSvnOptions());
    client.setIgnoreExternals(false);

    return setupClient(client);
  }
  private static void copySVNURL(String fileName) {
    File file = new File(fileName);

    SVNClientManager clientManager = SVNClientManager.newInstance();

    SVNStatusClient statusClient = clientManager.getStatusClient();
    SVNStatus status = null;
    try {
      status = statusClient.doStatus(file, false);
    } catch (SVNException e) {
      logger.error("SVN Status was not possible", e);
      String message = "Some error with SVN. Probably the file selected is not in SVN.";
      String title = "Error";
      JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE);
      System.exit(ERROR_END);
    }
    if (status != null) {
      SVNURL fileSVNUrl = status.getRemoteURL();
      logger.info("SVN URL " + fileSVNUrl);
      Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
      StringSelection stringSelection = new StringSelection(fileSVNUrl.toString());
      clpbrd.setContents(stringSelection, null);
      String message = "Remote SVN URL has been coppied to the clipboard";
      String title = "Success!";
      JOptionPane.showMessageDialog(null, message, title, JOptionPane.INFORMATION_MESSAGE);
    } else {
      String message = "File " + fileName + " cannot be found in SVN";
      String title = "File not found in Repository";
      JOptionPane.showMessageDialog(null, message, title, JOptionPane.WARNING_MESSAGE);
    }
  }
示例#3
0
 public SVNStatusClient createStatusClient() {
   SVNStatusClient client = new SVNStatusClient(getPool(), myConfiguration.getOptions(myProject));
   client
       .getOperationsFactory()
       .setAuthenticationManager(myConfiguration.getAuthenticationManager(this));
   client.setIgnoreExternals(false);
   return client;
 }
  public void testStatusDoesNotLockForWrite() throws Exception {
    final File ioFile = new File(myWorkingCopyRoot, filename);
    ioFile.getParentFile().mkdirs();

    /*SVNWCClient client11 = new SVNWCClient((ISVNRepositoryPool)null, new DefaultSVNOptions());
    client11.doAdd(ioFile.getParentFile(), true, false, true, true);*/

    ioFile.createNewFile();
    try {
      final SVNStatusClient readClient =
          new SVNStatusClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
      final Semaphore semaphore = new Semaphore();
      final Semaphore semaphoreMain = new Semaphore();
      final Semaphore semaphoreWokeUp = new Semaphore();

      final AtomicReference<Boolean> wasUp = new AtomicReference<Boolean>(false);
      final ISVNStatusHandler handler =
          status -> {
            semaphore.waitFor();
            wasUp.set(true);
          };

      semaphore.down();
      semaphoreMain.down();
      semaphoreWokeUp.down();

      final SVNException[] exception = new SVNException[1];
      Thread thread =
          new Thread(
              () -> {
                try {
                  semaphoreMain.up();
                  readClient.doStatus(myWorkingCopyRoot, true, false, true, false, handler);
                  semaphoreWokeUp.up();
                } catch (SVNException e) {
                  exception[0] = e;
                }
              },
              "svn test");
      thread.start();

      semaphoreMain.waitFor();
      TimeoutUtil.sleep(5);
      SVNWCClient client = new SVNWCClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
      client.doAdd(ioFile.getParentFile(), true, false, true, true);
      semaphore.up();
      semaphoreWokeUp.waitFor();

      Assert.assertEquals(true, wasUp.get().booleanValue());
      if (exception[0] != null) {
        throw exception[0];
      }
      thread.join();
    } finally {
      ioFile.delete();
    }
  }
 @Nullable
 private String getStatus(final File ioFile) throws SVNException {
   try {
     SVNStatusClient readClient =
         new SVNStatusClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
     final SVNStatus status = readClient.doStatus(ioFile, false);
     return status == null ? null : status.getNodeStatus().toString();
   } catch (SVNException e) {
     if (SVNErrorCode.WC_NOT_WORKING_COPY.equals(e.getErrorMessage().getErrorCode())) {
       return null;
     }
     throw e;
   }
 }
  @Test
  public void testRefusedAdd() throws Exception {
    SVNWCDb db = new SVNWCDb();
    final File ioFile = new File(myWorkingCopyRoot, filename);
    ioFile.getParentFile().mkdirs();
    ioFile.createNewFile();
    try {
      db.open(ISVNWCDb.SVNWCDbOpenMode.ReadWrite, new DefaultSVNOptions(), true, true);
      SVNWCContext context =
          new SVNWCContext(
              db,
              new ISVNEventHandler() {
                @Override
                public void handleEvent(SVNEvent event, double progress) throws SVNException {}

                @Override
                public void checkCancelled() throws SVNCancelException {}
              });

      File file = context.acquireWriteLock(myWorkingCopyRoot, false, true);
      boolean failed = false;
      try {
        SVNWCClient client = new SVNWCClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
        client.doAdd(ioFile, true, false, false, true);
      } catch (SVNException e) {
        Assert.assertEquals(155004, e.getErrorMessage().getErrorCode().getCode());
        failed = true;
      } finally {
        context.releaseWriteLock(myWorkingCopyRoot);
      }
      Assert.assertTrue(failed);

      SVNStatusClient readClient =
          new SVNStatusClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
      // readClient.doStatus(ioFile, false);
      readClient.doStatus(myWorkingCopyRoot, false);
    } finally {
      ioFile.delete();
      db.close();
    }
  }
 private static SVNStatus getExternalItemStatus(final SvnVcs vcs, final File file) {
   final SVNStatusClient statusClient = vcs.createStatusClient();
   try {
     if (file.isDirectory()) {
       return statusClient.doStatus(file, false);
     } else {
       final File parent = file.getParentFile();
       if (parent != null) {
         statusClient.setFilesProvider(
             new ISVNStatusFileProvider() {
               public Map getChildrenFiles(File parent) {
                 return Collections.singletonMap(file.getAbsolutePath(), file);
               }
             });
         final Ref<SVNStatus> refStatus = new Ref<SVNStatus>();
         statusClient.doStatus(
             parent,
             SVNRevision.WORKING,
             SVNDepth.FILES,
             false,
             true,
             false,
             false,
             new ISVNStatusHandler() {
               public void handleStatus(final SVNStatus status) throws SVNException {
                 if (file.equals(status.getFile())) {
                   refStatus.set(status);
                 }
               }
             },
             null);
         return refStatus.get();
       }
     }
   } catch (SVNException e) {
     //
   }
   return null;
 }