Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 106460

Summary: [RelEng] Better support to replace existing projects with a given branch
Product: [Eclipse Project] Platform Reporter: Dani Megert <daniel_megert>
Component: CVSAssignee: Michael Valenta <Michael.Valenta>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P5 CC: markus.kell.r, Szymon.Brandys, tomasz.zarna
Version: 3.1Keywords: helpwanted
Target Milestone: 3.4 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard: hasPatch
Attachments:
Description Flags
Fix none

Description Dani Megert CLA 2005-08-09 08:42:45 EDT
R3.1

Here's the task  need to fulfill: replace all (cvs shared) projects for which
there's a R3_1_maintenance branch with that branch.

I tried the following:
- selected all projects in the Navigator and then replaced with R3_1_maintenance
  ==> some of the projects got empty because there was no branch
- tried to filter all non-shared from the CVS Repositories view but filters 
  aren't supported

Finally I had to do it manually one by one for more than 20 projects.
Comment 1 Markus Keller CLA 2007-06-29 07:11:55 EDT
>   ==> some of the projects got empty because there was no branch

This is actually a bug. The user should not be able to check out an inexistent branch. The action should just leave projects that don't have the selected branch alone.
Comment 2 Markus Keller CLA 2007-06-29 10:11:39 EDT
Created attachment 72778 [details]
Fix

I was too lazy to find all branched projects by hand, so I just fixed it in the source. The patch also fixes bug 125140.
Comment 3 Michael Valenta CLA 2007-06-29 10:37:10 EDT
Thanks for the patch Markus.
Comment 4 Michael Valenta CLA 2007-06-29 11:33:08 EDT
There is a fundamental problem with the patch. It assumes that the user chose to refresh the tags in the tag selection dialog. If the user does not refresh, it is possible that projects (or resources) that have the tag will be excluded from the operation. The only way I can see to make this work is to refresh the tags in the ReplaceOperation as well. I think that an acceptable workaround is to refresh in the replace operation if the tag is not found for a resource. I have added this to the patch and released it. I also added a short circuit which automatically adds the resource if the tag is a date, head or base tag.
Comment 5 Markus Keller CLA 2007-06-29 12:36:09 EDT
Thanks for the quick review/release.

However, I just got the NPE below with the version in HEAD after deleting a file and the choosing 'Replace With > Latest from HEAD' on the parent folder. It looks like getTag() can return null.

java.lang.NullPointerException
	at org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation.addResourceIfTagExists(ReplaceOperation.java:145)
	at org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation.getResourcesToUpdate(ReplaceOperation.java:131)
	at org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation.internalExecuteCommand(ReplaceOperation.java:86)
	at org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation.access$0(ReplaceOperation.java:84)
	at org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation$1.run(ReplaceOperation.java:68)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1797)
	at org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation.executeCommand(ReplaceOperation.java:65)
	at org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation.execute(SingleCommandOperation.java:42)
	at org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation.execute(RepositoryProviderOperation.java:280)
	at org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation.execute(SingleCommandOperation.java:66)
	at org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation.execute(RepositoryProviderOperation.java:256)
	at org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation.execute(RepositoryProviderOperation.java:210)
	at org.eclipse.team.internal.ccvs.ui.operations.CVSOperation.run(CVSOperation.java:81)
	at org.eclipse.team.internal.ui.actions.JobRunnableContext.run(JobRunnableContext.java:144)
	at org.eclipse.team.internal.ui.actions.JobRunnableContext$ResourceJob.runInWorkspace(JobRunnableContext.java:72)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


Comment 6 Markus Keller CLA 2007-06-29 12:43:08 EDT
(In reply to comment #4)
> I also added a short circuit
> which automatically adds the resource if the tag is a date, head or base tag.

Changing

    if (tag.getType() == CVSTag.DATE || tag.isHeadTag() || tag.isBaseTag())

in ReplaceOperation.addResourceIfTagExists(..) to

    if (tag == null || tag.getType() == CVSTag.DATE || tag.isHeadTag() ||
            tag.isBaseTag())

fixes the problem.
Comment 7 Dani Megert CLA 2007-07-03 06:14:19 EDT
Bumping up the severity: I can no longer use Replace With > Latest From HEAD on my files as I always get an NPE.
Comment 8 Michael Valenta CLA 2007-07-03 09:40:02 EDT
Sorry about that. Fix released to HEAD.
Comment 9 Tomasz Zarna CLA 2007-08-07 09:05:39 EDT
Verified in I20070806-1800. "Replace With >" for multiple projects works as expected.