Hello Daniel, With Subversion you can't run diff on targets from different repositories. What you can do is get file's contents using SvnCat operation and save this contents to files. Then generate diff with the help of internal SvnDiffGenerator class (may need to set more options to make it work):
SvnDiffGenerator generator = new SvnDiffGenerator(); generator.setOriginalTargets(SvnTarget.fromFile(file1), SvnTarget.fromFile(file2)); generator.setAnchors(SvnTarget.fromFile(file1), SvnTarget.fromFile(file2)); generator.displayContentChanged(...); Alexander Kitaev, TMate Software, http://subgit.com/ - Svn to Git Migration! http://svnkit.com/ - Java [Sub]Versioning Library! http://hg4j.com/ - Java Mercurial Library! http://sqljet.com/ - Java SQLite Library! On 12 March 2013 13:23, Daniel Alencar <daniel.calen...@gmail.com> wrote: > Hi Alexander, > > Thanks for your reply! > > I tried de following code: > > public static void diffFromTwoDifferentRepositories() throws IOException, > SVNException > { > Properties prop = new Properties(); > > prop.load(SVNKitUtils.class.getClassLoader().getResourceAsStream("svnkit.properties")); > String urlDesenvolvimento = prop.getProperty("url_desenvolvimento"); > String urlCooperacao = prop.getProperty("url_cooperacao"); > String user = prop.getProperty("username"); > String password = prop.getProperty("password"); > > SVNURL svnUrlDev = > SVNURL.parseURIEncoded("http://desenvolvimento.info.ufrn.br/projetos/"); > SVNURL svnUrlCoop = > SVNURL.parseURIEncoded("http://version.info.ufrn.br/cooperacao/"); > > SVNURL svnUrlDevFile = > SVNURL.parseURIEncoded("http://desenvolvimento.info.ufrn.br/projetos/trunk/SIGAA/avaliacao/br/ufrn/sigaa/avaliacao/dao/CalendarioAvaliacaoDao.java"); > SVNURL svnUrlCoopFile = > SVNURL.parseURIEncoded("http://version.info.ufrn.br/cooperacao/branches/ufpb/svn/trunk/SIGAA/avaliacao/br/ufrn/sigaa/avaliacao/dao/CalendarioAvaliacaoDao.java"); > > SVNPasswordAuthentication[] authentications = new > SVNPasswordAuthentication[2]; > authentications[0] = new > SVNPasswordAuthentication(user,password,true,svnUrlDev,false); > authentications[1] = new > SVNPasswordAuthentication(user,password,true,svnUrlCoop,false); > BasicAuthenticationManager authm = new > BasicAuthenticationManager(authentications); > > > SvnOperationFactory of = new SvnOperationFactory(); > of.setAuthenticationManager(authm); > > try { > > final ByteArrayOutputStream byteArrayOutputStream = new > ByteArrayOutputStream(); > final SvnDiffGenerator diffGenerator = new SvnDiffGenerator(); > diffGenerator.setBasePath(new File("")); > > final SvnDiff diff = of.createDiff(); > diff.setSources(SvnTarget.fromURL(svnUrlCoopFile, > SVNRevision.create(28003)), SvnTarget.fromURL(svnUrlDevFile, > SVNRevision.create(137213))); > diff.setDiffGenerator(diffGenerator); > diff.setOutput(byteArrayOutputStream); > diff.run(); > > final String actualDiffOutput = > byteArrayOutputStream.toString(); > } finally { > of.dispose(); > } > } > > The user and password are registered to both repositories. But i'm getting > the following error: > > Exception in thread "main" org.tmatesoft.svn.core.SVNException: svn: > E190001: Unusable URI: it does not refer to this repository > svn: E175002: REPORT of '/cooperacao/!svn/vcc/default': 500 Internal Server > Error (http://version.info.ufrn.br) > at > org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:64) > at > org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:51) > at > org.tmatesoft.svn.core.internal.io.dav.DAVRepository.runReport(DAVRepository.java:1289) > at > org.tmatesoft.svn.core.internal.io.dav.DAVRepository.diff(DAVRepository.java:815) > at > org.tmatesoft.svn.core.internal.wc2.ng.SvnNgDiff.doDiffReposRepos(SvnNgDiff.java:263) > at > org.tmatesoft.svn.core.internal.wc2.ng.SvnNgDiff.doDiff(SvnNgDiff.java:111) > at > org.tmatesoft.svn.core.internal.wc2.ng.SvnNgDiff.run(SvnNgDiff.java:78) > at > org.tmatesoft.svn.core.internal.wc2.ng.SvnNgDiff.run(SvnNgDiff.java:34) > at > org.tmatesoft.svn.core.internal.wc2.ng.SvnNgOperationRunner.run(SvnNgOperationRunner.java:20) > at > org.tmatesoft.svn.core.internal.wc2.SvnOperationRunner.run(SvnOperationRunner.java:20) > at > org.tmatesoft.svn.core.wc2.SvnOperationFactory.run(SvnOperationFactory.java:1235) > at org.tmatesoft.svn.core.wc2.SvnOperation.run(SvnOperation.java:291) > at > br.com.jeebrasil.iproject.utils.SVNKitUtils.diffFromTwoDifferentRepositories(SVNKitUtils.java:474) > at > br.com.jeebrasil.iproject.utils.SVNKitUtils.main(SVNKitUtils.java:484) > > Do you know why i can't diff these two files? > > Thanks for any help. > > > On Mon, Mar 11, 2013 at 4:27 PM, Alexander Kitaev <kit...@gmail.com> wrote: >> >> Hello Daniel, >> >> > The repositories contains two differents evolutions of the ProjectX, so >> > i >> > want to do a diff of a fileX1 from svn1 to a fileX2 from svn2. In order >> > to >> > do this, i have to provide two credentials for my authentication manager >> > (one for svn1 and other for svn2), right? >> > >> > Then i could do the following: >> > >> > SvnOperationFactory opF = new SvnOperationFactory(); >> > >> > opF.setAuthenticationManager(<here my authentication manager with two >> > credentials>) >> >> When asked for credentials, SVNKit calls its ISVNAuthenticationManager >> object that is responsible for providing credentials. There are two >> built-in implementation of ISVNAuthenticationManager and of course you >> may implement your own. >> >> First and most frequently used is DefaultSVNAuthenticationManager - it >> supports credentials caching and user's credentials callback >> (ISVNAuthenticationProvider). It works like this: >> >> 1) First it attempts to use explicitly configured credentials >> 2) Then, if there are none or if explicit credentials have been >> rejected, it looks for credentials in runtime storage >> 3) Then, if there are none or if in-memory cached credentials have >> been rejected, it looks in on-disk credentials cache >> 4) Finally, if there are none on disk or on-disk cached credentials >> have been rejected, it calls users ISVNAuthenticationProvider (if >> set); provider may return "null" to cancel authentication or provide >> credentials for repository it was asked for. >> 5) Whenever credentials are accepted, they are saved into runtime >> cache and, in case it is allowed by configuration, into on-disk cache. >> >> So, this is how DefaultSVNAuthenticationManager works. For you that >> means that if you use it, you should implement and set >> ISVNAuthenticationProvider callback that will provide either first or >> second user's credentials depending on the repository URL: >> >> DefaultSVNAuthenticationManager authManager = >> SVNWCUtil.createDefaultAuthenticationManager(); >> authManager.setAuthenticationProvider(new >> ISVNAuthenticationProvider() { >> public SVNAuthentication >> requestClientAuthentication(String kind, SVNURL url, String realm, >> SVNErrorMessage errorMessage, SVNAuthentication previousAuth, boolean >> authMayBeStored) { >> if (url.equals(URL1)) { >> return new SVNPasswordAuthentication(userName1, >> password2, false, url, false); >> } else if (url.equals(URL2)) { >> return new SVNPasswordAuthentication(userName2, >> password2, false, url, false); >> } >> return null; >> } >> public int acceptServerAuthentication(SVNURL url, String >> realm, Object certificate, boolean resultMayBeStored) { >> return ACCEPTED_TEMPORARY; >> } >> }); >> SvnOperationFactory of = new SvnOperationFactory(); >> of.setAuthenticationManager(authManager); >> >> >> Another authentication manager is BasicAuthenticationManager. When >> asked for credentials it simply provides all it has been configured >> with and you may use it too: >> >> BasicAuthenticationManager authManager = new >> BasicAuthenticationManager(new SVNAuthentication[] {user1Auth, >> user2Auth}); >> SvnOperationFactory of = new SvnOperationFactory(); >> of.setAuthenticationManager(authManager); >> >> When asked for credentials by repository2, first user1Auth will be >> used. In case these credentials are rejected, user2Auth will be used. >> This probably not exactly what you want in case for instance both >> user1 and user2 are in both repositories and you'd like to have >> control over user account being used with each repository. >> >> Finally, another simple approach is to keep two >> BasicAuthenticationManager objects each configured for certain user. >> Then set corresponding manager on SvnOperationFactory before running >> an operation. >> >> Alexander Kitaev, >> TMate Software, >> http://subgit.com/ - Svn to Git Migration! >> http://svnkit.com/ - Java [Sub]Versioning Library! >> http://hg4j.com/ - Java Mercurial Library! >> http://sqljet.com/ - Java SQLite Library! >> >> >> On 10 March 2013 20:47, Daniel Alencar <daniel.calen...@gmail.com> wrote: >> > Hi Everybody, >> > >> > Is there a way to store two or more credentials in one >> > SVNAuthenticationManager? >> > >> > Background: >> > >> > I have two different SVN repositories >> > >> > svn1: svn://192.169.0.10/svn/projectX1 >> > svn2: svn://192.169.0.10/svn/projectX2 >> > >> > The repositories contains two differents evolutions of the ProjectX, so >> > i >> > want to do a diff of a fileX1 from svn1 to a fileX2 from svn2. In order >> > to >> > do this, i have to provide two credentials for my authentication manager >> > (one for svn1 and other for svn2), right? >> > >> > Then i could do the following: >> > >> > SvnOperationFactory opF = new SvnOperationFactory(); >> > >> > opF.setAuthenticationManager(<here my authentication manager with two >> > credentials>) >> > >> > Is this the solution? how do i do this? >> > >> > I'm thankful for any help you can provide, >> > >> > -- >> > Daniel Alencar da Costa >> > > > > -- > Daniel Alencar da Costa