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
Steve Ashton selected this answer as the correct answer
Comments
Steve Ashton
commented Jul 18 '14, 10:32 a.m.
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.
java.util.List locateAncestors(java.util.List versionableHandles, org.eclipse.core.runtime.IProgressMonitor monitor) throws TeamRepositoryExceptionFor 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
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.
Steve Ashton
commented Jul 18 '14, 11:24 a.m.
I found what I needed for the file move part here:
sam detweiler
commented Jul 18 '14, 11:30 a.m.
thanks for the feedback.
|
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.