Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Accessing File info from a ChangeSet/History Entry

Given a change set or a history entry, how can we retrieve it's corresponding version number, associated file (IFile) and predecessor file?

0 votes



One answer

Permanent link
I figured out how to retrieve the associated file for a selected file version from a history entry. Listed below are the steps for the same -
1. Get a handle to the selected file version (or the IHistoryEntry item), lets call it "entry".
2. Get the Path of the file from the IHistoryEntry item - IPath path = new Path(entry.getTargetItem().getFQName());
3. Get the File itself from the Resource Plugin and the Path obtained in step 2 - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
4. Get the contents of the selected file version from the IHistoryEntry item - InputStream input = entry.getTargetItem().getContents(mon).getInputStream();
5. Set the contents of the file with the inputStream obtained in Step 4 - file.setContents(input, true, true, mon));
(First check it the file exits, if it doesn't, then create the project/folder and file first)

With this the file will now have the contents of the selected file version.

Obtaining the predecessor files is also simple. One can do that by first getting the previous entry of the selected file version - prevEntry = entry.getPrevious(mon);
and then following the same steps listed above to get the associated file version.

Regards,
Swathi

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,943

Question asked: Nov 05 '07, 9:14 a.m.

Question was seen: 6,369 times

Last updated: Nov 05 '07, 9:14 a.m.

Confirmation Cancel Confirm