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);
    }
  }
Example #2
0
  /**
   * Constructor FileTableRow
   *
   * @param status
   */
  public FileTableRow(SVNStatus status) {
    File statusFile = status.getFile();

    this.status = new String(getStatus(status));
    this.folder = statusFile.getParentFile();
    this.file = statusFile.getName();
    this.revision = status.getRevision().getNumber();
    this.committedRevision = status.getCommittedRevision().getNumber();

    int extIndex = file.lastIndexOf('.');

    if (statusFile.isFile() && (extIndex > 0)) {
      ext = file.substring(extIndex + 1);
    } else {
      ext = "";
    }

    long lastModified = statusFile.lastModified();

    if (lastModified > 0) {
      modified = new Date(lastModified);
    } else {
      modified = null;
    }

    if (status.getURL() != null) {
      location = new Location(statusFile, status.getURL().toString());
    } else {
      location = null;
    }
  }
 @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;
   }
 }
 private boolean for17move(
     final SvnVcs vcs, final File src, final File dst, boolean undo, SVNStatus srcStatus)
     throws SVNException {
   if (srcStatus != null && srcStatus.getCopyFromURL() == null) {
     undo = false;
   }
   if (undo) {
     myUndoingMove = true;
     createRevertAction(vcs, dst, true).execute();
     copyUnversionedMembersOfDirectory(src, dst);
     if (srcStatus == null || SvnVcs.svnStatusIsUnversioned(srcStatus)) {
       FileUtil.delete(src);
     } else {
       createRevertAction(vcs, src, true).execute();
     }
     restoreFromUndoStorage(dst);
   } else {
     if (doUsualMove(vcs, src)) return true;
     // check destination directory
     final SVNStatus dstParentStatus = getFileStatus(vcs, dst.getParentFile());
     if (dstParentStatus == null || SvnVcs.svnStatusIsUnversioned(dstParentStatus)) {
       try {
         copyFileOrDir(src, dst);
       } catch (IOException e) {
         throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e);
       }
       createDeleteAction(vcs, src, true).execute();
       return false;
     }
     moveFileWithSvn(vcs, src, dst);
   }
   return false;
 }
  /**
   * add file or directory:
   *
   * <p>parent directory is: unversioned: do nothing, return false versioned: entry is: null: create
   * entry, schedule for addition missing: do nothing, return false deleted, 'do' mode: try to
   * create entry and it schedule for addition if kind is the same, otherwise do nothing, return
   * false. deleted: 'undo' mode: try to revert non-recursively, if kind is the same, otherwise do
   * nothing, return false. anything else: return false.
   */
  private boolean createItem(
      VirtualFile dir, String name, boolean directory, final boolean recursive) {
    SvnVcs vcs = getVCS(dir);
    if (vcs == null) {
      return false;
    }
    final VcsShowConfirmationOption.Value value = vcs.getAddConfirmation().getValue();
    if (VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY.equals(value)) return false;

    if (isUndo(vcs) && SvnUtil.isAdminDirectory(dir, name)) {
      return false;
    }
    File ioDir = getIOFile(dir);
    boolean pendingAdd = isPendingAdd(vcs.getProject(), dir);
    if (!SvnUtil.isSvnVersioned(vcs.getProject(), ioDir) && !pendingAdd) {
      return false;
    }
    final File targetFile = new File(ioDir, name);
    SVNStatus status = getFileStatus(vcs, targetFile);

    if (status == null
        || status.getContentsStatus() == SVNStatusType.STATUS_NONE
        || status.getContentsStatus() == SVNStatusType.STATUS_UNVERSIONED) {
      myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(dir, name, null, recursive));
      return false;
    } else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING)) {
      return false;
    } else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) {
      SVNNodeKind kind = status.getKind();
      // kind differs.
      if (directory && kind != SVNNodeKind.DIR || !directory && kind != SVNNodeKind.FILE) {
        return false;
      }
      try {
        if (isUndo(vcs)) {
          createRevertAction(vcs, targetFile, false).execute();
          return true;
        }
        myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(dir, name, null, recursive));
        return false;
      } catch (SVNException e) {
        SVNFileUtil.deleteAll(targetFile, true);
        return false;
      }
    }
    return false;
  }
 @Override
 public boolean fileExistsInVcs(FilePath path) {
   File file = path.getIOFile();
   try {
     SVNStatus status = createStatusClient().doStatus(file, false);
     if (status != null) {
       if (svnStatusIs(status, SVNStatusType.STATUS_ADDED)) {
         return status.isCopied();
       }
       return !(svnStatusIsUnversioned(status)
           || svnStatusIs(status, SVNStatusType.STATUS_IGNORED)
           || svnStatusIs(status, SVNStatusType.STATUS_OBSTRUCTED));
     }
   } catch (SVNException e) {
     //
   }
   return false;
 }
    public void handleStatus(final SVNStatus status) throws SVNException {
      myPartner.checkCanceled();
      final File ioFile = status.getFile();
      checkIfCopyRootWasReported();

      final LocalFileSystem lfs = LocalFileSystem.getInstance();
      VirtualFile vFile = lfs.findFileByIoFile(ioFile);
      if (vFile == null) {
        vFile = lfs.refreshAndFindFileByIoFile(ioFile);
      }
      if ((vFile != null) && myPartner.isExcluded(vFile)) return;

      if ((vFile != null) && (SvnVcs.svnStatusIsUnversioned(status))) {
        myReceiver.processUnversioned(vFile);
        if (vFile.isDirectory()) {
          processRecursively(vFile, myCurrentItem.getDepth());
        }
      } else {
        final FilePath path = VcsUtil.getFilePath(ioFile, status.getKind().equals(SVNNodeKind.DIR));
        myReceiver.process(path, status);
      }
    }
    public void checkIfCopyRootWasReported() {
      if (!myMetCurrentItem && myCurrentItem.isIsInnerCopyRoot()) {
        myMetCurrentItem = true;
        final SVNStatus statusInner =
            SvnUtil.getStatus(SvnVcs.getInstance(myProject), myCurrentItem.getPath().getIOFile());
        if (statusInner == null) return;

        final SVNStatusType status = statusInner.getNodeStatus();
        if (SVNStatusType.OBSTRUCTED.equals(status)
            || SVNStatusType.STATUS_IGNORED.equals(status)
            || SVNStatusType.STATUS_NONE.equals(status)
            || SVNStatusType.STATUS_UNVERSIONED.equals(status)
            || SVNStatusType.UNKNOWN.equals(status)) {
          return;
        }
        if (myCurrentItem.getPath().getVirtualFile() != null) {
          myReceiver.processCopyRoot(
              myCurrentItem.getPath().getVirtualFile(),
              statusInner.getURL(),
              WorkingCopyFormat.getInstance(statusInner.getWorkingCopyFormat()));
        }
      }
    }
 private void fillDeletedFiles(
     Project project,
     List<Pair<FilePath, WorkingCopyFormat>> deletedFiles,
     Collection<FilePath> deleteAnyway)
     throws SVNException {
   final SvnVcs vcs = SvnVcs.getInstance(project);
   final Collection<File> files = myDeletedFiles.remove(project);
   for (final File file : files) {
     final SVNStatus status =
         new RepeatSvnActionThroughBusy() {
           @Override
           protected void executeImpl() throws SVNException {
             myT = vcs.getFactory(file).createStatusClient().doStatus(file, false);
           }
         }.compute();
     boolean isAdded = SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus());
     final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file);
     if (isAdded) {
       deleteAnyway.add(filePath);
     } else {
       deletedFiles.add(Pair.create(filePath, vcs.getWorkingCopyFormat(file)));
     }
   }
 }
Example #10
0
  /**
   * Method getStatus
   *
   * @param status
   * @return
   */
  public static char[] getStatus(SVNStatus status) {
    char[] s = {' ', ' ', ' ', ' ', ' ', ' ', ' '};

    // column 1 file status
    s[0] = status.getContentsStatus().getCode();
    // column 2 folder status
    s[1] = status.getPropertiesStatus().getCode();

    // column 3 lock status
    if (status.isLocked()) {
      s[2] = 'L';
    }

    // column 4 copy status
    if (status.isCopied()) {
      s[3] = '+';
    }

    // column 5 switched status
    if (status.isSwitched()) {
      s[4] = 'S';
    }

    // column 6 local lock status
    if (status.getLocalLock() != null) {
      s[5] = 'K';
    }

    // column 7 needs update
    if ((status.getRemotePropertiesStatus() != SVNStatusType.STATUS_NONE)
        || (status.getRemoteContentsStatus() != SVNStatusType.STATUS_NONE)) {
      s[6] = '*';
    }

    return s;
  }
 @Override
 public void setIsConflicted(boolean isConflicted) {
   myConflicted = isConflicted;
   super.setIsConflicted(isConflicted);
 }
Example #12
0
 public static boolean svnStatusIs(final SVNStatus status, @NotNull final SVNStatusType value) {
   return value.equals(status.getNodeStatus()) || value.equals(status.getContentsStatus());
 }