当前位置: 首页>>代码示例>>Java>>正文


Java SVNRepository.getLatestRevision方法代码示例

本文整理汇总了Java中org.tmatesoft.svn.core.io.SVNRepository.getLatestRevision方法的典型用法代码示例。如果您正苦于以下问题:Java SVNRepository.getLatestRevision方法的具体用法?Java SVNRepository.getLatestRevision怎么用?Java SVNRepository.getLatestRevision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.tmatesoft.svn.core.io.SVNRepository的用法示例。


在下文中一共展示了SVNRepository.getLatestRevision方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLastRevision

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
private long getLastRevision(boolean deleted) throws SVNException {
    SVNRepository repository = getStore().getRepository();
    if (repository.getLatestRevision() == 0) {
        //new repository cannot hold a revision yet (MCR-1196)
        return -1;
    }
    final String path = getFilePath();
    String dir = getDirectory();
    LastRevisionLogHandler lastRevisionLogHandler = new LastRevisionLogHandler(path, deleted);
    int limit = 0; //we stop through LastRevisionFoundException
    try {
        repository.log(new String[] { dir }, repository.getLatestRevision(), 0, true, true, limit, false, null,
            lastRevisionLogHandler);
    } catch (LastRevisionFoundException ignored) {
    }
    return lastRevisionLogHandler.getLastRevision();
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:18,代码来源:MCRVersionedMetadata.java

示例2: correctRevision

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
private SVNRevision correctRevision(final UpdateRootInfo value, final SVNURL url, final SVNRevision updateRevision) throws SVNException {
  if (SVNRevision.HEAD.equals(value.getRevision())) {
    // find acual revision to update to (a bug if just say head in switch)
    SVNRepository repository = null;
    try {
      repository = myVcs.createRepository(url);
      final long longRevision = repository.getLatestRevision();
      final SVNRevision newRevision = SVNRevision.create(longRevision);
      value.setRevision(newRevision);
      return newRevision;
    } finally {
      if (repository != null) {
        repository.closeSession();
      }
    }
  }
  return updateRevision;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:SvnUpdateEnvironment.java

示例3: lockForce

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
/**
 * Check to stealing lock.
 *
 * @throws Exception
 */
@Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class)
public void lockForce(@NotNull SvnTesterFactory factory) throws Exception {
  try (SvnTester server = factory.create()) {
    final SVNRepository repo = server.openSvnRepository();

    createFile(repo, "/example.txt", "", propsEolNative);
    final long latestRevision = repo.getLatestRevision();

    SVNLock oldLock = lock(repo, "example.txt", latestRevision, false, null);
    Assert.assertNotNull(oldLock);
    compareLock(oldLock, repo.getLock("example.txt"));

    SVNLock badLock = lock(repo, "example.txt", latestRevision, false, SVNErrorCode.FS_PATH_ALREADY_LOCKED);
    Assert.assertNull(badLock);
    compareLock(oldLock, repo.getLock("example.txt"));

    SVNLock newLock = lock(repo, "example.txt", latestRevision, true, null);
    Assert.assertNotNull(newLock);
    compareLock(newLock, repo.getLock("example.txt"));
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:27,代码来源:SvnLockTest.java

示例4: unlockTwice

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
/**
 * Try to twice remove lock.
 *
 * @throws Exception
 */
@Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class)
public void unlockTwice(@NotNull SvnTesterFactory factory) throws Exception {
  try (SvnTester server = factory.create()) {
    final SVNRepository repo = server.openSvnRepository();

    createFile(repo, "/example.txt", "", propsEolNative);
    final long latestRevision = repo.getLatestRevision();

    // New lock
    final SVNLock lock = lock(repo, "example.txt", latestRevision, false, null);
    Assert.assertNotNull(lock);
    unlock(repo, lock, false, null);
    unlock(repo, lock, false, SVNErrorCode.FS_NO_SUCH_LOCK);
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:21,代码来源:SvnLockTest.java

示例5: testReplayFileModification

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
@Test
public void testReplayFileModification() throws Exception {
  try (SvnTestServer server = SvnTestServer.createEmpty()) {
    final URL repoMark = ReplayTest.class.getResource("repo/format");
    final SVNURL url = SVNURL.fromFile(new File(repoMark.getPath()).getParentFile());
    final SVNRepository srcRepo = SVNRepositoryFactory.create(url);
    final SVNRepository dstRepo = server.openSvnRepository();

    long lastRevision = srcRepo.getLatestRevision();
    log.info("Start replay");
    for (long revision = 1; revision <= lastRevision; revision++) {
      final SVNPropertyValue message = srcRepo.getRevisionPropertyValue(revision, "svn:log");
      log.info("  replay commit #{}: {}", revision, StringHelper.getFirstLine(message.getString()));
      replayRangeRevision(srcRepo, dstRepo, revision, false);
      log.info("  compare revisions #{}: {}", revision, StringHelper.getFirstLine(message.getString()));
      compareRevision(srcRepo, revision, dstRepo, dstRepo.getLatestRevision());
    }
    log.info("End replay");
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:21,代码来源:ReplayTest.java

示例6: close

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
@Override
public void close() throws Exception {
  final SVNRepository repo = openSvnRepository(url);
  long revision = repo.getLatestRevision();
  try {
    final SVNLock[] locks = repo.getLocks(suffix);
    if (locks.length > 0) {
      final SVNURL root = repo.getRepositoryRoot(true);
      final Map<String, String> locksMap = new HashMap<>();
      for (SVNLock lock : locks) {
        final String relativePath = SVNURLUtil.getRelativeURL(url, root.appendPath(lock.getPath(), false), false);
        locksMap.put(relativePath, lock.getID());
      }
      repo.unlock(locksMap, true, null);
    }
    final ISVNEditor editor = repo.getCommitEditor("Remove subdir for test", null, false, null);
    editor.openRoot(-1);
    editor.deleteEntry(suffix, revision);
    editor.closeEdit();
  } finally {
    repo.closeSession();
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:24,代码来源:SvnTesterExternal.java

示例7: commitRootWithoutProperties

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
/**
 * Check commit .gitattributes.
 *
 * @throws Exception
 */
@Test
public void commitRootWithoutProperties() throws Exception {
  try (SvnTestServer server = SvnTestServer.createEmpty()) {
    final SVNRepository repo = server.openSvnRepository();

    createFile(repo, "/.gitattributes", "", propsEolNative);
    try {
      long latestRevision = repo.getLatestRevision();
      final ISVNEditor editor = repo.getCommitEditor("Modify .gitattributes", null, false, null);
      editor.openRoot(latestRevision);
      // Empty file.
      final String filePath = "/.gitattributes";
      editor.openFile(filePath, latestRevision);
      sendDeltaAndClose(editor, filePath, "", "*.txt\t\t\ttext eol=native\n");
      // Close dir
      editor.closeDir();
      editor.closeEdit();
      Assert.fail();
    } catch (SVNException e) {
      Assert.assertTrue(e.getMessage().contains(SVNProperty.INHERITABLE_AUTO_PROPS));
    }
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:29,代码来源:SvnFilePropertyTest.java

示例8: lockNotFile

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
/**
 * Check to take lock of out-of-date file.
 *
 * @throws Exception
 */
@Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class)
public void lockNotFile(@NotNull SvnTesterFactory factory) throws Exception {
  try (SvnTester server = factory.create()) {
    final SVNRepository repo = server.openSvnRepository();

    final ISVNEditor editor = repo.getCommitEditor("Intital state", null, false, null);
    editor.openRoot(-1);
    editor.addDir("/example", null, -1);
    editor.addFile("/example/example.txt", null, -1);
    editor.changeFileProperty("/example/example.txt", SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE));
    sendDeltaAndClose(editor, "/example/example.txt", null, "Source content");
    editor.closeDir();
    editor.closeDir();
    editor.closeEdit();

    final long latestRevision = repo.getLatestRevision();
    lock(repo, "example", latestRevision, false, SVNErrorCode.FS_NOT_FILE);
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:25,代码来源:SvnLockTest.java

示例9: copyAndModify

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
/**
 * Copy file with filter change.
 *
 * @throws Exception
 */
@Test()
public void copyAndModify() throws Exception {
  try (SvnTestServer server = SvnTestServer.createEmpty()) {
    final SVNRepository repo = server.openSvnRepository();

    // Add filter to file.
    createFile(repo, "/.gitattributes", "/*.z\t\t\tfilter=gzip\n", propsNative);
    // Create source file.
    createFile(repo, "/data.txt", CONTENT_FOO, propsNative);
    // Copy source file with "raw" filter to destination with "gzip" filter.
    {
      final long rev = repo.getLatestRevision();
      final ISVNEditor editor = repo.getCommitEditor("Copy file commit", null, false, null);
      editor.openRoot(-1);
      editor.addFile("data.z", "data.txt", rev);
      sendDeltaAndClose(editor, "data.z", CONTENT_FOO, CONTENT_BAR);
      editor.closeDir();
      editor.closeEdit();
    }
    // On file read now we must have uncompressed content.
    checkFileContent(repo, "/data.z", CONTENT_BAR);
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:29,代码来源:SvnFilterTest.java

示例10: timeoutShutdown

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
/**
 * Check simple shutdown:
 * <p>
 * * All old connection have a small time to finish work.
 * * New connection is not accepted.
 *
 * @throws Exception
 */
@Test
public void timeoutShutdown() throws Exception {
  final Map<String, Thread> oldThreads = getAllThreads();
  final SvnTestServer server = SvnTestServer.createEmpty();
  final SVNRepository repo = server.openSvnRepository();
  repo.getLatestRevision();
  final ISVNEditor editor = repo.getCommitEditor("Empty commit", null, false, null);
  editor.openRoot(-1);
  server.startShutdown();
  server.shutdown(FORCE_TIME);
  checkThreads(oldThreads);
  try {
    editor.closeDir();
    editor.closeEdit();
    repo.closeSession();
  } catch (SVNException ignored) {
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:27,代码来源:ShutdownTest.java

示例11: runUrlDiff

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
private Collection<Change> runUrlDiff() throws SVNException {
  SVNRepository sourceRepository = myVcs.getSvnKitManager().createRepository(myTarget1.getURL());
  sourceRepository.setCanceller(new SvnKitProgressCanceller());
  SvnDiffEditor diffEditor;
  final long rev;
  SVNRepository targetRepository = null;
  try {
    rev = sourceRepository.getLatestRevision();
    // generate Map of path->Change
    targetRepository = myVcs.getSvnKitManager().createRepository(myTarget2.getURL());
    diffEditor = new SvnDiffEditor(sourceRepository, targetRepository, -1, false);
    final ISVNEditor cancellableEditor = SVNCancellableEditor.newInstance(diffEditor, new SvnKitProgressCanceller(), null);
    sourceRepository.diff(myTarget2.getURL(), rev, rev, null, true, true, false, new ISVNReporterBaton() {
      public void report(ISVNReporter reporter) throws SVNException {
        reporter.setPath("", null, rev, false);
        reporter.finishReport();
      }
    }, cancellableEditor);

    return diffEditor.getChangesMap().values();
  }
  finally {
    sourceRepository.closeSession();
    if (targetRepository != null) {
      targetRepository.closeSession();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:SvnKitDiffClient.java

示例12: execute

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
public void execute() throws SVNException {
    // TODO: Check whether the directory exists already
    String versionName = getRequestHeader(SVN_VERSION_NAME_HEADER);
    long version = DAVResource.INVALID_REVISION;
    try {
        version = Long.parseLong(versionName);
    } catch (NumberFormatException e) {
    }

    DAVRepositoryManager manager = getRepositoryManager();

    // use latest version, if no version was specified
    SVNRepository resourceRepository = SVNGitRepositoryFactory.create(SVNURL.parseURIEncoded(manager.getResourceRepositoryRoot()));
    if ( version == -1 )
    {
      version = resourceRepository.getLatestRevision();
    }
    resourceRepository.testConnection(); // to open the repository

    DAVResourceURI resourceURI =
            new DAVResourceURI(manager.getResourceContext(), manager.getResourcePathInfo(), null, false, version);
    String activityId = resourceURI.getActivityID();
    if (!emptyDirss.containsKey(activityId)) {
        emptyDirss.put(activityId, new HashSet<String>());
    }
    Set<String> emptyDirs = emptyDirss.get(activityId);

    String path = resourceURI.getPath();
    path = DAVPathUtil.dropLeadingSlash(path);
    emptyDirs.add(path);

    // 1. 이미 존재하면 에러 - 에러 안내면 안되나. 그냥 안낼래
    // 2. 빈 디렉토리라면 에러

    handleDAVCreated(null, "Collection", false);
}
 
开发者ID:naver,项目名称:svngit,代码行数:37,代码来源:SVNGitMakeCollectionHandler.java

示例13: getLastMergedRevision

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
@Nullable
private String getLastMergedRevision(final SVNRevision rev2, final SVNURL svnURL2) {
  if (!rev2.isValid() || rev2.isLocal()) {
    return null;
  }
  else {
    final long number = rev2.getNumber();
    if (number > 0) {
      return String.valueOf(number);
    }
    else {

      SVNRepository repos = null;
      try {
        repos = myVcs.createRepository(svnURL2.toString());
        final long latestRev = repos.getLatestRevision();
        return String.valueOf(latestRev);
      }
      catch (SVNException e) {
        return null;
      } finally {
        if (repos != null) {
          repos.closeSession();
        }
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:SvnIntegrateEnvironment.java

示例14: BranchMerger

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
public BranchMerger(final SvnVcs vcs,
                    final SVNURL sourceUrl,
                    final SVNURL targetUrl, final String targetPath,
                    final UpdateEventHandler handler,
                    final boolean isReintegrate, final String branchName, final long sourceCopyRevision) {
  myVcs = vcs;
  myTargetPath = targetPath;
  mySourceUrl = sourceUrl;
  myTargetUrl = targetUrl;
  myHandler = handler;
  myReintegrate = isReintegrate;
  myBranchName = branchName;
  mySourceCopyRevision = sourceCopyRevision;
  myAtStart = true;
  SVNRepository repository = null;
  try {
    repository = myVcs.createRepository(mySourceUrl);
    mySourceLatestRevision = repository.getLatestRevision();
  }
  catch (SVNException e) {
    mySourceLatestRevision = SVNRevision.HEAD.getNumber();
  } finally {
    if (repository != null) {
      repository.closeSession();
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:BranchMerger.java

示例15: getLocks

import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
/**
 * Check get locks.
 *
 * @throws Exception
 */
@Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class)
public void getLocks(@NotNull SvnTesterFactory factory) throws Exception {
  try (SvnTester server = factory.create()) {
    final SVNRepository repo = server.openSvnRepository();
    {
      final ISVNEditor editor = repo.getCommitEditor("Intital state", null, false, null);
      editor.openRoot(-1);
      editor.addDir("/example", null, -1);
      editor.addFile("/example/example.txt", null, -1);
      editor.changeFileProperty("/example/example.txt", SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE));
      sendDeltaAndClose(editor, "/example/example.txt", null, "Source content");
      editor.closeDir();
      editor.addFile("/foo.txt", null, -1);
      editor.changeFileProperty("/foo.txt", SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE));
      sendDeltaAndClose(editor, "/foo.txt", null, "Source content");
      editor.closeDir();
      editor.closeEdit();
    }
    compareLocks(repo.getLocks(""));

    final long latestRevision = repo.getLatestRevision();
    // Lock
    final SVNLock lock1 = lock(repo, "/example/example.txt", latestRevision, false, null);
    Assert.assertNotNull(lock1);
    final SVNLock lock2 = lock(repo, "/foo.txt", latestRevision, false, null);
    Assert.assertNotNull(lock2);

    compareLocks(repo.getLocks(""), lock1, lock2);
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:36,代码来源:SvnLockTest.java


注:本文中的org.tmatesoft.svn.core.io.SVNRepository.getLatestRevision方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。