コード例 #1
0
 protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath)
     throws SVNException {
   Date date = logEntry.getDate();
   String author = logEntry.getAuthor();
   String message = logEntry.getMessage();
   SVNRevision rev = SVNRevision.create(logEntry.getRevision());
   final SVNURL url = myRepositoryRoot.appendPath(myLastPath, true);
   return new SvnFileRevision(
       myVcs, myPegRevision, rev, url.toString(), author, date, message, copyPath, myCharset);
 }
コード例 #2
0
 @Override
 protected SvnFileRevision createRevision(
     final LogEntry logEntry, final String copyPath, LogEntryPath entryPath)
     throws SVNException {
   final SVNURL url =
       entryPath == null
           ? myRepositoryRoot.appendPath(myLastPathCorrector.getBefore(), false)
           : myRepositoryRoot.appendPath(entryPath.getPath(), true);
   return new SvnFileRevision(
       myVcs, SVNRevision.UNDEFINED, logEntry, url.toString(), copyPath, null);
 }
コード例 #3
0
  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()));
  }
コード例 #4
0
ファイル: SVNRepository.java プロジェクト: ryuneeee/yobi
  @Override
  public List<Commit> getHistory(int page, int limit, String until)
      throws AmbiguousObjectException, IOException, NoHeadException, GitAPIException, SVNException {
    // Get the repository
    SVNURL svnURL = SVNURL.fromFile(new File(repoPrefix + ownerName + "/" + projectName));
    org.tmatesoft.svn.core.io.SVNRepository repository = SVNRepositoryFactory.create(svnURL);

    // path to get log
    String[] paths = {"/"};

    // Determine revisions
    long startRevision = repository.getLatestRevision() - page * limit;
    long endRevision = startRevision - limit;
    if (endRevision < 1) {
      endRevision = 1;
    }

    // No log to return.
    if (startRevision < endRevision) {
      return new ArrayList<>();
    }

    // Get the logs
    List<Commit> result = new ArrayList<>();
    for (Object entry : repository.log(paths, null, startRevision, endRevision, false, false)) {
      result.add(new SvnCommit((SVNLogEntry) entry));
    }

    return result;
  }
コード例 #5
0
ファイル: SvnLockTest.java プロジェクト: kstarsinic/svnkit
  @Test
  public void testRecursiveInfoGetsFileLock() throws Exception {
    final TestOptions options = TestOptions.getInstance();

    final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
    final Sandbox sandbox =
        Sandbox.createWithCleanup(getTestName() + ".testRecursiveInfoGetsFileLock", options);
    try {
      final SVNURL url = sandbox.createSvnRepository();

      final CommitBuilder commitBuilder = new CommitBuilder(url);
      commitBuilder.addFile("directory/file");
      commitBuilder.commit();

      final SVNURL fileUrl = url.appendPath("directory/file", false);

      final String lockMessage = "lock message";

      final SvnSetLock setLock = svnOperationFactory.createSetLock();
      setLock.setSingleTarget(SvnTarget.fromURL(fileUrl));
      setLock.setLockMessage(lockMessage);
      setLock.run();

      final SVNLock[] lock = new SVNLock[1];

      final SvnGetInfo getInfo = svnOperationFactory.createGetInfo();
      getInfo.setDepth(SVNDepth.INFINITY);
      getInfo.setSingleTarget(SvnTarget.fromURL(url));
      getInfo.setReceiver(
          new ISvnObjectReceiver<SvnInfo>() {
            public void receive(SvnTarget target, SvnInfo info) throws SVNException {
              if (target.getPathOrUrlDecodedString().endsWith("file")) {
                lock[0] = info.getLock();
              }
            }
          });
      getInfo.run();

      Assert.assertNotNull(lock[0]);
      Assert.assertEquals("/directory/file", lock[0].getPath());
      Assert.assertEquals(lockMessage, lock[0].getComment());
    } finally {
      svnOperationFactory.dispose();
      sandbox.dispose();
    }
  }
コード例 #6
0
ファイル: SvnLockTest.java プロジェクト: kstarsinic/svnkit
  @Test
  public void testCommitOfLockedFile() throws SVNException {
    final String fullFilePath = "Project/Prueba/Modify/prueba.txt";
    final String filePath = "Prueba/Modify/prueba.txt";

    final TestOptions options = TestOptions.getInstance();
    final Sandbox sandbox =
        Sandbox.createWithCleanup(getClass().getSimpleName() + ".testModifyLocked", options);
    final SVNURL url = sandbox.createSvnRepository();
    final CommitBuilder commitBuilder = new CommitBuilder(url);
    commitBuilder.addFile(fullFilePath);
    commitBuilder.commit();

    // user paths relative to Project directory.

    SVNRepository repository = SVNRepositoryFactory.create(url.appendPath("Project", false));
    repository.setAuthenticationManager(new BasicAuthenticationManager("user", "password"));
    final Map<String, Long> pathsToRevisions = new HashMap<String, Long>();
    pathsToRevisions.put(filePath, 1l);
    repository.lock(pathsToRevisions, null, false, null);

    repository.closeSession();
    // same user as one who owns the lock.
    repository.setAuthenticationManager(new BasicAuthenticationManager("user", "password"));

    final SVNLock lock = repository.getLock(filePath);
    Assert.assertNotNull(lock);
    Assert.assertNotNull(lock.getID());
    Assert.assertEquals("user", lock.getOwner());

    final Map<String, String> locks = new HashMap<String, String>();

    try {
      tryCommit(filePath, repository, locks);
      Assert.fail();
    } catch (SVNException e) {
      // no lock token.
    }

    locks.put(filePath, lock.getID());
    SVNCommitInfo info = tryCommit(filePath, repository, locks);
    Assert.assertNotNull(info);
    Assert.assertEquals(2, info.getNewRevision());
  }
コード例 #7
0
    @Override
    protected void load() {
      String relativeUrl = myUrl;
      final SVNURL repoRootURL = myInfo.getRepositoryRootURL();

      final String root = repoRootURL.toString();
      if (myUrl != null && myUrl.startsWith(root)) {
        relativeUrl = myUrl.substring(root.length());
      }
      if (myPI != null) {
        myPI.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", myUrl));
      }
      final SVNRevision pegRevision = myInfo.getRevision();
      final SvnTarget target = SvnTarget.fromFile(myFile.getIOFile(), myPeg);
      try {
        myVcs
            .getFactory(target)
            .createHistoryClient()
            .doLog(
                target,
                myFrom == null ? SVNRevision.HEAD : myFrom,
                myTo == null ? SVNRevision.create(1) : myTo,
                false,
                true,
                myShowMergeSources && mySupport15,
                myLimit + 1,
                null,
                new MyLogEntryHandler(
                    myVcs,
                    myUrl,
                    pegRevision,
                    relativeUrl,
                    createConsumerAdapter(myConsumer),
                    repoRootURL,
                    myFile.getCharset()));
      } catch (SVNCancelException e) {
        //
      } catch (SVNException e) {
        myException = new VcsException(e);
      } catch (VcsException e) {
        myException = e;
      }
    }
コード例 #8
0
  @Override
  public <S> List<S> filterUniqueRoots(
      final List<S> in, final Convertor<S, VirtualFile> convertor) {
    if (in.size() <= 1) return in;

    final List<MyPair<S>> infos = new ArrayList<MyPair<S>>(in.size());
    final SvnFileUrlMappingImpl mapping = (SvnFileUrlMappingImpl) getSvnFileUrlMapping();
    final List<S> notMatched = new LinkedList<S>();
    for (S s : in) {
      final VirtualFile vf = convertor.convert(s);
      if (vf == null) continue;

      final File ioFile = new File(vf.getPath());
      SVNURL url = mapping.getUrlForFile(ioFile);
      if (url == null) {
        url = SvnUtil.getUrl(this, ioFile);
        if (url == null) {
          notMatched.add(s);
          continue;
        }
      }
      infos.add(new MyPair<S>(vf, url.toString(), s));
    }
    final List<MyPair<S>> filtered = new ArrayList<MyPair<S>>(infos.size());
    ForNestedRootChecker.filterOutSuperfluousChildren(this, infos, filtered);

    final List<S> converted =
        ObjectsConvertor.convert(
            filtered,
            new Convertor<MyPair<S>, S>() {
              @Override
              public S convert(final MyPair<S> o) {
                return o.getSrc();
              }
            });
    if (!notMatched.isEmpty()) {
      // potential bug is here: order is not kept. but seems it only occurs for cases where result
      // is sorted after filtering so ok
      converted.addAll(notMatched);
    }
    return converted;
  }
コード例 #9
0
    private void loadBackwards(SVNURL svnurl) throws SVNException, VcsException {
      // this method is called when svnurl does not exist in latest repository revision - thus
      // concrete old revision is used for "info"
      // command to get repository url
      Info info = myVcs.getInfo(svnurl, myPeg, myPeg);
      final SVNURL rootURL = info != null ? info.getRepositoryRootURL() : null;
      final String root = rootURL != null ? rootURL.toString() : "";
      String relativeUrl = myUrl;
      if (myUrl.startsWith(root)) {
        relativeUrl = myUrl.substring(root.length());
      }

      final RepositoryLogEntryHandler repositoryLogEntryHandler =
          new RepositoryLogEntryHandler(
              myVcs,
              myUrl,
              SVNRevision.UNDEFINED,
              relativeUrl,
              new ThrowableConsumer<VcsFileRevision, SVNException>() {
                @Override
                public void consume(VcsFileRevision revision) throws SVNException {
                  myConsumer.consume(revision);
                }
              },
              rootURL);
      repositoryLogEntryHandler.setThrowCancelOnMeetPathCreation(true);

      SvnTarget target = SvnTarget.fromURL(rootURL, myFrom);
      myVcs
          .getFactory(target)
          .createHistoryClient()
          .doLog(
              target,
              myFrom,
              myTo == null ? SVNRevision.create(1) : myTo,
              false,
              true,
              myShowMergeSources && mySupport15,
              1,
              null,
              repositoryLogEntryHandler);
    }
コード例 #10
0
    @Override
    protected void load() {
      String relativeUrl = myUrl;
      final SVNURL repoRootURL = myInfo.getRepositoryRootURL();

      final String root = repoRootURL.toString();
      if (myUrl != null && myUrl.startsWith(root)) {
        relativeUrl = myUrl.substring(root.length());
      }
      if (myPI != null) {
        myPI.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", myUrl));
      }
      final SVNRevision pegRevision = myInfo.getRevision();
      SVNLogClient client = myVcs.createLogClient();
      try {
        client.doLog(
            new File[] {new File(myFile.getIOFile().getAbsolutePath())},
            SVNRevision.HEAD,
            SVNRevision.create(1),
            SVNRevision.UNDEFINED,
            false,
            true,
            mySupport15,
            0,
            null,
            new MyLogEntryHandler(
                myVcs,
                myUrl,
                pegRevision,
                relativeUrl,
                myConsumer,
                repoRootURL,
                myFile.getCharset()));
      } catch (SVNCancelException e) {
        //
      } catch (SVNException e) {
        myException = new VcsException(e);
      } catch (VcsException e) {
        myException = e;
      }
    }
コード例 #11
0
ファイル: SVNRepository.java プロジェクト: ryuneeee/yobi
  @Override
  public Commit getCommit(String revNumber) throws IOException, SVNException {
    long rev = Integer.parseInt(revNumber);
    String[] paths = {"/"};
    SVNURL svnURL = SVNURL.fromFile(new File(getRepoPrefix() + ownerName + "/" + projectName));
    org.tmatesoft.svn.core.io.SVNRepository repository = SVNRepositoryFactory.create(svnURL);

    for (Object entry : repository.log(paths, null, rev, rev, false, false)) {
      return new SvnCommit((SVNLogEntry) entry);
    }

    return null;
  }
コード例 #12
0
 private void tryByRoot(
     SvnChangeList[] result, SVNLogClient logger, SVNRevision revisionBefore, SVNURL repositoryUrl)
     throws VcsException {
   final boolean authorized =
       SvnAuthenticationNotifier.passiveValidation(myProject, repositoryUrl);
   if (!authorized) return;
   tryExactHit(
       new SvnRepositoryLocation(repositoryUrl.toString()),
       result,
       logger,
       revisionBefore,
       repositoryUrl,
       repositoryUrl);
 }
コード例 #13
0
ファイル: SVNRepository.java プロジェクト: hoyajigi/yobi
 @Override
 public boolean isEmpty() {
   SVNURL svnURL;
   org.tmatesoft.svn.core.io.SVNRepository repository = null;
   try {
     svnURL = SVNURL.fromFile(getDirectory());
     repository = SVNRepositoryFactory.create(svnURL);
     return repository.getLatestRevision() == 0;
   } catch (SVNException e) {
     throw new RuntimeException(e);
   } finally {
     if (repository != null) {
       repository.closeSession();
     }
   }
 }
コード例 #14
0
 @Override
 protected void load() {
   if (myPI != null) {
     myPI.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", myUrl));
   }
   SVNWCClient wcClient = myVcs.createWCClient();
   try {
     final SVNURL svnurl = SVNURL.parseURIEncoded(myUrl);
     SVNInfo info = null;
     info = wcClient.doInfo(svnurl, SVNRevision.UNDEFINED, SVNRevision.HEAD);
     final String root = info.getRepositoryRootURL().toString();
     String relativeUrl = myUrl;
     if (myUrl.startsWith(root)) {
       relativeUrl = myUrl.substring(root.length());
     }
     SVNLogClient client = myVcs.createLogClient();
     client.doLog(
         svnurl,
         new String[] {},
         SVNRevision.UNDEFINED,
         SVNRevision.HEAD,
         SVNRevision.create(1),
         false,
         true,
         mySupport15,
         0,
         null,
         new RepositoryLogEntryHandler(
             myVcs,
             myUrl,
             SVNRevision.UNDEFINED,
             relativeUrl,
             myConsumer,
             info.getRepositoryRootURL()));
   } catch (SVNCancelException e) {
     //
   } catch (SVNException e) {
     myException = new VcsException(e);
   } catch (VcsException e) {
     myException = e;
   }
 }
コード例 #15
0
ファイル: SVNRepository.java プロジェクト: hoyajigi/yobi
  private String getPatch(long revA, long revB) throws SVNException, UnsupportedEncodingException {
    // Prepare required arguments.
    SVNURL svnURL = SVNURL.fromFile(getDirectory());

    // Get diffClient.
    SVNClientManager clientManager = SVNClientManager.newInstance();
    SVNDiffClient diffClient = clientManager.getDiffClient();

    // Using diffClient, write the changes by commitId into
    // byteArrayOutputStream, as unified format.
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    diffClient.doDiff(
        svnURL,
        null,
        SVNRevision.create(revA),
        SVNRevision.create(revB),
        SVNDepth.INFINITY,
        true,
        byteArrayOutputStream);

    return byteArrayOutputStream.toString(Config.getCharset().name());
  }
コード例 #16
0
ファイル: SVNRepository.java プロジェクト: ryuneeee/yobi
  @Override
  public String getPatch(String commitId) throws SVNException {
    // Prepare required arguments.
    SVNURL svnURL = SVNURL.fromFile(new File(getRepoPrefix() + ownerName + "/" + projectName));
    long rev = Integer.parseInt(commitId);

    // Get diffClient.
    SVNClientManager clientManager = SVNClientManager.newInstance();
    SVNDiffClient diffClient = clientManager.getDiffClient();

    // Using diffClient, write the changes by commitId into
    // byteArrayOutputStream, as unified format.
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    diffClient.doDiff(
        svnURL,
        null,
        SVNRevision.create(rev - 1),
        SVNRevision.create(rev),
        SVNDepth.INFINITY,
        true,
        byteArrayOutputStream);

    return byteArrayOutputStream.toString();
  }
コード例 #17
0
 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()));
 }
コード例 #18
0
  @Nullable
  public static SvnBranchConfigurationNew loadDefaultConfiguration(
      final Project project, final VirtualFile vcsRoot) {
    try {
      final SvnVcs vcs = SvnVcs.getInstance(project);

      File rootFile = new File(vcsRoot.getPath());
      final Info info = vcs.getInfo(rootFile);
      if (info == null || info.getURL() == null) {
        LOG.info("Directory is not a working copy: " + vcsRoot.getPresentableUrl());
        return null;
      }
      SVNURL baseUrl = info.getURL();

      final SvnBranchConfigurationNew result = new SvnBranchConfigurationNew();
      result.setTrunkUrl(baseUrl.toString());
      while (true) {
        final String s = SVNPathUtil.tail(baseUrl.getPath());
        if (s.equalsIgnoreCase(DEFAULT_TRUNK_NAME)
            || s.equalsIgnoreCase(DEFAULT_BRANCHES_NAME)
            || s.equalsIgnoreCase(DEFAULT_TAGS_NAME)) {
          SVNURL rootPath = baseUrl.removePathTail();
          SvnTarget target = SvnTarget.fromURL(rootPath);

          vcs.getFactory(target)
              .createBrowseClient()
              .list(target, SVNRevision.HEAD, Depth.IMMEDIATES, createHandler(result, rootPath));
          break;
        }
        if (SVNPathUtil.removeTail(baseUrl.getPath()).length() == 0) {
          break;
        }
        baseUrl = baseUrl.removePathTail();
      }
      return result;
    } catch (SVNException e) {
      LOG.info(e);
      return null;
    } catch (VcsException e) {
      LOG.info(e);
      return null;
    }
  }
コード例 #19
0
  @Override
  public Pair<SvnChangeList, FilePath> getOneList(final VirtualFile file, VcsRevisionNumber number)
      throws VcsException {
    final RootUrlInfo rootUrlInfo =
        myVcs.getSvnFileUrlMapping().getWcRootForFilePath(new File(file.getPath()));
    if (rootUrlInfo == null) return null;
    final VirtualFile root = rootUrlInfo.getVirtualFile();
    if (root == null) return null;
    final SvnRepositoryLocation svnRootLocation =
        (SvnRepositoryLocation) getLocationFor(new FilePathImpl(root));
    if (svnRootLocation == null) return null;
    final String url = svnRootLocation.getURL();
    final long revision;
    try {
      revision = Long.parseLong(number.asString());
    } catch (NumberFormatException e) {
      throw new VcsException(e);
    }

    final SvnChangeList[] result = new SvnChangeList[1];
    final SVNLogClient logger;
    final SVNRevision revisionBefore;
    final SVNURL repositoryUrl;
    final SVNURL svnurl;
    final SVNInfo targetInfo;
    try {
      logger = myVcs.createLogClient();
      revisionBefore = SVNRevision.create(revision);

      svnurl = SVNURL.parseURIEncoded(url);
      final SVNWCClient client = myVcs.createWCClient();
      final SVNInfo info = client.doInfo(svnurl, SVNRevision.UNDEFINED, SVNRevision.HEAD);
      targetInfo = client.doInfo(new File(file.getPath()), SVNRevision.UNDEFINED);
      if (info == null) {
        throw new VcsException("Can not get repository URL");
      }
      repositoryUrl = info.getRepositoryRootURL();
    } catch (SVNException e) {
      LOG.info(e);
      throw new VcsException(e);
    }

    tryExactHit(svnRootLocation, result, logger, revisionBefore, repositoryUrl, svnurl);
    if (result[0] == null) {
      tryByRoot(result, logger, revisionBefore, repositoryUrl);
      if (result[0] == null) {
        FilePath path =
            tryStepByStep(svnRootLocation, result, logger, revisionBefore, targetInfo, svnurl);
        path = path == null ? new FilePathImpl(file) : path;
        // and pass & take rename context there
        return new Pair<SvnChangeList, FilePath>(result[0], path);
      }
    }
    if (result[0].getChanges().size() == 1) {
      final Collection<Change> changes = result[0].getChanges();
      final Change change = changes.iterator().next();
      final ContentRevision afterRevision = change.getAfterRevision();
      if (afterRevision != null) {
        return new Pair<SvnChangeList, FilePath>(result[0], afterRevision.getFile());
      } else {
        return new Pair<SvnChangeList, FilePath>(result[0], new FilePathImpl(file));
      }
    }
    String relativePath =
        SVNPathUtil.getRelativePath(
            targetInfo.getRepositoryRootURL().toString(), targetInfo.getURL().toString());
    relativePath = relativePath.startsWith("/") ? relativePath : "/" + relativePath;
    final Change targetChange = result[0].getByPath(relativePath);
    if (targetChange == null) {
      FilePath path =
          tryStepByStep(svnRootLocation, result, logger, revisionBefore, targetInfo, svnurl);
      path = path == null ? new FilePathImpl(file) : path;
      // and pass & take rename context there
      return new Pair<SvnChangeList, FilePath>(result[0], path);
    }
    return new Pair<SvnChangeList, FilePath>(result[0], new FilePathImpl(file));
  }
コード例 #20
0
  private void getCommittedChangesImpl(
      ChangeBrowserSettings settings,
      final String url,
      final String[] filterUrls,
      final int maxCount,
      final Consumer<SVNLogEntry> resultConsumer,
      final boolean includeMergedRevisions,
      final boolean filterOutByDate)
      throws VcsException {
    final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
    if (progress != null) {
      progress.setText(SvnBundle.message("progress.text.changes.collecting.changes"));
      progress.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", url));
    }
    try {
      SVNLogClient logger = myVcs.createLogClient();

      final String author = settings.getUserFilter();
      final Date dateFrom = settings.getDateAfterFilter();
      final Long changeFrom = settings.getChangeAfterFilter();
      final Date dateTo = settings.getDateBeforeFilter();
      final Long changeTo = settings.getChangeBeforeFilter();

      final SVNRevision revisionBefore;
      if (dateTo != null) {
        revisionBefore = SVNRevision.create(dateTo);
      } else if (changeTo != null) {
        revisionBefore = SVNRevision.create(changeTo.longValue());
      } else {
        SVNRepository repository = null;
        final long revision;
        try {
          repository = myVcs.createRepository(url);
          revision = repository.getLatestRevision();
        } finally {
          if (repository != null) {
            repository.closeSession();
          }
        }
        revisionBefore = SVNRevision.create(revision);
      }
      final SVNRevision revisionAfter;
      if (dateFrom != null) {
        revisionAfter = SVNRevision.create(dateFrom);
      } else if (changeFrom != null) {
        revisionAfter = SVNRevision.create(changeFrom.longValue());
      } else {
        revisionAfter = SVNRevision.create(1);
      }

      logger.doLog(
          SVNURL.parseURIEncoded(url),
          filterUrls,
          revisionBefore,
          revisionBefore,
          revisionAfter,
          settings.STOP_ON_COPY,
          true,
          includeMergedRevisions,
          maxCount,
          null,
          new ISVNLogEntryHandler() {
            public void handleLogEntry(SVNLogEntry logEntry) {
              if (myProject.isDisposed()) throw new ProcessCanceledException();
              if (progress != null) {
                progress.setText2(
                    SvnBundle.message(
                        "progress.text2.processing.revision", logEntry.getRevision()));
                progress.checkCanceled();
              }
              if (filterOutByDate && logEntry.getDate() == null) {
                // do not add lists without info - this situation is possible for lists where there
                // are paths that user has no rights to observe
                return;
              }
              if (author == null || author.equalsIgnoreCase(logEntry.getAuthor())) {
                resultConsumer.consume(logEntry);
              }
            }
          });
    } catch (SVNException e) {
      throw new VcsException(e);
    }
  }
コード例 #21
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;
      }
    }
コード例 #22
0
 public SVNRepository createRepository(String url) throws SVNException {
   SVNRepository repos = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url));
   repos.setAuthenticationManager(myConfiguration.getAuthenticationManager(this));
   repos.setTunnelProvider(myConfiguration.getOptions(myProject));
   return repos;
 }
コード例 #23
0
ファイル: SvnRemoteList.java プロジェクト: centic9/svnkit
  private void doList(
      SVNRepository repos,
      long rev,
      final ISVNDirEntryHandler handler,
      boolean fetchLocks,
      SVNDepth depth,
      int entryFields,
      SVNURL externalParentUrl,
      String externalTarget)
      throws SVNException {
    boolean includeExternals = !getOperation().isIgnoreExternals();
    Map<SVNURL, SVNPropertyValue> externals =
        includeExternals ? new HashMap<SVNURL, SVNPropertyValue>() : null;
    SVNURL url = repos.getLocation();
    SVNURL reposRoot = repos.getRepositoryRoot(false);
    SVNDirEntry entry = null;
    SVNException error = null;
    try {
      entry = repos.info("", rev);
    } catch (SVNException svne) {
      if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.RA_NOT_IMPLEMENTED) {
        error = svne;
      } else {
        throw svne;
      }
    }
    if (error != null) {
      SVNNodeKind kind = repos.checkPath("", rev);
      if (kind != SVNNodeKind.NONE) {
        if (!url.equals(reposRoot)) {
          String name = SVNPathUtil.tail(repos.getLocation().getPath());
          repos.setLocation(repos.getLocation().removePathTail(), false);
          Collection<SVNDirEntry> dirEntries =
              repos.getDir("", rev, null, entryFields, (Collection) null);
          repos.setLocation(url, false);
          for (Iterator<SVNDirEntry> ents = dirEntries.iterator(); ents.hasNext(); ) {
            SVNDirEntry dirEntry = (SVNDirEntry) ents.next();
            if (name.equals(dirEntry.getName())) {
              entry = dirEntry;
              break;
            }
          }
          if (entry != null) {
            entry.setRelativePath(kind == SVNNodeKind.FILE ? name : "");
          }
        } else {
          SVNProperties props = new SVNProperties();
          repos.getDir("", rev, props, entryFields, (Collection<SVNDirEntry>) null);
          SVNProperties revProps = repos.getRevisionProperties(rev, null);
          String author = revProps.getStringValue(SVNRevisionProperty.AUTHOR);
          String dateStr = revProps.getStringValue(SVNRevisionProperty.DATE);
          Date datestamp = null;
          if (dateStr != null) {
            datestamp = SVNDate.parseDateString(dateStr);
          }
          entry =
              new SVNDirEntry(
                  url, reposRoot, "", kind, 0, !props.isEmpty(), rev, datestamp, author);
          entry.setRelativePath("");
        }
      }
    } else if (entry != null) {
      if (entry.getKind() == SVNNodeKind.DIR) {
        entry.setName("");
      }
      entry.setRelativePath(entry.getKind() == SVNNodeKind.DIR ? "" : entry.getName());
    }
    if (entry == null) {
      SVNErrorMessage err =
          SVNErrorMessage.create(
              SVNErrorCode.FS_NOT_FOUND, "URL ''{0}'' non-existent in that revision", url);
      SVNErrorManager.error(err, SVNLogType.WC);
    }
    final Map locksMap = new SVNHashMap();
    if (fetchLocks) {
      SVNLock[] locks = new SVNLock[0];
      try {
        locks = repos.getLocks("");
      } catch (SVNException e) {
        if (!(e.getErrorMessage() != null
            && e.getErrorMessage().getErrorCode() == SVNErrorCode.RA_NOT_IMPLEMENTED)) {
          throw e;
        }
      }
      if (locks != null && locks.length > 0) {
        SVNURL root = repos.getRepositoryRoot(true);
        for (int i = 0; i < locks.length; i++) {
          String repositoryPath = locks[i].getPath();
          locksMap.put(root.appendPath(repositoryPath, false), locks[i]);
        }
      }
    }
    ISVNDirEntryHandler nestedHandler =
        new ISVNDirEntryHandler() {

          public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException {
            dirEntry.setLock((SVNLock) locksMap.get(dirEntry.getURL()));
            handler.handleDirEntry(dirEntry);
          }
        };
    entry.setExternalParentUrl(externalParentUrl);
    entry.setExternalTarget(externalTarget);
    nestedHandler.handleDirEntry(entry);
    if (entry.getKind() == SVNNodeKind.DIR
        && (depth == SVNDepth.FILES
            || depth == SVNDepth.IMMEDIATES
            || depth == SVNDepth.INFINITY)) {
      list(
          repos,
          "",
          rev,
          depth,
          entryFields,
          externals,
          externalParentUrl,
          externalTarget,
          nestedHandler);
    }

    if (includeExternals && externals != null && externals.size() > 0) {
      listExternals(repos, externals, depth, entryFields, fetchLocks, handler);
    }
  }
コード例 #24
0
ファイル: SVNRepository.java プロジェクト: hoyajigi/yobi
  private org.tmatesoft.svn.core.io.SVNRepository getSVNRepository() throws SVNException {
    SVNURL svnURL = SVNURL.fromFile(getDirectory());

    return SVNRepositoryFactory.create(svnURL);
  }
コード例 #25
0
ファイル: SVNRepository.java プロジェクト: ryuneeee/yobi
  private org.tmatesoft.svn.core.io.SVNRepository getSVNRepository() throws SVNException {
    SVNURL svnURL = SVNURL.fromFile(new File(getRepoPrefix() + ownerName + "/" + projectName));

    return SVNRepositoryFactory.create(svnURL);
  }
コード例 #26
0
ファイル: SvnRemoteList.java プロジェクト: centic9/svnkit
  private static void list(
      SVNRepository repository,
      String path,
      long rev,
      SVNDepth depth,
      int entryFields,
      Map<SVNURL, SVNPropertyValue> externals,
      SVNURL externalParentUrl,
      String externalTarget,
      ISVNDirEntryHandler handler)
      throws SVNException {
    if (depth == SVNDepth.EMPTY) {
      return;
    }
    Collection entries = new TreeSet();
    SVNProperties properties;
    try {
      properties = externals == null ? null : new SVNProperties();
      entries = repository.getDir(path, rev, properties, entryFields, entries);
    } catch (SVNAuthenticationException e) {
      return;
    } catch (SVNException e) {
      if (e.getErrorMessage().getErrorCode() == SVNErrorCode.RA_NOT_AUTHORIZED) {
        return;
      }
      throw e;
    }

    SVNPropertyValue svnExternalsVaule =
        properties == null ? null : properties.getSVNPropertyValue(SVNProperty.EXTERNALS);
    if (svnExternalsVaule != null) {
      SVNURL location = repository.getLocation();
      externals.put(location.appendPath(path, false), svnExternalsVaule);
    }

    for (Iterator iterator = entries.iterator(); iterator.hasNext(); ) {
      SVNDirEntry entry = (SVNDirEntry) iterator.next();
      String childPath = SVNPathUtil.append(path, entry.getName());
      entry.setRelativePath(childPath);
      if (entry.getKind() == SVNNodeKind.FILE
          || depth == SVNDepth.IMMEDIATES
          || depth == SVNDepth.INFINITY) {
        entry.setExternalParentUrl(externalParentUrl);
        entry.setExternalTarget(externalTarget);
        handler.handleDirEntry(entry);
      }
      if (entry.getKind() == SVNNodeKind.DIR
          && entry.getDate() != null
          && depth == SVNDepth.INFINITY) {
        list(
            repository,
            childPath,
            rev,
            depth,
            entryFields,
            externals,
            externalParentUrl,
            externalTarget,
            handler);
      }
    }
  }