private ISVNEditor getWrappedEditor() throws SVNException { if (myWrappedEditor == null) { myWrappedEditor = myTargetRepository.getCommitEditor("", null, false, null); } return myWrappedEditor; }
private ISVNEditor getWrappedEditor() throws SVNException { if (myWrappedEditor == null) { myWrappedEditor = myTargetRepository.getCommitEditor(null, null, false, myRevisionProperties, null); } return myWrappedEditor; }
private ISVNEditor getWrappedEditor() throws SVNException { if (myWrappedEditor == null) { myWrappedEditor = myTargetRepository.getCommitEditor(null, null, false, myRevisionProperties, null); } return myWrappedEditor; }
private ISVNEditor getWrappedEditor() throws SVNException { if (myWrappedEditor == null) { myWrappedEditor = myTargetRepository.getCommitEditor(null, null, false, myRevisionProperties, null); } return myWrappedEditor; }
SVNRepository repository = SVNRepositoryFactory.create( SVNURL.parseURIDecoded( url ) ); ISVNEditor editor = repository.getCommitEditor( logMessage , null /*locks*/ , true /*keepLocks*/ , null /*mediator*/ ); //the second and the third parameters are the path and revision respectively //of the item's ancestor if the item is being added with history editor.addFile( "your/path/project/README.txt" , null , -1 );
@Override public ISVNEditor handleStartRevision(long revision, SVNProperties revisionProperties) throws SVNException { final CopyFromSVNEditor editor = new CopyFromSVNEditor(dstRepo.getCommitEditor(revisionProperties.getStringValue("svn:log"), null), "/", checkDelete); copyFroms.put(revision, editor); return editor; }
SVNRepository repository = SVNRepositoryFactory.create(url); ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(user,password); repository.setAuthenticationManager(authManager); SVNPropertyValue svnPropertyValue = SVNPropertyValue.create("def"); ISVNEditor editor = repository.getCommitEditor("comment", null); editor.openRoot(-1); editor.openDir("dirname", -1); editor.changeDirProperty("myproperty", svnPropertyValue); editor.closeEdit();
SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(svnUrl)); SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator(); ISVNEditor editor = repository.getCommitEditor("This is a log message.", new CommitMediator()); editor.openRoot(-1); editor.addFile("testThisTextCommit1.txt", null, -1); editor.applyTextDelta(svnUrl, null); InputStream is = SVNFileUtil.openFileForReading(file); String chksm = deltaGenerator.sendDelta(svnUrl, is, editor, true); is.close(); editor.textDeltaEnd("testThisTextCommit1.txt"); editor.closeFile("testThisTextCommit1.txt", chksm); editor.closeEdit();
SVNRepository repository = SVNRepositoryFactory.create(url); ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(user,password); repository.setAuthenticationManager(authManager); ISVNEditor editor = repository.getCommitEditor("comment" , null); editor.openRoot(-1); editor.openFile("/file1.txt", -1); editor.changeFileProperty("/file1.txt", "mypropertyname", SVNPropertyValue.create("myvalue")); editor.closeFile("/file1.txt",null); editor.closeEdit();
protected void doOpenConnection() throws SVNException { String url = getSubversionURL(); SVNURL repoUrl = SVNURL.parseURIDecoded(url); queryRepo = SVNRepositoryFactory.create(repoUrl); configureAuthenticationManager(queryRepo); // when URL is given like http://svn.dev.java.net/svn/abc/trunk/xyz, we need to compute // repositoryRoot=http://svn.dev.java.net/abc and rootPath=/trunk/xyz rootPath = repoUrl.getPath().substring(queryRepo.getRepositoryRoot(true).getPath().length()); if(rootPath.startsWith("/")) rootPath=rootPath.substring(1); // at least in case of file:// URL, the commit editor remembers the root path // portion and that interferes with the way we work, so re-open the repository // with the correct root. SVNURL repoRoot = queryRepo.getRepositoryRoot(true); queryRepo.setLocation(repoRoot,false); // open another one for commit commitRepo = SVNRepositoryFactory.create(repoRoot); configureAuthenticationManager(commitRepo); // prepare a commit ISVNEditor svnEditor = commitRepo.getCommitEditor("Upload by wagon-svn", new CommitMediator()); svnEditor.openRoot(-1); // if openRoot fails, Maven calls closeConnection anyway, so don't let the incorrect // editor state show through. this.editor = svnEditor; }
public SvnTesterExternal(@NotNull SVNURL url, @Nullable ISVNAuthenticationManager authManager) throws SVNException { this.url = url; this.authManager = authManager; this.suffix = UUID.randomUUID().toString(); final SVNRepository repo = openSvnRepository(url); try { final ISVNEditor editor = repo.getCommitEditor("Create subdir for test", null, false, null); editor.openRoot(-1); editor.addDir(suffix, null, -1); editor.closeDir(); editor.closeEdit(); } finally { repo.closeSession(); } }
@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(); }
@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(); }
private void replayRevision(@NotNull SVNRepository srcRepo, @NotNull SVNRepository dstRepo, long revision) throws SVNException { SVNProperties revisionProperties = srcRepo.getRevisionProperties(revision, null); CopyFromSVNEditor editor = new CopyFromSVNEditor(dstRepo.getCommitEditor(revisionProperties.getStringValue("svn:log"), null), "/", true); srcRepo.replay(revision - 1, revision, true, editor); editor.closeEdit(); checkCopyFrom(srcRepo, editor, revision); }
private void updateRevision(@NotNull SVNRepository srcRepo, @NotNull SVNRepository dstRepo, long revision) throws SVNException { final SVNPropertyValue message = srcRepo.getRevisionPropertyValue(revision, "svn:log"); final CopyFromSVNEditor editor = new CopyFromSVNEditor(dstRepo.getCommitEditor(message.getString(), null), "/", true); srcRepo.update(revision, "", SVNDepth.INFINITY, true, reporter -> { reporter.setPath("", null, revision - 1, SVNDepth.INFINITY, false); reporter.finishReport(); }, new FilterSVNEditor(editor, true)); checkCopyFrom(srcRepo, editor, revision); }
public boolean commitFileChangeOnLatestRevision(String newContent, String dirPath, String fileName) throws SVNException { String logMessage = "log message"; boolean success = true; if (repository != null) { String filePath = dirPath + "/" + fileName; ISVNEditor editor = repository.getCommitEditor(logMessage, null /* locks */, true /* keepLocks */, null /* mediator */); editor.openRoot(-1); editor.addDir(dirPath, null, -1); editor.addFile(filePath, null, -1); long fileRevision = getFileRevision(filePath); editor.openFile(filePath, fileRevision); editor.applyTextDelta(filePath, null); byte[] bytesUtf8 = StringUtils.getBytesUtf8(newContent); SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator(); String checksum = deltaGenerator.sendDelta(filePath, new ByteArrayInputStream(bytesUtf8), editor, true); editor.closeFile(filePath, checksum); editor.closeDir(); editor.closeDir(); SVNCommitInfo commitInfo = editor.closeEdit(); success = commitInfo.getNewRevision() != fileRevision; } return success; }
/** * 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); } }
@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(); } }
/** * Check commit .gitattributes. * * @throws Exception */ @Test public void commitDirWithProperties() throws Exception { try (SvnTestServer server = SvnTestServer.createEmpty()) { final SVNRepository repo = server.openSvnRepository(); final long latestRevision = repo.getLatestRevision(); final ISVNEditor editor = repo.getCommitEditor("Create directory: /foo", null, false, null); editor.openRoot(-1); editor.addDir("/foo", null, latestRevision); editor.changeDirProperty(SVNProperty.INHERITABLE_AUTO_PROPS, SVNPropertyValue.create("*.txt = svn:eol-style=native\n")); // Empty file. final String filePath = "/foo/.gitattributes"; editor.addFile(filePath, null, -1); editor.changeFileProperty(filePath, SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE)); sendDeltaAndClose(editor, filePath, null, "*.txt\t\t\ttext eol=native\n"); // Close dir editor.closeDir(); editor.closeDir(); editor.closeEdit(); } }
@NotNull private SvnTester create(@NotNull SvnTesterFactory factory) throws Exception { final SvnTester tester = factory.create(); final SVNRepository repo = tester.openSvnRepository(); final ISVNEditor editor = repo.getCommitEditor("", null); editor.openRoot(-1); editor.changeDirProperty("svn:ignore", SVNPropertyValue.create("sample.txt")); editor.addFile("/.gitattributes", null, -1); sendDeltaAndClose(editor, "/.gitattributes", null, "* -text\n"); editor.addFile("/.gitignore", null, -1); sendDeltaAndClose(editor, "/.gitignore", null, "/sample.txt\n"); editor.addDir("/a", null, -1); editor.addDir("/a/b", null, -1); editor.addFile("/a/b/e", null, -1); sendDeltaAndClose(editor, "/a/b/e", null, "e body"); editor.addDir("/a/b/c", null, -1); editor.addFile("/a/b/c/d", null, -1); sendDeltaAndClose(editor, "/a/b/c/d", null, "d body"); editor.closeDir(); editor.closeDir(); editor.closeDir(); editor.closeDir(); editor.closeEdit(); return tester; }