It's all about the answers!

Ask a question

How to find change's moved from where?


Mehmet Ali Aydın (6133) | asked Oct 18 '10, 11:13 a.m.
Hello,

I have a Change with kind MOVE. I can get versioned item's current path but couldn't find anyway to get previous path.

How to find change's moved from where?

I use the code below to get current path of folderHandle and fileItemHandle. I tried to get previous path with IConfiguration.determineAncestorsInHistory and IConfiguration.locateAncestors methods with IChange.afterState and IChange.beforeState. They always return current path.

private static String findChangePath(IVersionableHandle vhandle, IConfiguration iconfig) throws TeamRepositoryException

{
List filesToSearch = new ArrayList();
filesToSearch.add(vhandle);
List ancestor = iconfig.locateAncestors(filesToSearch, monitor);
String path = "";

for(Object ancestorObj:ancestor)
{
IAncestorReport ancestorImpl = (IAncestorReport)ancestorObj;

for(Object nameItemPairObj:ancestorImpl.getNameItemPairs())
{
NameItemPairImpl nameItemPair = (NameItemPairImpl)nameItemPairObj;
Object item = SCMPlatform.getWorkspaceManager(teamRepository).versionableManager().fetchCompleteState(nameItemPair.getItem(), null);
String pathName = "";
if(item instanceof IFolder)
{
pathName = ((IFolder)item).getName();
}
else if(item instanceof IFileItem)
{
pathName = ((IFileItem)item).getName();
}
if(!pathName.equals(""))
path = path + "\\" + pathName;
}
}

return path;
}

One answer



permanent link
Geoffrey Clemm (30.1k33035) | answered Oct 18 '10, 2:14 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
In general, a file change doesn't have a pathname. It just has a
parent directory and its name within that parent directory. That change
can be accepted into many different workspaces, and the pathname of that
file can be different in all of them (but it will always have the same
last segment).

So you can ask for a pathname of a file change in a given configuration
(which you have done below), but there is no such thing as a "pathname
of a file change" outside of a configuration context, either before or
after the move.

Cheers,
Geoff

On 10/18/2010 11:23 AM, underprotect wrote:
Hello,

I have a Change with kind MOVE. I can get versioned item's current
path but couldn't find anyway to get previous path.

How to find change's moved from where?

I use the code below to get current path of folderHandle and
fileItemHandle. I tried to get previous path with
IConfiguration.determineAncestorsInHistory and
IConfiguration.locateAncestors methods with IChange.afterState and
IChange.beforeState. They always return current path.

private static String
findChangePath(IVersionableHandle vhandle, IConfiguration
iconfig) throws TeamRepositoryException
{
List filesToSearch = new ArrayList();
filesToSearch.add(vhandle);
List ancestor = iconfig.locateAncestors(filesToSearch,
monitor);
String path = "";

for(Object ancestorObj:ancestor)
{
IAncestorReport ancestorImpl =
(IAncestorReport)ancestorObj;

for(Object
nameItemPairObj:ancestorImpl.getNameItemPairs())
{
NameItemPairImpl nameItemPair =
(NameItemPairImpl)nameItemPairObj;
Object item =
SCMPlatform.getWorkspaceManager(teamRepository).versionableManager().fetchCompleteState(nameItemPair.getItem(),
null);
String pathName = "";
if(item instanceof IFolder)
{
pathName = ((IFolder)item).getName();
}
else if(item instanceof IFileItem)
{
pathName = ((IFileItem)item).getName();
}
if(!pathName.equals(""))
path = path + "\\" + pathName;
}
}

return path;
}

Your answer


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