for ( Version v : versions )
{
// Remove diff representing this promote
FileDifference difference = differencesMap.get( v.getElementId() );
// TODO: how are defuncts shown in the version history?
if ( difference != null )
{
String newVersionSpec = difference.getNewVersionSpec();
if ( newVersionSpec != null && newVersionSpec.equals( v.getRealSpec() ) )
{
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Removing difference for " + v );
}
differencesMap.remove( v.getElementId() );
}
}
// Add this file, unless the virtual version indicates this is the basis stream, and the real
// version came from our workspace stream (ie, this transaction is a promote from the workspace
// to its basis stream, and is therefore NOT a change
if ( v.getRealSpec().startsWith( streamPrefix ) && !v.getVirtualSpec().startsWith( streamPrefix ) )
{
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Skipping workspace to basis stream promote " + v );
}
}
else
{
ChangeFile f =
new ChangeFile( v.getElementName(), v.getVirtualSpec() + " (" + v.getRealSpec() + ")" );
files.add( f );
}
}
if ( versions.isEmpty() || !files.isEmpty() )
{
ChangeSet changeSet = new ChangeSet( t.getWhen(), t.getComment(), t.getAuthor(), files );
entries.add( changeSet );
}
else
{
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "All versions removed for " + t );
}
}
}
// Anything left in the differencesMap represents a change from a higher stream
// We don't have details on who or where these came from, but it is important to
// detect these for CI tools like Continuum
if ( !differencesMap.isEmpty() )
{
List<ChangeFile> upstreamFiles = new ArrayList<ChangeFile>();
for ( FileDifference difference : differencesMap.values() )
{
if ( difference.getNewVersionSpec() != null )
{
upstreamFiles.add( new ChangeFile( difference.getNewFile().getPath(),
difference.getNewVersionSpec() ) );
}
else
{
// difference is a deletion
upstreamFiles.add( new ChangeFile( difference.getOldFile().getPath(), null ) );
}
}
entries.add( new ChangeSet( endDate, "Upstream changes", "various", upstreamFiles ) );
}