本文整理汇总了Java中org.tmatesoft.svn.core.io.SVNRepository.getCommitEditor方法的典型用法代码示例。如果您正苦于以下问题:Java SVNRepository.getCommitEditor方法的具体用法?Java SVNRepository.getCommitEditor怎么用?Java SVNRepository.getCommitEditor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.tmatesoft.svn.core.io.SVNRepository
的用法示例。
在下文中一共展示了SVNRepository.getCommitEditor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: perform
import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
public Long perform(BasicSVNOperations operations, final SVNRepository repository) throws SVNException, PageStoreException, IOException {
ISVNEditor commitEditor = null;
boolean success = false;
try {
commitEditor = repository.getCommitEditor(_commitMessage, _locks, false, null);
commitEditor.openRoot(-1);
driveCommitEditor(commitEditor, operations);
commitEditor.closeDir();
final long newRevision = commitEditor.closeEdit().getNewRevision();
success = true;
return newRevision;
}
catch (SVNException ex) {
// We try clean-up as advised but re-throw the original error for handling.
checkForInterveningCommit(ex);
throw ex;
}
finally {
if (!success) {
cleanup(commitEditor);
}
}
}
示例3: modifyLockedRemoveLock
import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
/**
* Check for commit with keep locks.
*
* @throws Exception
*/
@Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class)
public void modifyLockedRemoveLock(@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();
// Lock
final SVNLock lock = lock(repo, "example.txt", latestRevision, false, null);
Assert.assertNotNull(lock);
{
final Map<String, String> locks = new HashMap<>();
locks.put("/example.txt", lock.getID());
final ISVNEditor editor = repo.getCommitEditor("Intital state", locks, false, null);
editor.openRoot(-1);
editor.openFile("/example.txt", latestRevision);
sendDeltaAndClose(editor, "/example.txt", "", "Source content");
editor.closeDir();
editor.closeEdit();
}
Assert.assertNull(repo.getLock("/example.txt"));
}
}
示例4: 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();
}
}
示例5: copy
import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
/**
* Copy file with filter change.
*
* @throws Exception
*/
@Test()
public void copy() 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);
editor.closeFile("data.z", null);
editor.closeDir();
editor.closeEdit();
}
// On file read now we must have uncompressed content.
checkFileContent(repo, "/data.z", CONTENT_FOO);
}
}
示例6: 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);
}
}
示例7: simpleShutdown
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 simpleShutdown() throws Exception {
final Map<String, Thread> oldThreads = getAllThreads();
final SvnTestServer server = SvnTestServer.createEmpty();
final SVNRepository repo2 = server.openSvnRepository();
final SVNRepository repo1 = server.openSvnRepository();
repo1.getLatestRevision();
final ISVNEditor editor = repo1.getCommitEditor("Empty commit", null, false, null);
editor.openRoot(-1);
server.startShutdown();
try {
// Can't create new connection is shutdown mode.
repo2.getLatestRevision();
Assert.fail();
} catch (SVNException ignored) {
}
editor.closeDir();
editor.closeEdit();
repo1.closeSession();
repo2.closeSession();
server.shutdown(SHOWDOWN_TIME);
checkThreads(oldThreads);
}
示例8: 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) {
}
}
示例9: modifyFile
import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
@NotNull
public static SVNCommitInfo modifyFile(@NotNull SVNRepository repo, @NotNull String filePath, @NotNull byte[] newData, long fileRev) throws SVNException, IOException {
final ByteArrayOutputStream oldData = new ByteArrayOutputStream();
repo.getFile(filePath, fileRev, null, oldData);
final ISVNEditor editor = repo.getCommitEditor("Modify file: " + filePath, null, false, null);
editor.openRoot(-1);
int index = 0;
int depth = 1;
while (true) {
index = filePath.indexOf('/', index + 1);
if (index < 0) {
break;
}
editor.openDir(filePath.substring(0, index), -1);
depth++;
}
editor.openFile(filePath, fileRev);
sendDeltaAndClose(editor, filePath, oldData.toByteArray(), newData);
for (int i = 0; i < depth; ++i) {
editor.closeDir();
}
return editor.closeEdit();
}
示例10: deleteFile
import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
@NotNull
public static SVNCommitInfo deleteFile(@NotNull SVNRepository repo, @NotNull String filePath) throws SVNException, IOException {
long latestRevision = repo.getLatestRevision();
final ISVNEditor editor = repo.getCommitEditor("Delete file: " + filePath, null, false, null);
editor.openRoot(-1);
int index = 0;
int depth = 1;
while (true) {
index = filePath.indexOf('/', index + 1);
if (index < 0) {
break;
}
editor.openDir(filePath.substring(0, index), -1);
depth++;
}
editor.deleteEntry(filePath, latestRevision);
for (int i = 0; i < depth; ++i) {
editor.closeDir();
}
return editor.closeEdit();
}
示例11: createFile
import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
@NotNull
public static SVNCommitInfo createFile(@NotNull SVNRepository repo, @NotNull String filePath, @NotNull byte[] content, @Nullable Map<String, String> props) throws SVNException, IOException {
final ISVNEditor editor = repo.getCommitEditor("Create file: " + filePath, null, false, null);
editor.openRoot(-1);
int index = 0;
int depth = 1;
while (true) {
index = filePath.indexOf('/', index + 1);
if (index < 0) {
break;
}
editor.openDir(filePath.substring(0, index), -1);
depth++;
}
editor.addFile(filePath, null, -1);
if (props != null) {
for (Map.Entry<String, String> entry : props.entrySet()) {
editor.changeFileProperty(filePath, entry.getKey(), SVNPropertyValue.create(entry.getValue()));
}
}
sendDeltaAndClose(editor, filePath, null, content);
for (int i = 0; i < depth; ++i) {
editor.closeDir();
}
return editor.closeEdit();
}
示例12: commitRootWithProperties
import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
/**
* Check commit .gitattributes.
*
* @throws Exception
*/
@Test
public void commitRootWithProperties() throws Exception {
try (SvnTestServer server = SvnTestServer.createEmpty()) {
final SVNRepository repo = server.openSvnRepository();
createFile(repo, "/.gitattributes", "", propsEolNative);
{
long latestRevision = repo.getLatestRevision();
final ISVNEditor editor = repo.getCommitEditor("Modify .gitattributes", null, false, null);
editor.openRoot(latestRevision);
editor.changeDirProperty(SVNProperty.INHERITABLE_AUTO_PROPS, SVNPropertyValue.create("*.txt = svn:eol-style=native\n"));
// 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();
}
}
}
示例13: 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));
}
}
}
示例14: 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);
}
}
示例15: commit
import org.tmatesoft.svn.core.io.SVNRepository; //导入方法依赖的package包/类
void commit(String mode) throws IOException {
// Commit to SVN
SVNCommitInfo info;
try {
SVNRepository repository = getStore().getRepository();
// Check which paths already exist in SVN
String[] paths = store.getSlotPaths(id);
int existing = paths.length - 1;
for (; existing >= 0; existing--) {
if (!repository.checkPath(paths[existing], -1).equals(SVNNodeKind.NONE)) {
break;
}
}
existing += 1;
// Start commit editor
String commitMsg = mode + "d metadata object " + store.getID() + "_" + id + " in store";
ISVNEditor editor = repository.getCommitEditor(commitMsg, null);
editor.openRoot(-1);
// Create directories in SVN that do not exist yet
for (int i = existing; i < paths.length - 1; i++) {
LOGGER.debug("SVN create directory {}", paths[i]);
editor.addDir(paths[i], null, -1);
editor.closeDir();
}
// Commit file changes
String filePath = paths[paths.length - 1];
if (existing < paths.length) {
editor.addFile(filePath, null, -1);
} else {
editor.openFile(filePath, -1);
}
editor.applyTextDelta(filePath, null);
SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
InputStream in = fo.getContent().getInputStream();
String checksum = deltaGenerator.sendDelta(filePath, in, editor, true);
in.close();
if (store.shouldForceXML()) {
editor.changeFileProperty(filePath, SVNProperty.MIME_TYPE, SVNPropertyValue.create("text/xml"));
}
editor.closeFile(filePath, checksum);
editor.closeDir(); // root
info = editor.closeEdit();
} catch (SVNException e) {
throw new IOException(e);
}
revision = () -> Optional.of(info.getNewRevision());
LOGGER.info("SVN commit of {} finished, new revision {}", mode, getRevision());
if (MCRVersioningMetadataStore.shouldSyncLastModifiedOnSVNCommit()) {
setLastModified(info.getDate());
}
}