本文整理汇总了Java中org.tmatesoft.svn.core.SVNProperty类的典型用法代码示例。如果您正苦于以下问题:Java SVNProperty类的具体用法?Java SVNProperty怎么用?Java SVNProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SVNProperty类属于org.tmatesoft.svn.core包,在下文中一共展示了SVNProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProperties
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的package包/类
@NotNull
@Override
public Map<String, String> getProperties() throws IOException, SVNException {
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 (fileMode.getObjectType() == Constants.OBJ_BLOB && repo.isObjectBinary(filter, getObjectId())) {
props.remove(SVNProperty.EOL_STYLE);
props.put(SVNProperty.MIME_TYPE, SVNFileUtil.BINARY_MIME_TYPE);
}
}
return props;
}
示例2: create
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的package包/类
public void create(final ISVNEditor commitEditor, final String path, final InputStream content, Map<String, String> attributes) throws SVNException, IOException {
final BufferedInputStream bis = new BufferedInputStream(content);
final String autoDetectedMimeType = detectMimeType(bis);
commitEditor.addFile(path, null, -1);
commitEditor.applyTextDelta(path, null);
SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
String checksum = deltaGenerator.sendDelta(path, bis, commitEditor, true);
final Map<String, String> autoProperties = _autoPropertiesApplier.apply(path);
final Map<String, String> allProperties = new LinkedHashMap<String, String>();
allProperties.putAll(autoProperties);
allProperties.putAll(attributes);
setProperties(commitEditor, path, allProperties);
if (!allProperties.containsKey(SVNProperty.MIME_TYPE) && autoDetectedMimeType != null) {
commitEditor.changeFileProperty(path, SVNProperty.MIME_TYPE, SVNPropertyValue.create(autoDetectedMimeType));
}
commitEditor.closeFile(path, checksum);
}
示例3: test
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的package包/类
/**
* Tests if all Java files in the src folder have the svn:keywords property.
*/
public void test() throws Exception {
IResource root = createBinaryScope(getTmpDirectory(),
new String[] { "**/*.java" }, null);
executeProcessor(SVNPropertiesExtractor.class, "(input=(ref=", root,
"), property=(name='", SVNProperty.KEYWORDS, "'))");
List<IElement> elements = ResourceTraversalUtils.listElements(root,
IElement.class);
assertTrue(elements.size() == 5);
for (IElement element : elements) {
Object property = element.getValue(SVNProperty.KEYWORDS);
assertNotNull(property);
assertTrue(property.toString().toLowerCase().contains("id"));
}
}
示例4: editFiles
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的package包/类
public void editFiles(VirtualFile[] files) throws VcsException {
File[] ioFiles = new File[files.length];
SVNWCClient client = myVCS.createWCClient();
for (int i = 0; i < files.length; i++) {
ioFiles[i] = new File(files[i].getPath());
try {
SVNPropertyData property = client
.doGetProperty(ioFiles[i], SVNProperty.NEEDS_LOCK, SVNRevision.WORKING, SVNRevision.WORKING);
if (property == null || property.getValue() == null) {
throw new VcsException(SvnBundle.message("exception.text.file.miss.svn", ioFiles[i].getName()));
}
}
catch (SVNException e) {
throw new VcsException(e);
}
}
SvnUtil.doLockFiles(myVCS.getProject(), myVCS, ioFiles);
}
示例5: create
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的package包/类
@NotNull
@Override
public GitProperty[] create(@NotNull String content) throws IOException {
final List<GitProperty> properties = new ArrayList<>();
for (String line : content.split("(?:#[^\n]*)?\n")) {
final String[] tokens = line.trim().split("\\s+");
try {
final Wildcard wildcard = new Wildcard(tokens[0]);
processProperty(properties, wildcard, SVNProperty.MIME_TYPE, getMimeType(tokens));
processProperty(properties, wildcard, SVNProperty.EOL_STYLE, getEol(tokens));
final String filter = getFilter(tokens);
if (filter != null) {
properties.add(new GitFilterProperty(wildcard.getMatcher(), filter));
}
} catch (InvalidPatternException | PatternSyntaxException e) {
log.warn("Found invalid git pattern: {}", line);
}
}
return properties.toArray(new GitProperty[properties.size()]);
}
示例6: getEol
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的package包/类
@Nullable
private String getEol(String[] tokens) {
for (int i = 1; i < tokens.length; ++i) {
final String token = tokens[i];
if (token.startsWith(EOL_PREFIX)) {
switch (token.substring(EOL_PREFIX.length())) {
case "lf":
return SVNProperty.EOL_STYLE_LF;
case "native":
return SVNProperty.EOL_STYLE_NATIVE;
case "cr":
return SVNProperty.EOL_STYLE_CR;
case "crlf":
return SVNProperty.EOL_STYLE_CRLF;
}
}
if (token.startsWith("binary")) {
return "";
}
if (token.startsWith("-text")) {
return "";
}
}
return null;
}
示例7: commitDirWithProperties
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的package包/类
/**
* 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();
}
}
示例8: commitDirWithoutProperties
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的package包/类
/**
* Check commit .gitattributes.
*
* @throws Exception
*/
@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 eol=native\n");
// Close dir
editor.closeDir();
editor.closeDir();
editor.closeEdit();
Assert.fail();
} catch (SVNException e) {
Assert.assertTrue(e.getMessage().contains(SVNProperty.INHERITABLE_AUTO_PROPS));
}
}
}
示例9: commitRootWithProperties
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的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();
}
}
}
示例10: commitRootWithoutProperties
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的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));
}
}
}
示例11: commitFileWithProperties
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的package包/类
/**
* Check commit .gitattributes.
*
* @throws Exception
*/
@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));
}
}
}
示例12: commit
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的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());
}
}
示例13: changeProperties
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的package包/类
private void changeProperties(EditorEntry entry, String name, SVNPropertyValue value) throws SVNException {
//String quotedName = SVNEncodingUtil.xmlEncodeCDATA(name, true);
if (getUpdateRequest().isSendAll()) {
if (value != null) {
writePropertyTag("set-prop", name, value);
} else {
writeEntryTag("remove-prop", name);
}
} else if (value != null) {
if (SVNProperty.isEntryProperty(name)) {
if (SVNProperty.COMMITTED_REVISION.equals(name)) {
entry.setCommitedRevision(value.getString());
} else if (SVNProperty.COMMITTED_DATE.equals(name)) {
entry.setCommitedDate(value.getString());
} else if (SVNProperty.LAST_AUTHOR.equals(name)) {
entry.setLastAuthor(value.getString());
} else if (SVNProperty.LOCK_TOKEN.equals(name) && value == null) {
entry.addRemovedProperty(name);
}
return;
}
if (value == null) {
entry.addRemovedProperty(name);
} else {
entry.setHasChangedProperty(true);
}
}
}
示例14: handleEvent
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的package包/类
public void handleEvent(SVNEvent event, double progress) {
/*
* Gets the current action. An action is represented by SVNEventAction.
* In case of a commit an action can be determined via comparing
* SVNEvent.getAction() with SVNEventAction.COMMIT_-like constants.
*/
SVNEventAction action = event.getAction();
if (action == SVNEventAction.COMMIT_MODIFIED) {
System.out.println("Sending " + event.getFile());
} else if (action == SVNEventAction.COMMIT_DELETED) {
System.out.println("Deleting " + event.getFile());
} else if (action == SVNEventAction.COMMIT_REPLACED) {
System.out.println("Replacing " + event.getFile());
} else if (action == SVNEventAction.COMMIT_DELTA_SENT) {
System.out.println("Transmitting file data....");
} else if (action == SVNEventAction.COMMIT_ADDED) {
/*
* Gets the MIME-type of the item.
*/
String mimeType = event.getMimeType();
if (SVNProperty.isBinaryMimeType(mimeType)) {
/*
* If the item is a binary file
*/
System.out.println("Adding (bin) "
+ event.getFile());
} else {
System.out.println("Adding "
+ event.getFile());
}
}
}
示例15: isBinary
import org.tmatesoft.svn.core.SVNProperty; //导入依赖的package包/类
public boolean isBinary(@NotNull final VirtualFile file) {
SvnVcs vcs = SvnVcs.getInstance(myProject);
try {
SVNWCClient client = vcs.createWCClient();
File ioFile = new File(file.getPath());
SVNPropertyData svnPropertyData = client.doGetProperty(ioFile, SVNProperty.MIME_TYPE, SVNRevision.UNDEFINED, SVNRevision.WORKING);
if (svnPropertyData != null && SVNProperty.isBinaryMimeType(SVNPropertyValue.getPropertyAsString(svnPropertyData.getValue()))) {
return true;
}
}
catch (SVNException e) {
//
}
return false;
}