org.tmatesoft.svn.core.SVNProperty Java Examples
The following examples show how to use
org.tmatesoft.svn.core.SVNProperty.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SvnFilePropertyTest.java From git-as-svn with GNU General Public License v2.0 | 6 votes |
/** * Check commit .gitattributes. */ @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\n"); // Close dir editor.closeDir(); editor.closeDir(); editor.closeEdit(); } }
Example #2
Source File: SvnFilePropertyTest.java From git-as-svn with GNU General Public License v2.0 | 6 votes |
/** * Check commit .gitattributes. */ @Test public void commitFileWithProperties() throws Exception { try (SvnTestServer server = SvnTestServer.createEmpty()) { final SVNRepository repo = server.openSvnRepository(); createFile(repo, "sample.txt", "", propsEolNative); checkFileProp(repo, "/sample.txt", propsEolNative); createFile(repo, ".gitattributes", "*.txt\t\t\ttext eol=lf\n", propsEolNative); createFile(repo, "with-props.txt", "", propsEolLf); try { createFile(repo, "none-props.txt", "", null); } catch (SVNException e) { Assert.assertTrue(e.getMessage().contains(SVNProperty.EOL_STYLE)); } } }
Example #3
Source File: SvnFilePropertyTest.java From git-as-svn with GNU General Public License v2.0 | 6 votes |
/** * Check commit .gitattributes. */ @Test public void commitDirWithoutProperties() throws Exception { try (SvnTestServer server = SvnTestServer.createEmpty()) { final SVNRepository repo = server.openSvnRepository(); try { final long latestRevision = repo.getLatestRevision(); final ISVNEditor editor = repo.getCommitEditor("Create directory: /foo", null, false, null); editor.openRoot(-1); editor.addDir("/foo", null, latestRevision); // Empty file. final String filePath = "/foo/.gitattributes"; editor.addFile(filePath, null, -1); sendDeltaAndClose(editor, filePath, null, "*.txt\t\t\ttext\n"); // Close dir editor.closeDir(); editor.closeDir(); editor.closeEdit(); Assert.fail(); } catch (SVNException e) { Assert.assertTrue(e.getMessage().contains(SVNProperty.INHERITABLE_AUTO_PROPS)); } } }
Example #4
Source File: GitDeltaConsumer.java From git-as-svn with GNU General Public License v2.0 | 6 votes |
public void applyTextDelta(String path, @Nullable String baseChecksum) throws SVNException { try { if ((originalMd5 != null) && (baseChecksum != null)) { if (!baseChecksum.equals(originalMd5)) { throw new SVNException(SVNErrorMessage.create(SVNErrorCode.CHECKSUM_MISMATCH)); } } if (window != null) throw new SVNException(SVNErrorMessage.create(SVNErrorCode.RA_SVN_CMD_ERR)); newFilter = writer.getBranch().getRepository().getFilter(props.containsKey(SVNProperty.SPECIAL) ? FileMode.SYMLINK : FileMode.REGULAR_FILE, entry.getRawProperties()); window = new SVNDeltaProcessor(); final InputStream base = (oldFilter != null && objectId != null) ? oldFilter.inputStream(objectId) : SVNFileUtil.DUMMY_IN; final OutputStream target = newFilter.outputStream(new UncloseableOutputStream(temporaryStream), user); window.applyTextDelta(base, new UncheckedCloseOutputStream(target), true); } catch (IOException e) { throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR), e); } }
Example #5
Source File: SvnFilePropertyTest.java From git-as-svn with GNU General Public License v2.0 | 6 votes |
/** * Check commit .gitattributes. */ @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\n"); // Close dir editor.closeDir(); editor.closeEdit(); Assert.fail(); } catch (SVNException e) { Assert.assertTrue(e.getMessage().contains(SVNProperty.INHERITABLE_AUTO_PROPS)); } } }
Example #6
Source File: SvnFilePropertyTest.java From git-as-svn with GNU General Public License v2.0 | 6 votes |
/** * Check commit .gitattributes. */ @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\n"); // Close dir editor.closeDir(); editor.closeEdit(); } } }
Example #7
Source File: GitAutoProperty.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@Override public void apply(@NotNull Map<String, String> props) { final String mask = matcher.getSvnMaskGlobal(); if (mask != null) { String autoprops = props.getOrDefault(SVNProperty.INHERITABLE_AUTO_PROPS, ""); int beg = 0; while (true) { if (autoprops.substring(beg).startsWith(mask + MASK_SEPARATOR)) { int end = autoprops.indexOf('\n', beg + 1); if (end < 0) { end = autoprops.length(); } autoprops = autoprops.substring(0, end) + "; " + property + "=" + value + autoprops.substring(end); break; } beg = autoprops.indexOf('\n', beg + 1); if (beg < 0) { autoprops = autoprops + mask + MASK_SEPARATOR + property + "=" + value + "\n"; break; } } props.put(SVNProperty.INHERITABLE_AUTO_PROPS, autoprops); } }
Example #8
Source File: SvnFilePropertyTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
/** * Check commit .gitattributes. */ @Test public void binary() throws Exception { //Map<String, String> props = new HashMap<>()["key":""]; try (SvnTestServer server = SvnTestServer.createEmpty()) { final SVNRepository repo = server.openSvnRepository(); createFile(repo, "/data.txt", "Test file", propsEolNative); createFile(repo, "/data.dat", "Test data\0", propsBinary); checkFileProp(repo, "/data.txt", propsEolNative); checkFileProp(repo, "/data.dat", propsBinary); { final long latestRevision = repo.getLatestRevision(); final ISVNEditor editor = repo.getCommitEditor("Modify files", null, false, null); editor.openRoot(-1); editor.openFile("/data.txt", latestRevision); editor.changeFileProperty("/data.txt", SVNProperty.MIME_TYPE, SVNPropertyValue.create(SVNFileUtil.BINARY_MIME_TYPE)); editor.changeFileProperty("/data.txt", SVNProperty.EOL_STYLE, null); sendDeltaAndClose(editor, "/data.txt", "Test file", "Test file\0"); editor.openFile("/data.dat", latestRevision); editor.changeFileProperty("/data.dat", SVNProperty.MIME_TYPE, null); editor.changeFileProperty("/data.dat", SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE)); sendDeltaAndClose(editor, "/data.dat", "Test data\0", "Test data"); editor.closeDir(); editor.closeEdit(); } checkFileProp(repo, "/data.txt", propsBinary); checkFileProp(repo, "/data.dat", propsEolNative); } }
Example #9
Source File: SvnFilePropertyTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
/** * Check commit .gitattributes. */ @Test public void executable() throws Exception { //Map<String, String> props = new HashMap<>()["key":""]; try (SvnTestServer server = SvnTestServer.createEmpty()) { final SVNRepository repo = server.openSvnRepository(); createFile(repo, "/non-exec.txt", "", propsEolNative); createFile(repo, "/exec.txt", "", propsExecutable); checkFileProp(repo, "/non-exec.txt", propsEolNative); checkFileProp(repo, "/exec.txt", propsExecutable); { final long latestRevision = repo.getLatestRevision(); final ISVNEditor editor = repo.getCommitEditor("Create directory: /foo", null, false, null); editor.openRoot(-1); editor.openFile("/non-exec.txt", latestRevision); editor.changeFileProperty("/non-exec.txt", SVNProperty.EXECUTABLE, SVNPropertyValue.create("*")); editor.closeFile("/non-exec.txt", null); editor.openFile("/exec.txt", latestRevision); editor.changeFileProperty("/exec.txt", SVNProperty.EXECUTABLE, null); editor.closeFile("/exec.txt", null); editor.closeDir(); editor.closeEdit(); } checkFileProp(repo, "/non-exec.txt", propsExecutable); checkFileProp(repo, "/exec.txt", propsEolNative); } }
Example #10
Source File: WCDepthTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@BeforeMethod private void before() throws Exception { server = SvnTestServer.createEmpty(); final SVNRepository repository = server.openSvnRepository(); factory = server.createOperationFactory(); wc = Files.createDirectories(server.getTempDirectory().resolve("wc")); final ISVNEditor editor = repository.getCommitEditor("", null); editor.openRoot(-1); editor.addDir("/a", null, -1); editor.addDir("/a/b", null, -1); editor.addFile("/a/b/e", null, -1); editor.changeFileProperty("/a/b/e", SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE)); sendDeltaAndClose(editor, "/a/b/e", null, "e body"); editor.addDir("/a/b/c", null, -1); editor.addFile("/a/b/c/d", null, -1); editor.changeFileProperty("/a/b/c/d", SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE)); sendDeltaAndClose(editor, "/a/b/c/d", null, "d body"); editor.closeDir(); editor.closeDir(); editor.closeDir(); editor.closeDir(); editor.closeEdit(); }
Example #11
Source File: DepthTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@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); editor.changeFileProperty("/.gitattributes", SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE)); sendDeltaAndClose(editor, "/.gitattributes", null, "\n"); editor.addFile("/.gitignore", null, -1); editor.changeFileProperty("/.gitignore", SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE)); 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); editor.changeFileProperty("/a/b/e", SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE)); sendDeltaAndClose(editor, "/a/b/e", null, "e body"); editor.addDir("/a/b/c", null, -1); editor.addFile("/a/b/c/d", null, -1); editor.changeFileProperty("/a/b/c/d", SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE)); sendDeltaAndClose(editor, "/a/b/c/d", null, "d body"); editor.closeDir(); editor.closeDir(); editor.closeDir(); editor.closeDir(); editor.closeEdit(); return tester; }
Example #12
Source File: SvnKitPropget.java From StatSVN with GNU Lesser General Public License v3.0 | 5 votes |
public boolean isBinaryFile(final String revision, final String filename) { try { // TODO: HAS NEVER BEEN TESTED. SVNPropertyData data = getManager().getWCClient().doGetProperty(new File(filename), SVNProperty.MIME_TYPE, SVNRevision.parse(revision), SVNRevision.parse(revision)); return isBinary(data); } catch (SVNException e) { try { handleSvnException(e); } catch (IOException ex) { } return false; } }
Example #13
Source File: GitIgnore.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@Override public void apply(@NotNull Map<String, String> props) { if (global.length > 0) { props.compute(SVNProperty.INHERITABLE_IGNORES, (key, value) -> addIgnore(value, global)); } if (local.length > 0) { props.compute(SVNProperty.IGNORE, (key, value) -> addIgnore(value, local)); } }
Example #14
Source File: GitAttributesFactory.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@NotNull @Override public GitProperty[] create(@NotNull InputStream stream) throws IOException { AttributesNode r = new AttributesNode(); r.parse(stream); final List<GitProperty> properties = new ArrayList<>(); for (AttributesRule rule : r.getRules()) { final Wildcard wildcard; try { wildcard = new Wildcard(rule.getPattern()); } catch (InvalidPatternException | PatternSyntaxException e) { log.warn("Found invalid git pattern: {}", rule.getPattern()); continue; } final Attributes attrs = new Attributes(rule.getAttributes().toArray(emptyAttributes)); final EolType eolType = getEolType(attrs); if (eolType != null) { processProperty(properties, wildcard, SVNProperty.MIME_TYPE, eolType.mimeType); processProperty(properties, wildcard, SVNProperty.EOL_STYLE, eolType.eolStyle); } processProperty(properties, wildcard, SVNProperty.NEEDS_LOCK, getNeedsLock(attrs)); final String filter = getFilter(attrs); if (filter != null) properties.add(new GitFilterProperty(wildcard.getMatcher(), filter)); } return properties.toArray(GitProperty.emptyArray); }
Example #15
Source File: GitFile.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@NotNull default Map<String, String> getRevProperties() { final Map<String, String> props = new HashMap<>(); final GitRevision last = getLastChange(); props.put(SVNProperty.UUID, getBranch().getUuid()); props.put(SVNProperty.COMMITTED_REVISION, String.valueOf(last.getId())); putProperty(props, SVNProperty.COMMITTED_DATE, last.getDateString()); putProperty(props, SVNProperty.LAST_AUTHOR, last.getAuthor()); return props; }
Example #16
Source File: GitFileTreeEntry.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@NotNull @Override public Map<String, String> getProperties() throws IOException { final Map<String, String> props = getUpstreamProperties(); final FileMode fileMode = getFileMode(); if (fileMode.equals(FileMode.SYMLINK)) { props.remove(SVNProperty.EOL_STYLE); props.remove(SVNProperty.MIME_TYPE); props.put(SVNProperty.SPECIAL, "*"); } else { if (fileMode.equals(FileMode.EXECUTABLE_FILE)) props.put(SVNProperty.EXECUTABLE, "*"); if (props.containsKey(SVNProperty.MIME_TYPE)) { props.remove(SVNProperty.EOL_STYLE); } else if (props.containsKey(SVNProperty.EOL_STYLE)) { props.remove(SVNProperty.MIME_TYPE); } else if (fileMode.getObjectType() == Constants.OBJ_BLOB) { if (branch.getRepository().isObjectBinary(filter, getObjectId())) { props.put(SVNProperty.MIME_TYPE, MIME_BINARY); } else { props.put(SVNProperty.EOL_STYLE, SVNProperty.EOL_STYLE_NATIVE); } } } return props; }
Example #17
Source File: GitDeltaConsumer.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@Nullable public GitObject<ObjectId> getObjectId() throws IOException { if ((originalId != null) && originalId.equals(objectId) && (newFilter == null)) { this.newFilter = oldFilter; this.objectId = originalId; if (oldFilter == null) { throw new IllegalStateException("Original object ID defined, but original Filter is not defined"); } migrateFilter(writer.getBranch().getRepository().getFilter(props.containsKey(SVNProperty.SPECIAL) ? FileMode.SYMLINK : FileMode.REGULAR_FILE, entry.getRawProperties())); } return objectId; }
Example #18
Source File: SvnUpdateTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
/** * Bug: svn up doesnt remove file #18 * <pre> * bozaro@landfill:/tmp/test/git-as-svn$ echo > test.txt * bozaro@landfill:/tmp/test/git-as-svn$ svn add test.txt * A test.txt * bozaro@landfill:/tmp/test/git-as-svn$ svn commit -m "Add new file" * Добавляю test.txt * Передаю данные . * Committed revision 58. * bozaro@landfill:/tmp/test/git-as-svn$ svn up -r 57 * Updating '.': * В редакции 57. * bozaro@landfill:/tmp/test/git-as-svn$ ls -l test.txt * -rw-rw-r-- 1 bozaro bozaro 1 авг. 15 00:50 test.txt * bozaro@landfill:/tmp/test/git-as-svn$ * </pre> */ @Test public void addAndUpdate() throws Exception { try (SvnTestServer server = SvnTestServer.createEmpty()) { final SvnOperationFactory factory = server.createOperationFactory(); final SVNClientManager client = SVNClientManager.newInstance(factory); // checkout final SvnCheckout checkout = factory.createCheckout(); checkout.setSource(SvnTarget.fromURL(server.getUrl())); checkout.setSingleTarget(SvnTarget.fromFile(server.getTempDirectory().toFile())); checkout.setRevision(SVNRevision.HEAD); final long revision = checkout.run(); // create file Path newFile = server.getTempDirectory().resolve("somefile.txt"); TestHelper.saveFile(newFile, "Bla Bla Bla"); // add file client.getWCClient().doAdd(newFile.toFile(), false, false, false, SVNDepth.INFINITY, false, true); // set eof property client.getWCClient().doSetProperty(newFile.toFile(), SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE), false, SVNDepth.INFINITY, null, null); // commit new file client.getCommitClient().doCommit(new File[]{newFile.toFile()}, false, "Add file commit", null, null, false, false, SVNDepth.INFINITY); // update for checkout revision client.getUpdateClient().doUpdate(server.getTempDirectory().toFile(), SVNRevision.create(revision), SVNDepth.INFINITY, false, false); // file must be remove Assert.assertFalse(Files.exists(newFile)); } }
Example #19
Source File: FilterSVNEditor.java From git-as-svn with GNU General Public License v2.0 | 4 votes |
@Override public void changeFileProperty(String path, String propertyName, SVNPropertyValue propertyValue) throws SVNException { if (!propertyName.startsWith(SVNProperty.SVN_ENTRY_PREFIX)) { super.changeFileProperty(path, propertyName, propertyValue); } }
Example #20
Source File: SvnFilePropertyTest.java From git-as-svn with GNU General Public License v2.0 | 4 votes |
/** * Check commit .gitattributes. */ @Test public void commitUpdatePropertiesSubdir() throws Exception { try (SvnTestServer server = SvnTestServer.createEmpty()) { final SVNRepository repo = server.openSvnRepository(); { final ISVNEditor editor = repo.getCommitEditor("Create directory: /foo", null, false, null); editor.openRoot(-1); editor.addDir("/foo", null, -1); // Empty file. final String emptyFile = "/foo/.keep"; editor.addFile(emptyFile, null, -1); editor.changeFileProperty(emptyFile, SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE)); sendDeltaAndClose(editor, emptyFile, null, ""); // Close dir editor.closeDir(); editor.closeDir(); editor.closeEdit(); } createFile(repo, "/sample.txt", "", propsEolNative); createFile(repo, "/foo/sample.txt", "", propsEolNative); checkFileProp(repo, "/sample.txt", propsEolNative); checkFileProp(repo, "/foo/sample.txt", propsEolNative); createFile(repo, "/foo/.gitattributes", "*.txt\t\t\ttext eol=lf\n", propsEolNative); // After commit .gitattributes file sample.txt must change property svn:eol-style automagically. checkFileProp(repo, "/foo/sample.txt", propsEolLf); checkFileProp(repo, "/sample.txt", propsEolNative); // After commit .gitattributes directory with .gitattributes must change property svn:auto-props automagically. checkDirProp(repo, "/foo", propsAutoProps); // After commit .gitattributes file sample.txt must change property svn:eol-style automagically. { final Set<String> changed = new HashSet<>(); repo.log(new String[]{""}, repo.getLatestRevision(), repo.getLatestRevision(), true, false, logEntry -> changed.addAll(logEntry.getChangedPaths().keySet())); Assert.assertTrue(changed.contains("/foo")); Assert.assertTrue(changed.contains("/foo/.gitattributes")); Assert.assertTrue(changed.contains("/foo/sample.txt")); Assert.assertEquals(changed.size(), 3); } } }
Example #21
Source File: FilterSVNEditor.java From git-as-svn with GNU General Public License v2.0 | 4 votes |
@Override public void changeDirProperty(String name, SVNPropertyValue value) throws SVNException { if (!name.startsWith(SVNProperty.SVN_ENTRY_PREFIX)) { super.changeDirProperty(name, value); } }
Example #22
Source File: GitEolTest.java From git-as-svn with GNU General Public License v2.0 | 4 votes |
@DataProvider(name = "parseAttributesData") public static Object[][] parseAttributesData() throws IOException { final GitProperty[] attr; try (InputStream in = TestHelper.asStream( "# comment\n" + "* text\n" + "*.txt text\n" + // Tests that eol attribute works even without text attribute "*.md eol=lf\n" + "*.dat -text\n" + "3.md -text\n" + "*.bin binary\n" + "1.bin text\n" + "2.bin text\n" )) { attr = new GitAttributesFactory().create(in); } final Params[] params = new Params[]{ new Params(attr, "/").prop(SVNProperty.INHERITABLE_AUTO_PROPS, "*.txt = svn:eol-style=native\n" + "*.md = svn:eol-style=LF\n" + "*.dat = svn:mime-type=application/octet-stream\n" + "3.md = svn:mime-type=application/octet-stream\n" + "*.bin = svn:mime-type=application/octet-stream\n" + "1.bin = svn:eol-style=native\n" + "2.bin = svn:eol-style=native\n"), new Params(attr, "README.md").prop(SVNProperty.EOL_STYLE, SVNProperty.EOL_STYLE_LF), new Params(attr, "foo.dat").prop(SVNProperty.MIME_TYPE, SVNFileUtil.BINARY_MIME_TYPE), new Params(attr, "foo.txt").prop(SVNProperty.EOL_STYLE, SVNProperty.EOL_STYLE_NATIVE), new Params(attr, "foo.bin").prop(SVNProperty.MIME_TYPE, SVNFileUtil.BINARY_MIME_TYPE), new Params(attr, "1.bin").prop(SVNProperty.EOL_STYLE, SVNProperty.EOL_STYLE_NATIVE), new Params(attr, "2.bin").prop(SVNProperty.EOL_STYLE, SVNProperty.EOL_STYLE_NATIVE), new Params(attr, "3.md").prop(SVNProperty.MIME_TYPE, SVNFileUtil.BINARY_MIME_TYPE), new Params(attr, "changelog").prop(SVNProperty.EOL_STYLE, SVNProperty.EOL_STYLE_NATIVE), }; final Object[][] result = new Object[params.length][]; for (int i = 0; i < params.length; ++i) { result[i] = new Object[]{params[i]}; } return result; }
Example #23
Source File: GitWriter.java From git-as-svn with GNU General Public License v2.0 | 4 votes |
private FileMode getFileMode(@NotNull Map<String, String> props) { if (props.containsKey(SVNProperty.SPECIAL)) return FileMode.SYMLINK; if (props.containsKey(SVNProperty.EXECUTABLE)) return FileMode.EXECUTABLE_FILE; return FileMode.REGULAR_FILE; }
Example #24
Source File: MCRVersionedMetadata.java From mycore with GNU General Public License v3.0 | 4 votes |
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(); String checksum; try (InputStream in = Files.newInputStream(path)) { checksum = deltaGenerator.sendDelta(filePath, in, editor, true); } 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()); } }