use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnParseCommandLineParseTest method testStatusInExternalMove.
public void testStatusInExternalMove() throws Exception {
final String status = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<status>\n" + "<target\n" + " path=\".\">\n" + "<entry\n" + " path=\"slave\">\n" + "<wc-status\n" + " item=\"external\"\n" + " props=\"none\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + " path=\"src\\com\\test\\just\">\n" + "<wc-status\n" + " props=\"none\"\n" + " item=\"unversioned\">\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + " path=\"C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\MacMessagesParser.java\">\n" + "<wc-status\n" + " item=\"added\"\n" + " props=\"none\"\n" + " copied=\"true\">\n" + "<commit\n" + " revision=\"7\">\n" + "<author>admin</author>\n" + "<date>2012-09-12T12:16:51.621000Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "<entry\n" + " path=\"C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\SomeOtherClass.java\">\n" + "<wc-status\n" + " props=\"none\"\n" + " item=\"deleted\"\n" + " revision=\"7\">\n" + "<commit\n" + " revision=\"7\">\n" + "<author>admin</author>\n" + "<date>2012-09-12T12:16:51.621000Z</date>\n" + "</commit>\n" + "</wc-status>\n" + "</entry>\n" + "</target>\n" + "</status>";
final String basePath = "C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main";
final SvnStatusHandler[] handler = new SvnStatusHandler[1];
final File baseFile = new File(basePath);
final SvnStatusHandler.ExternalDataCallback callback = CmdStatusClient.createStatusCallback(status1 -> {
System.out.println(status1.getURL());
if (new File("C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\MacMessagesParser.java").equals(status1.getFile())) {
Assert.assertEquals("http://external/src/com/slave/MacMessagesParser.java", status1.getURL().toString());
}
if (new File("C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\SomeOtherClass.java").equals(status1.getFile())) {
Assert.assertEquals("http://external/src/com/slave/SomeOtherClass.java", status1.getURL().toString());
}
}, baseFile, createStubInfo(basePath, "http://mainurl/"), handler);
handler[0] = new SvnStatusHandler(callback, baseFile, o -> {
try {
if (new File("C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave").equals(o)) {
return createStubInfo(o.getPath(), "http://external");
}
return createStubInfo(o.getPath(), "http://12345");
} catch (SVNException e) {
throw new RuntimeException(e);
}
});
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(new ByteArrayInputStream(status.getBytes(CharsetToolkit.UTF8_CHARSET)), handler[0]);
final MultiMap<String, PortableStatus> changes = handler[0].getCurrentListChanges();
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnParseCommandLineParseTest method testOneFileInChangeListStatus.
public void testOneFileInChangeListStatus() throws Exception {
final String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<status>\n" + "<target\n" + " path=\".\">\n" + "</target>\n" + "<changelist\n" + " name=\"target\">\n" + "<entry\n" + " path=\"a.txt\">\n" + "<wc-status\n" + " props=\"none\"\n" + " item=\"added\"\n" + " revision=\"-1\">\n" + "</wc-status>\n" + "</entry>\n" + "</changelist>\n" + "</status>";
final SvnStatusHandler[] handlerArr = new SvnStatusHandler[1];
final boolean isWindows = SystemInfo.isWindows;
final String basePath = isWindows ? "C:/base/" : "/base33729/";
final Set<PortableStatus> statuses = new HashSet<>();
final String[] clName = new String[1];
final SvnStatusHandler handler = new SvnStatusHandler(new SvnStatusHandler.ExternalDataCallback() {
@Override
public void switchPath() {
final PortableStatus pending = handlerArr[0].getPending();
pending.setChangelistName(clName[0]);
statuses.add(pending);
pending.getKind();
}
@Override
public void switchChangeList(String newList) {
clName[0] = newList;
}
}, new File(basePath), o -> {
try {
o.getCanonicalFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
if (isWindows) {
final int idx = o.getPath().indexOf(":");
Assert.assertTrue(idx > 0);
final int secondIdx = o.getPath().indexOf(":", idx + 1);
Assert.assertTrue(o.getPath(), secondIdx == -1);
} else {
if (o.getPath().contains(LINUX_ROOT)) {
Assert.assertFalse(o.getPath().contains(basePath));
}
}
try {
return createStubInfo(basePath + "1", "http://a.b.c");
} catch (SVNException e) {
throw new RuntimeException(e);
}
});
handlerArr[0] = handler;
final String osChecked = changePathsIfNix(s);
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(new ByteArrayInputStream(osChecked.getBytes(CharsetToolkit.UTF8_CHARSET)), handler);
Assert.assertEquals(1, statuses.size());
final PortableStatus next = statuses.iterator().next();
Assert.assertEquals("a.txt", next.getPath());
Assert.assertEquals("target", next.getChangelistName());
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnUpdateRootOptionsPanel method chooseBranch.
private void chooseBranch() {
if (mySourceUrl == null) {
myBranchField.setEnabled(false);
return;
}
SelectBranchPopup.show(myVcs.getProject(), myRoot.getVirtualFile(), (project, configuration, url, revision) -> {
// TODO: It seems that we could reuse configuration passed as parameter to this callback
SvnBranchConfigurationNew branchConfiguration = getBranchConfiguration();
String branchRelativeUrl = branchConfiguration != null ? branchConfiguration.getRelativeUrl(mySourceUrl.toString()) : null;
if (mySourceUrl == null || branchRelativeUrl == null) {
myBranchField.setText("");
} else {
try {
myURLText.setText(SVNURL.parseURIEncoded(url).appendPath(branchRelativeUrl, true).toDecodedString());
} catch (SVNException e) {
LOG.error(e);
}
myBranchField.setText(SVNPathUtil.tail(url));
}
}, SvnBundle.message("select.branch.popup.general.title"), myPanel);
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnKitUpgradeClient method upgrade.
@Override
public void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ProgressTracker handler) throws VcsException {
validateFormat(format, getSupportedFormats());
SVNWCClient client = myVcs.getSvnKitManager().createUpgradeClient();
client.setEventHandler(toEventHandler(handler));
try {
cleanupIfNecessary(path, format, client, handler);
upgrade(path, format, client, handler);
} catch (SVNException e) {
throw new SvnBindException(e);
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnAuthenticationTest method testWhenPassSaveNoInServers.
public void testWhenPassSaveNoInServers() throws Exception {
final TestListener listener = new TestListener(mySynchObject);
myAuthenticationManager.addListener(listener);
final SavedOnceListener savedOnceListener = new SavedOnceListener();
myAuthenticationManager.addListener(savedOnceListener);
final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");
final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
FileUtil.copy(servers, oldServers);
try {
FileUtil.appendToFile(servers, "\nstore-passwords=no\n");
final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
final SVNException[] exception = new SVNException[1];
final Boolean[] result = new Boolean[1];
synchronousBackground(() -> {
try {
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(3, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
myTestInteraction.reset();
savedOnceListener.assertForAwt();
savedOnceListener.reset();
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(6, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
} catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
Assert.assertEquals(6, listener.getCnt());
listener.assertForAwt();
savedOnceListener.assertForAwt();
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
if (exception[0] != null) {
throw exception[0];
}
} finally {
FileUtil.delete(servers);
FileUtil.rename(oldServers, servers);
}
}
Aggregations