It's all about the answers!

Ask a question

Compare Workspaces, what means equal?


sam detweiler (12.5k6195201) | asked Feb 07 '14, 6:09 p.m.
retagged Feb 12 '14, 10:23 a.m. by Sonia Dimitrov (27159)
my migration utility copies workspaces from one repository to another.
I have almost 400 of them to do.. many will not have changed since last time I did this.

I've coded up the code to compare them first, and only copy if they are different... but there are so manay elements in the compare results object.  is there an easy way to sum up all the results?

Accepted answer


permanent link
Michael Valenta (3.7k3) | answered Feb 20 '14, 11:04 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Sam,

Using change sets is fine as long as you are not concerned about baselines. Otherwise, You could include baselines and check whether those lists are empty as well.
sam detweiler selected this answer as the correct answer

Comments
sam detweiler commented Feb 21 '14, 6:44 a.m.

thanks.. my 'assumption' is that even if one workspace has baselines different from another,  it also has changesets different from another.

changeset contained in a baseline are still changesets.  I don't care what is in the changeset, just the list of things that are different is all I am looking for.


Geoffrey Clemm commented Feb 21 '14, 10:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

A workspace can have baselines that another workspaces does not have, while having exactly the same change sets as the other workspace.   For example, start with two workspaces that have the same change sets, and execute a "create baseline" operation in the first workspace.   The two workspaces will continue to have the same change sets, but the first workspace will have a baseline that the second workspace does not have.


sam detweiler commented Feb 21 '14, 4:34 p.m. | edited Feb 21 '14, 4:36 p.m.

using both your nudges. I added code to compare for baselines and my previous changeset only checks would have misreported.. 


thank you. 

I updated the code in the prior comment to the latest..

One other answer



permanent link
sam detweiler (12.5k6195201) | answered Feb 18 '14, 10:39 a.m.
edited Feb 21 '14, 4:35 p.m.
I am thinking of just doing changset compare..  
    private static boolean has_workspacechanged(IWorkspaceConnection prodworkspace, IWorkspaceManager devmgr,
IAuditableHandle Owner, String workspacename) {
        boolean result = false;
        try
        {
        // get the workspace connection for this workspace
            List<IWorkspaceConnection>wslist = devmgr.findAllWorkspaces(Owner, workspacename, null);
            // if there was at least 1
            if(wslist.size()>=1)
            {
            // change set compare only
                IChangeHistorySyncReport compresult=prodworkspace.compareTo(wslist.get(0), WorkspaceComparisonFlags.INCLUDE_BASELINE_INFO|WorkspaceComparisonFlags.CHANGE_SET_COMPARISON_ONLY,new ArrayList< IComponentHandle>(), null);
                // if either list is not empty               
                if(!compresult.incomingChangeSets().isEmpty() || !compresult.outgoingChangeSets().isEmpty() || !compresult.incomingBaselines().isEmpty() || !compresult.outgoingBaselines().isEmpty())
                {
                // indicate the workspaces are not equal                    
                    System.out.println("workspaces are different="+workspacename);
                result= true;
                }
                else
                    System.out.println("workspaces are identical="+workspacename);
            }
            else
            {
                System.out.println("workspace not found = "+workspacename);
            result=true;
            }
        }
        catch (TeamRepositoryException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 
        // TODO Auto-generated method stub
        return result;
}

Comments
sam detweiler commented Feb 20 '14, 6:37 a.m.

if I compare just changesets is that enough? will changesets in new baselines also be detected?

no opportunity to test before I have to use this code Friday night

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.