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);
Accepted answer
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
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.
|