It's all about the answers!

Ask a question

How to get the change sets for a certain file


ioana lazar (9910) | asked Jul 23 '12, 5:37 a.m.
 Hello,
I would like to know if it is possible to get the last change set that modified a certain line in a file using Java Plain Client Libraries?
Thanks

One answer



permanent link
Andrew Niefer (7135) | answered Jul 23 '12, 3:10 p.m.
JAZZ DEVELOPER
edited Jul 24 '12, 1:19 p.m.
There is a getBlame method on com.ibm.team.filesystem.client.IFileSystemView.
IFileSystemManager manager = FileSystemCore.getFileSystemManager(workspaceConnection.teamRepository());
IFileSystemView fsView = manager.getFileSystemView(workspaceConnection);
List results = fsView.getBlame(component, fileItem, null, progressMonitor); 


In the list, entry n is the IChangeSet responsible for producing line n in the file.  (line numbering starts at 0).

How can I get the workspace handle so that I can get the workspaceConnection object and what is component and how do I get it?


You can find an ISharingDescriptor which will give you the workspace handle and component handle.

ISharingManager manager = FileSystemCore.getSharingManager();
IShareable shareable = manager.findShareable(new PathLocation(relativePath), ResourceType.FILE);
ISharingDescriptor desc = shareable.getShare(progressMonitor).getSharingDescriptor();
IComponentHandle component = desc.getComponent();
IContextHandle workspace = desc.getConnectionHandle();  //should be instanceof IWorkspaceHandle


Comments
ioana lazar commented Jul 24 '12, 3:52 a.m. | edited Jul 24 '12, 4:03 a.m.

Thanks for the getBlame method but I have some questions.How can I get the workspace handle so that I can get the workspaceConnection object and what is component and how do I get it?


Andrew Niefer commented Jul 24 '12, 1:20 p.m.
JAZZ DEVELOPER

I updated the answer with how to find the component and workspace handles.


ioana lazar commented Jul 25 '12, 6:33 a.m.

Hey... first of all thank you for the response, but I have a problem. for IShareable shareable = manager.findShareable(location, ResourceType.FILE); I get null for the shareable object. location is the ILocation is created with the path to my component, where I have the file. And I have problems finding javadoc for this methods.


Tim Mok commented Jul 26 '12, 3:45 p.m.
JAZZ DEVELOPER

I think the question is why you're getting null when getting the shareable. It sounds like the method isn't getting a valid ILocation to the file.


ioana lazar commented Jul 27 '12, 9:54 a.m. | edited Jul 27 '12, 9:55 a.m.

Hey. I've worked around and I didn't use the shareable instance. But I have 2 problems. 1. In the file that I am using for test I have 100 lines, and the result list from the blame method has 99 for size() and the first line is not empty. 2. The result list is with elements of type IChangeSetHandle. How can I get the corresponding change set and the name of the person that delivered that change set? Thanks

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.