Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [subversive-dev] Programmatically sharing a project and specifying credentials

Hi Alexander,

As mentioned earlier, sharing a project according to your instructions works fine. Now I have come across SVNFolderListener, which automatically (IOptionProvider.isAutomaticProjectShareEnabled()) shares projects the same way. Can you confirm that?

However, I am not sure, under which circumstances this mechanism is triggered. SVNFolderListener is registered for IResourceChangeEvent.PRE_BUILD. Is there a reason why SVNFolderListener is getting registered for PRE_BUILD instead of POST_CHANGE?

It seems like a PRE_BUILD event is broadcast whenever a project is opened or created (and SVNFolderListener then reacts only to creations). Can you confirm that? I have not yet found any useful documentation on when PRE_BUILD events are broadcast (BTW, our projects do not have any builders).

I want to be able to decide whether I can switch from my own implementation to relying on SVNFolderListener to do the work for me.


From: subversive-dev-bounces@xxxxxxxxxxx [subversive-dev-bounces@xxxxxxxxxxx] on behalf of Alexander Gurov [alexander.gurov@xxxxxxxxxxxx]
Sent: 26 September 2011 18:22
To: Developers mailing list
Subject: Re: [subversive-dev] Programmatically sharing a project and specifying credentials

Hello Biörn,

First of all you should detect which repository location you could use in order to share the project (below is the part of AlreadyConnectedPage which is responsible for the doing):

String url = ""> for (int i = 0; i < projects.length; i++) {
    SVNChangeStatus info = SVNUtility.getSVNInfoForNotConnected(projects[i]);
    String tmp = SVNUtility.decodeURL(info.url);
    if (url == null) {
        url = "">     }
    else {
        IPath tPath = SVNUtility.createPathForSVNUrl(url);
        IPath tPath2 = SVNUtility.createPathForSVNUrl(tmp);
        if (tPath2.isPrefixOf(tPath)) {
            url = "">         }
        else {
            while (!tPath.isPrefixOf(tPath2)) {
                tPath = tPath.removeLastSegments(1);
            url = "">         }
IRepositoryRoot []repositoryRoots = SVNUtility.findRoots(url, true); // here you will get all the acceptable repository locations

IRepositoryLocation location = repositoryRoots[0].getRepositoryLocation(); // you can take the first acceptable one, for example

If there are no location then you should create it first. In order to do so you can use the url you got from the previous step:

AbstractActionOperation createOp =  null;
if (repositoryRoots.length == 0) {
    location = SVNRemoteStorage.instance().newRepositoryLocation();
......// fill the IRepositoryLocation instance here
   createOp =  new AddRepositoryLocationOperation(location);

And in the end this is how you could share the projects that already contains Subversion metadata:

IProject []projects = ....;
IRepositoryLocation location = ....;

ReconnectProjectOperation mainOp = new ReconnectProjectOperation(projects, location); // reconnect operation itself

CompositeOperation op = new CompositeOperation(mainOp.getId(), mainOp.getMessagesClass());

op.add(new NotifyProjectStatesChangedOperation(mainOp.getProjects(), ProjectStatesChangedEvent.ST_PRE_SHARED)); // send required notifications
if (createOp != null) {
    op.add(new SaveRepositoryLocationsOperation());
    op.add(mainOp, new IActionOperation[] {createOp});
else {
op.add(new RefreshResourcesOperation(mainOp, IResource.DEPTH_INFINITE, RefreshResourcesOperation.REFRESH_ALL)); // initialize SVN metadata cache loading, redraw for the workspace resources tree etc.
op.add(new NotifyProjectStatesChangedOperation(mainOp.getProjects(), ProjectStatesChangedEvent.ST_POST_SHARED)); // send required notifications


Best regards,
Alexander Gurov.

14.09.2011 18:45, Biörnstad, Biörn пишет:

We want to programmatically enable the sharing of a project that already contains Subversion meta data (.svn). I have found the ShareProjectOperation and the ShareProjectWizard with the AlreadyConnectedPage. However, they contain much code and I am getting slightly lost.

Can someone give me instructions on how to achieve this?

Additionally, we want to provide the credentials (username and password) that Subversive should use when contacting the Subversion repository. Is it possible to specify the information when sharing the project? Or do we need to use an ISVNCredentialsPrompt through an IOptionProvider?

The point is that both operations should be done programmatically without user interaction.

Thanks in advance,
subversive-dev mailing list

Back to the top