本文整理汇总了Java中org.tmatesoft.svn.core.io.SVNRepository类的典型用法代码示例。如果您正苦于以下问题:Java SVNRepository类的具体用法?Java SVNRepository怎么用?Java SVNRepository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SVNRepository类属于org.tmatesoft.svn.core.io包,在下文中一共展示了SVNRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importFiles
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
@Override
public File importFiles(String path, File temp) {
SVNRepository svnRepository = getSVNRepository(repositoryURL, username, password);
try {
OutputStream o = new FileOutputStream(temp);
svnRepository.getFile(path, SVNRevision.HEAD.getNumber(), new SVNProperties(), o);
o.flush();
o.close();
return temp;
} catch (Exception e) {
console.printerrln(e);
return null;
}
}
示例2: connectToSVNInstance
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
public static SVNRepository connectToSVNInstance(String url, String usr,
String pass) {
SvnUtil.setupLibrary();
SVNRepository repository = null;
try {
repository = SvnUtil.createRepository(url);
} catch (SVNException svne) {
System.err
.println("error while creating an SVNRepository for location '"
+ url + "': " + svne.getMessage());
}
ISVNAuthenticationManager authManager = SVNWCUtil
.createDefaultAuthenticationManager(usr, pass);
repository.setAuthenticationManager(authManager);
try {
SvnUtil.verifySVNLocation(repository, url);
} catch (SVNException e) {
e.printStackTrace();
}
return repository;
}
示例3: delete
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
@Override
public void delete(int id) throws IOException {
String commitMsg = "Deleted metadata object " + getID() + "_" + id + " in store";
// Commit to SVN
SVNCommitInfo info;
try {
SVNRepository repository = getRepository();
ISVNEditor editor = repository.getCommitEditor(commitMsg, null);
editor.openRoot(-1);
editor.deleteEntry("/" + getSlotPath(id), -1);
editor.closeDir();
info = editor.closeEdit();
LOGGER.info("SVN commit of delete finished, new revision {}", info.getNewRevision());
} catch (SVNException e) {
LOGGER.error("Error while deleting {} in SVN ", id, e);
} finally {
super.delete(id);
}
}
示例4: retrieve
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
/**
* Retrieves this version of the metadata
*
* @return the metadata document as it was in this version
* @throws MCRUsageException
* if this is a deleted version, which can not be retrieved
*/
public MCRContent retrieve() throws IOException {
if (type == DELETED) {
String msg = "You can not retrieve a deleted version, retrieve a previous version instead";
throw new MCRUsageException(msg);
}
try {
SVNRepository repository = vm.getStore().getRepository();
MCRByteArrayOutputStream baos = new MCRByteArrayOutputStream();
repository.getFile(vm.getStore().getSlotPath(vm.getID()), revision, null, baos);
baos.close();
return new MCRByteContent(baos.getBuffer(), 0, baos.size(), getDate().getTime());
} catch (SVNException e) {
throw new IOException(e);
}
}
示例5: 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();
}
示例6: getCopy
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
public long getCopy(String relativePath, long revision, SVNProperties properties, OutputStream contents) throws SVNException {
// URL 검증
if (relativePath.isEmpty() || relativePath.endsWith("/"))
throw new SVNException(SVNErrorMessage.create(SVNErrorCode.BAD_URL, "Invalide relativePath : " + relativePath));
SVNRepository repository = getRepository();
LOGGER.debug("getCopy : {} ", relativePath);
SVNNodeKind checkPath = repository.checkPath(relativePath, revision);
long result = -1;
if (checkPath == SVNNodeKind.FILE) {
// return the revision the file has been taken at
result = repository.getFile(relativePath, revision, properties, contents);
int lastIndexOf = ValueUtil.lastIndexOf(relativePath, '/');
String fileName = relativePath.substring(lastIndexOf) + 1;
LOGGER.debug(fileName);
}
return result;
}
示例7: list
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
/********************************
* 작성일 : 2016. 5. 4. 작성자 : KYJ
*
* path에 속하는 구성정보 조회
*
* @param path
* @param revision
* @param exceptionHandler
* @return
********************************/
public List<String> list(String path, String revision, Consumer<Exception> exceptionHandler) {
List<String> resultList = Collections.emptyList();
try {
SVNProperties fileProperties = new SVNProperties();
SVNRepository repository = getRepository();
Collection<SVNDirEntry> dir = repository.getDir(path, Long.parseLong(revision), fileProperties, new ArrayList<>());
resultList = dir.stream().map(d -> {
SVNNodeKind kind = d.getKind();
if (SVNNodeKind.DIR == kind) {
return d.getRelativePath().concat("/");
} else {
return d.getRelativePath();
}
}).collect(Collectors.toList());
} catch (SVNException e) {
LOGGER.error(ValueUtil.toString(e));
if (exceptionHandler != null)
exceptionHandler.accept(e);
}
return resultList;
}
示例8: supportsMergeTracking
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
@Override
public boolean supportsMergeTracking(@NotNull SVNURL url) throws VcsException {
SVNRepository repository = null;
try {
repository = myVcs.getSvnKitManager().createRepository(url);
return repository.hasCapability(SVNCapability.MERGE_INFO);
}
catch (SVNException e) {
throw new SvnBindException(e);
}
finally {
if (repository != null) {
repository.closeSession();
}
}
}
示例9: CachingSvnRepositoryPool
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
public CachingSvnRepositoryPool(ThrowableConvertor<SVNURL, SVNRepository, SVNException> creator,
final int maxCached, final int maxConcurrent,
ThrowableConsumer<Pair<SVNURL, SVNRepository>, SVNException> adjuster,
final ApplicationLevelNumberConnectionsGuard guard) {
myGuard = guard;
myLock = new Object();
myConnectionTimeout = DEFAULT_IDLE_TIMEOUT;
myCreator = creator;
myAdjuster = adjuster;
myMaxCached = maxCached > 0 ? maxCached : ourMaxCachedDefault;
myMaxConcurrent = maxConcurrent > 0 ? maxConcurrent : ourMaxConcurrentDefault;
if (myMaxConcurrent < myMaxCached) {
myMaxConcurrent = myMaxCached;
}
myGroups = new HashMap<String, RepoGroup>();
myDisposed = false;
}
示例10: RepoGroup
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
private RepoGroup(ThrowableConvertor<SVNURL, SVNRepository, SVNException> creator, int cached, int concurrent,
final ThrowableConsumer<Pair<SVNURL, SVNRepository>, SVNException> adjuster,
final ApplicationLevelNumberConnectionsGuard guard, final Object waitObj, final long connectionTimeout) {
myCreator = creator;
myMaxCached = cached;
myMaxConcurrent = concurrent;
myAdjuster = adjuster;
myGuard = guard;
myConnectionTimeout = connectionTimeout;
myInactive = new TreeMap<Long, SVNRepository>();
myUsed = new HashSet<SVNRepository>();
myDisposed = false;
myWait = waitObj;
}
示例11: dispose
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
public void dispose() {
final List<SVNRepository> listForClose = new ArrayList<SVNRepository>();
listForClose.addAll(myInactive.values());
myInactive.clear();
myUsed.clear(); // todo use counter instead of list??
synchronized (myWait) {
myWait.notifyAll();
}
myDisposed = true;
myWait.notifyAll();
myGuard.connectionDestroyed(listForClose.size());
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
for (SVNRepository repository : listForClose) {
repository.closeSession();
}
}
});
}
示例12: listEntries
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
public static void listEntries(final SVNRepository repository, final File root, final int i, final String path) throws SVNException, IOException {
final Collection entries = repository.getDir(path, i, null, (Collection) null);
final File revroot = new File(root, i + "");
revroot.mkdirs();
final Iterator iterator = entries.iterator();
while (iterator.hasNext()) {
final SVNDirEntry entry = (SVNDirEntry) iterator.next();
final File file = new File(revroot, (path.equals("") ? "" : path + "/") + entry.getName());
if (entry.getKind() == SVNNodeKind.DIR) {
file.mkdirs();
} else {
file.delete();
IO.writeStringToFile(file, "author=" + entry.getAuthor() + "\r\nrevision=" + entry.getRevision() + "\r\ndate=" + entry.getDate());
}
if (entry.getKind() == SVNNodeKind.DIR) {
listEntries(repository, root, i, (path.equals("")) ? entry.getName() : path + "/" + entry.getName());
}
}
}
示例13: get
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
/**
* Handles a request to retrieve a file from the repository.
*
* @param source Path to the resource to retrieve, including the repository root.
* @param destination The location where the file should be retrieved to.
* @throws IOException If an error occurs retrieving the file.
*/
public void get(String source, File destination) throws IOException {
fireTransferInitiated(getResource(source), TransferEvent.REQUEST_GET);
String repositorySource = source;
if (!source.startsWith(repositoryRoot)) {
repositorySource = getRepositoryRoot() + source;
}
Message.debug("Getting file for user " + userName + " from " + repositorySource + " [revision="
+ svnRetrieveRevision + "] to " + destination.getAbsolutePath());
try {
SVNURL url = SVNURL.parseURIEncoded(repositorySource);
SVNRepository repository = getRepository(url, true);
repository.setLocation(url, false);
Resource resource = getResource(source);
fireTransferInitiated(resource, TransferEvent.REQUEST_GET);
SvnDao svnDAO = new SvnDao(repository);
svnDAO.getFile(url, destination, svnRetrieveRevision);
fireTransferCompleted(destination.length());
} catch (SVNException e) {
Message.error("Error retrieving" + repositorySource + " [revision=" + svnRetrieveRevision + "]");
throw (IOException) new IOException().initCause(e);
}
}
示例14: resolveResource
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
/**
* Fetch the needed file information for a given file (size, last modification time) and report it back in a
* SvnResource.
*
* @param repositorySource Full path to resource in subversion (including host, protocol etc.)
* @return SvnResource filled with the needed informations
*/
protected SvnResource resolveResource(String repositorySource) {
Message.debug("Resolving resource for " + repositorySource + " [revision=" + svnRetrieveRevision + "]");
SvnResource result = null;
try {
SVNURL url = SVNURL.parseURIEncoded(repositorySource);
SVNRepository repository = getRepository(url, true);
SVNNodeKind nodeKind = repository.checkPath("", svnRetrieveRevision);
if (nodeKind == SVNNodeKind.NONE) {
// log this on debug, NOT error, see http://code.google.com/p/ivysvn/issues/detail?id=21
Message.debug("No resource found at " + repositorySource + ", returning default resource");
result = new SvnResource();
} else {
Message.debug("Resource found at " + repositorySource + ", returning resolved resource");
SVNDirEntry entry = repository.info("", svnRetrieveRevision);
result = new SvnResource(this, repositorySource, true, entry.getDate().getTime(), entry.getSize());
}
} catch (SVNException e) {
Message.error("Error resolving resource " + repositorySource + ", " + e.getMessage());
Message.debug("Exception is: " + getStackTrace(e)); // useful for debugging network issues
result = new SvnResource();
}
return result;
}
示例15: getRecord
import org.tmatesoft.svn.core.io.SVNRepository; //导入依赖的package包/类
@Override
@Nonnull
public Record getRecord(@Nonnull String path) throws IOException {
SVNRepository repository = svnProvider.getRepository();
try {
SVNDirEntry entry = repository.info(path, revision);
RecordPath recordPath = RecordPath.from(path);
if (entry != null) {
return getRecord(entry, recordPath.getFolder());
} else {
if (findLast) {
long lastRevision = getLastRevision(repository, path);
if (lastRevision > -1) {
entry = repository.info(path, lastRevision);
return getRecord(entry, recordPath.getFolder());
}
}
return new Record(getUri(), recordPath, 0, Record.NO_EXIST_SIZE, false);
}
} catch (SVNException e) {
throw new IOException("failed to get file record: " + getFullPath(path), e);
} finally {
svnProvider.releaseRepository(repository);
}
}