public void run() {
      ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
      if (progress != null) {
        progress.setText(SvnBundle.message("progress.text.loading.contents", myURL));
        progress.setText2(SvnBundle.message("progress.text2.revision.information", myRevision));
      }

      try {
        myContents =
            SvnUtil.getFileContents(
                myVCS, SvnTarget.fromURL(SvnUtil.parseUrl(myURL)), myRevision, myPegRevision);
      } catch (VcsException e) {
        myException = e;
      }
    }
    public Pair<List<RepositoryLocationGroup>, List<RepositoryLocation>> groupLocations(
        final List<RepositoryLocation> in) {
      final List<RepositoryLocationGroup> groups = new ArrayList<RepositoryLocationGroup>();
      final List<RepositoryLocation> singles = new ArrayList<RepositoryLocation>();

      final MultiMap<SVNURL, RepositoryLocation> map = new MultiMap<SVNURL, RepositoryLocation>();

      for (RepositoryLocation location : in) {
        final SvnRepositoryLocation svnLocation = (SvnRepositoryLocation) location;
        final String url = svnLocation.getURL();

        final SVNURL root = SvnUtil.getRepositoryRoot(myVcs, url);
        if (root == null) {
          // should not occur
          LOG.info("repository root not found for location:" + location.toPresentableString());
          singles.add(location);
        } else {
          map.putValue(root, svnLocation);
        }
      }

      final Set<SVNURL> keys = map.keySet();
      for (SVNURL key : keys) {
        final Collection<RepositoryLocation> repositoryLocations = map.get(key);
        if (repositoryLocations.size() == 1) {
          singles.add(repositoryLocations.iterator().next());
        } else {
          final SvnRepositoryLocationGroup group =
              new SvnRepositoryLocationGroup(key, repositoryLocations);
          groups.add(group);
        }
      }
      return new Pair<List<RepositoryLocationGroup>, List<RepositoryLocation>>(groups, singles);
    }
 public void checkForOutsideCopies() {
   boolean canceled = false;
   for (Iterator<WCInfo> iterator = myWcInfos.iterator(); iterator.hasNext(); ) {
     final WCInfo wcInfo = iterator.next();
     if (!wcInfo.isIsWcRoot()) {
       File path = new File(wcInfo.getPath());
       path = SvnUtil.getWorkingCopyRoot(path);
       int result =
           Messages.showYesNoCancelDialog(
               SvnBundle.message("upgrade.format.clarify.for.outside.copies.text", path),
               SvnBundle.message("action.change.wcopy.format.task.title"),
               Messages.getWarningIcon());
       if (DialogWrapper.CANCEL_EXIT_CODE == result) {
         canceled = true;
         break;
       } else if (DialogWrapper.OK_EXIT_CODE != result) {
         // no - for this copy only. maybe other
         iterator.remove();
       }
     }
   }
   if (canceled) {
     myWcInfos.clear();
   }
 }
    @Override
    protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock)
        throws SAXException {
      final String path = attributes.getValue("path");
      assertSAX(path != null);
      final File file = SvnUtil.resolvePath(myBase, path);
      status.setFile(file);
      final boolean exists = file.exists();
      if (exists) {
        status.setKind(exists, NodeKind.from(file.isDirectory()));
      } else {
        // this is a hack. This is done so because of strange svn native client output:
        /*
                c:\TestProjects\sortedProjects\Subversion\local\withExt82420\mod4>svn st --xml
                <?xml version="1.0" encoding="UTF-8"?>
                <status>
                <target
                   path=".">
                <entry
                   path="mod4">
                <wc-status
                   props="none"
                   item="unversioned">
                </wc-status>
                </entry>
                </target>
                </status>

                while

        c:\TestProjects\sortedProjects\Subversion\local\withExt82420\mod4>dir
         Volume in drive C has no label.
         Volume Serial Number is B4EA-B379

         Directory of c:\TestProjects\sortedProjects\Subversion\local\withExt82420\mod4

        03/09/2012  05:30 PM    <DIR>          .
        03/09/2012  05:30 PM    <DIR>          ..
        03/09/2012  05:30 PM               437 mod4.iml
        03/09/2012  05:30 PM    <DIR>          src

        and no "mod4" under

                */
        final StatusType ns = status.getNodeStatus();
        if (myBase.getName().equals(path)
            && !StatusType.MISSING.equals(ns)
            && !StatusType.STATUS_DELETED.equals(ns)) {
          status.setKind(true, NodeKind.DIR);
          status.setFile(myBase);
          status.setPath("");
          return;
        }
        status.setKind(exists, NodeKind.UNKNOWN);
      }
      status.setPath(path);
    }
  private void collectLogEntries(
      final ProgressIndicator indicator,
      FilePath file,
      VcsException[] exception,
      final Consumer<VcsFileRevision> result,
      final Ref<Boolean> supports15Ref)
      throws SVNException, VcsException {
    SVNWCClient wcClient = myVcs.createWCClient();
    SVNInfo info =
        wcClient.doInfo(new File(file.getIOFile().getAbsolutePath()), SVNRevision.UNDEFINED);
    wcClient.setEventHandler(
        new ISVNEventHandler() {
          public void handleEvent(SVNEvent event, double progress) throws SVNException {}

          public void checkCancelled() throws SVNCancelException {
            indicator.checkCanceled();
          }
        });
    if (info == null || info.getRepositoryRootURL() == null) {
      exception[0] =
          new VcsException("File ''{0}'' is not under version control" + file.getIOFile());
      return;
    }
    final String url = info.getURL() == null ? null : info.getURL().toString();
    String relativeUrl = url;
    final SVNURL repoRootURL = info.getRepositoryRootURL();

    final String root = repoRootURL.toString();
    if (url != null && url.startsWith(root)) {
      relativeUrl = url.substring(root.length());
    }
    if (indicator != null) {
      indicator.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", url));
    }
    final SVNRevision pegRevision = info.getRevision();
    SVNLogClient client = myVcs.createLogClient();

    final boolean supports15 = SvnUtil.checkRepositoryVersion15(myVcs, url);
    supports15Ref.set(supports15);
    client.doLog(
        new File[] {new File(file.getIOFile().getAbsolutePath())},
        SVNRevision.HEAD,
        SVNRevision.create(1),
        SVNRevision.UNDEFINED,
        false,
        true,
        supports15,
        0,
        null,
        new MyLogEntryHandler(
            myVcs, url, pegRevision, relativeUrl, result, repoRootURL, file.getCharset()));
  }
  public void run(@NotNull final ProgressIndicator indicator) {
    ProjectLevelVcsManager.getInstanceChecked(myProject).startBackgroundVcsOperation();
    indicator.setIndeterminate(true);
    final boolean supportsChangelists = myNewFormat.supportsChangelists();
    if (supportsChangelists) {
      myBeforeChangeLists = ChangeListManager.getInstance(myProject).getChangeListsCopy();
    }
    final SVNWCClient wcClient = myVcs.createWCClient();

    try {
      for (WCInfo wcInfo : myWcInfos) {
        File path = new File(wcInfo.getPath());
        if (!wcInfo.isIsWcRoot()) {
          path = SvnUtil.getWorkingCopyRoot(path);
        }
        indicator.setText(
            SvnBundle.message(
                "action.change.wcopy.format.task.progress.text",
                path.getAbsolutePath(),
                SvnUtil.formatRepresentation(wcInfo.getFormat()),
                SvnUtil.formatRepresentation(myNewFormat)));
        try {
          wcClient.doSetWCFormat(path, myNewFormat.getFormat());
        } catch (Throwable e) {
          myExceptions.add(e);
        }
      }
    } finally {
      ProjectLevelVcsManager.getInstance(myProject).stopBackgroundVcsOperation();

      // to map to native
      if (supportsChangelists) {
        SvnVcs.getInstance(myProject).processChangeLists(myBeforeChangeLists);
      }

      ApplicationManager.getApplication().getMessageBus().syncPublisher(SvnVcs.WC_CONVERTED).run();
    }
  }
예제 #7
0
  public boolean needsInteraction(final UpdatedFiles updatedFiles) {
    if (myChangesUnderProjectRoot) {
      refreshChangeListsFindConflicts(updatedFiles);
    } else {
      final FileGroup conflictedGroup =
          updatedFiles.getGroupById(FileGroup.MERGED_WITH_CONFLICT_ID);
      for (String filename : conflictedGroup.getFiles()) {
        final VirtualFile vf = SvnUtil.getVirtualFile(filename);
        myConflictedVirtualFiles.add(vf);
      }
    }

    return ((!myConflictedVirtualFiles.isEmpty()) || (!haveUnresolvedConflicts(updatedFiles)))
        && (!SvnConfiguration.getInstance(myProject).MERGE_DRY_RUN);
  }
 private ByteArrayOutputStream getBaseRevisionContents(
     @NotNull SvnVcs vcs, @NotNull VirtualFile file) {
   ByteArrayOutputStream bos = new ByteArrayOutputStream();
   try {
     byte[] contents =
         SvnUtil.getFileContents(
             vcs,
             SvnTarget.fromFile(new File(file.getPath())),
             SVNRevision.BASE,
             SVNRevision.UNDEFINED);
     bos.write(contents);
   } catch (VcsException | IOException e) {
     LOG.warn(e);
   }
   return bos;
 }
예제 #9
0
 @Override
 public void run(ContinuationContext context) {
   try {
     final List<TaskDescriptor> tasks = new LinkedList<TaskDescriptor>();
     final boolean supportsMergeinfo =
         myWcInfo.getFormat().supportsMergeInfo()
             && SvnUtil.doesRepositorySupportMergeinfo(
                 myVcs, SVNURL.parseURIEncoded(mySourceUrl));
     if (!supportsMergeinfo) {
       insertMergeAll(tasks);
     } else {
       tasks.add(new MergeAllOrSelectedChooser());
     }
     context.next(tasks);
   } catch (SVNException e) {
     finishWithError(context, e.getMessage(), true);
   }
 }
 private void collectLogEntriesForRepository(
     final ProgressIndicator indicator,
     FilePath file,
     final Consumer<VcsFileRevision> result,
     final Ref<Boolean> supports15Ref)
     throws SVNException, VcsException {
   final String url = file.getPath().replace('\\', '/');
   if (indicator != null) {
     indicator.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", url));
   }
   SVNWCClient wcClient = myVcs.createWCClient();
   final SVNURL svnurl = SVNURL.parseURIEncoded(url);
   SVNInfo info = wcClient.doInfo(svnurl, SVNRevision.UNDEFINED, SVNRevision.HEAD);
   final String root = info.getRepositoryRootURL().toString();
   String relativeUrl = url;
   if (url.startsWith(root)) {
     relativeUrl = url.substring(root.length());
   }
   SVNLogClient client = myVcs.createLogClient();
   final boolean supports15 = SvnUtil.checkRepositoryVersion15(myVcs, root);
   supports15Ref.set(supports15);
   // todo log in history provider
   client.doLog(
       svnurl,
       new String[] {},
       SVNRevision.UNDEFINED,
       SVNRevision.HEAD,
       SVNRevision.create(1),
       false,
       true,
       supports15,
       0,
       null,
       new RepositoryLogEntryHandler(
           myVcs, url, SVNRevision.UNDEFINED, relativeUrl, result, info.getRepositoryRootURL()));
 }
 @Nullable
 public RepositoryLocation getLocationFor(final FilePath root) {
   final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
   final String url = SvnUtil.getExactLocation(myVcs, root.getIOFile());
   return url == null ? null : new SvnRepositoryLocation(url);
 }
 protected void initSupports15() {
   assert myUrl != null;
   mySupport15 = SvnUtil.checkRepositoryVersion15(myVcs, myUrl);
 }
예제 #13
0
    @Override
    protected void load() {
      if (myPI != null) {
        myPI.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", myUrl));
      }

      try {
        if (myForceBackwards) {
          SVNURL svnurl = SVNURL.parseURIEncoded(myUrl);
          if (!existsNow(svnurl)) {
            loadBackwards(svnurl);
            return;
          }
        }

        final SVNURL svnurl = SVNURL.parseURIEncoded(myUrl);
        SVNRevision operationalFrom = myFrom == null ? SVNRevision.HEAD : myFrom;
        // TODO: try to rewrite without separately retrieving repository url by item url - as this
        // command could require authentication
        // TODO: and it is not "clear enough/easy to implement" with current design (for some cases)
        // how to cache credentials (if in
        // TODO: non-interactive mode)
        final SVNURL rootURL = SvnUtil.getRepositoryRoot(myVcs, svnurl);
        if (rootURL == null) {
          throw new VcsException("Could not find repository root for URL: " + myUrl);
        }
        final String root = rootURL.toString();
        String relativeUrl = myUrl;
        if (myUrl.startsWith(root)) {
          relativeUrl = myUrl.substring(root.length());
        }
        SvnTarget target = SvnTarget.fromURL(svnurl, myPeg == null ? myFrom : myPeg);
        RepositoryLogEntryHandler handler =
            new RepositoryLogEntryHandler(
                myVcs,
                myUrl,
                SVNRevision.UNDEFINED,
                relativeUrl,
                createConsumerAdapter(myConsumer),
                rootURL);

        myVcs
            .getFactory(target)
            .createHistoryClient()
            .doLog(
                target,
                operationalFrom,
                myTo == null ? SVNRevision.create(1) : myTo,
                false,
                true,
                myShowMergeSources && mySupport15,
                myLimit + 1,
                null,
                handler);
      } catch (SVNCancelException e) {
        //
      } catch (SVNException e) {
        myException = new VcsException(e);
      } catch (VcsException e) {
        myException = e;
      }
    }