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

Identifying before and after path for IChange in ChangeHistory

 I am trying to distinguish between add/update/delete/move actions taken on files when looking at a change history.  I was assuming that I would be able to use the beforeState and afterState of the IChange to decide what action was taken. For example, I would have expected the before/after state for a delete to be [content/null] respectively, instead the after state still contains the content of the file.

I must be thinking about this the wrong way. Is there a better way to correctly identify what happened to a file?  Related, how would I determine the before path and the after path for a file move?
I am currently using  configuration.determineAncestorsInHistory(fileHandles, MONITOR); to get the path of an IChange, but I assume that only gets me the after path. How would I get the before path?

EDIT:  Updated title to reflect changes to question. I realized I was missing seeing the after state for the IChanges which were deletes.  So now my question really relates to the second paragraph... How do I get the before path and the after path for a given change? I am getting the same path for both changes when i moved a file by deleting it and then adding it to another folder.

This is how I am getting the paths right now:

List<IVersionableHandle> fileHandles = new ArrayList<IVersionableHandle>();
for (Object changeSetO : cs.changes()) {
  IChange changeSet = (IChange) changeSetO;
  IItemHandle itemHandle = changeSet.item();
  fileHandles.add((IVersionableHandle) itemHandle);
}
IConfiguration configuration = wc.configuration(cs.getComponent());
List<IAncestorReport> list = configuration.determineAncestorsInHistory(fileHandles, MONITOR);

0 votes


Accepted answer

Permanent link
according to the java doc (you are looking at the javadoc, right?) null state before means add, null state after means delete

then you would look at the merge type I think if both before and after are not null.

but one fo the SCM team folks should be along shortly to add/correct

Modifier and Type Method and Description
IVersionableHandle afterState()
Returns the "after" state of the versionable item, or null if the change is the deletion of a versionable item from the configuration.
IVersionableHandle beforeState()
Returns the "before" state of the versionable item, or null if the change is the addition of a versionable item to the configuration.
int getMergeKind(IVersionableHandle mergeState)
Returns the change kind which describes the type of change between the supplied merge state and the after state.

Steve Ashton selected this answer as the correct answer

0 votes

Comments

 Thanks for the info. I've edited my question to match. My remaining question is about file moves and how to get the path from before the move as well as the path after the move.

sorry, I do not know the answer to that.

but looking at IConfiguration again

java.util.List locateAncestors(java.util.List versionableHandles,
                             org.eclipse.core.runtime.IProgressMonitor monitor)
                               throws TeamRepositoryException
For each specified item, retrieves the sequence of name-item pairs that leads to that item in the configuration starting at a root folder. It is assumed that the reference versions can be found in the component that scopes this configuration.

This information could be turned into a path by combining the names from each folder entry in sequence. The operation fails by throwing TeamRepositoryException if the client is not logged in to the repository.

There can be at most one path to any particular versionable item in a configuration. A folder namespace is a strict tree with a single root for each component; there is no equivalent of Unix-style hard links.

so it sounds like you can get the data to construct the current path.


thanks for the feedback.

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,934
× 411
× 169

Question asked: Jul 18 '14, 9:47 a.m.

Question was seen: 4,651 times

Last updated: Jul 18 '14, 11:30 a.m.

Confirmation Cancel Confirm