How to get the change sets for a certain file
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
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 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? 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. 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. 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
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.