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

How to get before and after state from a IChange?

I have a IChange respectively a IChangeSetHandle object. Now I would like to see the file that is represented by this state, as well as the difference between the before and the after state.

But I don't know how to really get the file from a IChange object. Any hints?

0 votes

Comments

 Any progress for this question? S M, could you attach your solution? 

Have you tried John's suggestion below? The IChange provides the before and after states that can be fetched with IVersionableManager or IScmItemService.



3 answers

Permanent link
 Hi, Tim
You are right if I use data.getSourceWorkspace, the file name is the old file name. Thanks!

ServiceConfigurationProvider configProvider = ServiceConfigurationProvider.FACTORY.create(
data.getSourceWorkspace(), changeSet.getComponent());

1 vote


Permanent link
 Fetch using IVersionableManager or IScmItemService.  

0 votes


Permanent link
 Hi, Tim
If some one rename the source file eg rename file1 to file2, there will be one "rename" change and shows file2 (moved from file1)
I want to get the file1 and file2 name to do some pre-condition, so I used the following code, but seems  both change.beforeState() and change.afterState()  return file2.  Can you help to figure out?
 
 IVersionableHandle versionableHandle = change.beforeState();
 if (change.kind() == IChange.RENAME) {
versionableHandle = change.afterState();
}
ServiceConfigurationProvider configProvider = ServiceConfigurationProvider.FACTORY.create(
data.getDestWorkspace(), changeSet.getComponent());
IVersionable item = (IVersionable) scmService.fetchState(versionableHandle, null, null);
IAncestorReport reports[] = scmService.configurationLocateAncestors(
configProvider, new IVersionableHandle[] {versionableHandle}, null, null);
String filename=toFullPath(item, reports[0].getNameItemPairs());

0 votes

Comments

My guess is that you're using the destination workspace for the configuration provider. Since the change set hasn't been delivered yet, it won't have the renamed state. I don't know if this would be an issue but it looks like it could be a problem.

The other issue is you have to get the paths for both states but your code only uses the after state to get the path.

1 vote

Thanks Tim.

So 
1. I should use data.getSourceWorkspace, is that right?
2. It is sample code, I have tried afterState and beforeState to get path. 

Is that what you mentioned IVersionableManager or IScmItemService?

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
× 12,023

Question asked: Aug 08 '12, 6:21 a.m.

Question was seen: 4,795 times

Last updated: Nov 13 '12, 11:38 a.m.

Related questions
Confirmation Cancel Confirm