}
public boolean moveProject(final IResourceTree tree, final IProject source,
final IProjectDescription description, final int updateFlags,
final IProgressMonitor monitor) {
final RepositoryMapping srcm = RepositoryMapping.getMapping(source);
if (srcm == null)
return false;
IPath newLocation = null;
if (description.getLocationURI() != null)
newLocation = URIUtil.toPath(description.getLocationURI());
else
newLocation = source.getWorkspace().getRoot().getLocation()
.append(description.getName());
IPath sourceLocation = source.getLocation();
// Prevent a serious error.
if (sourceLocation.isPrefixOf(newLocation)
&& sourceLocation.segmentCount() != newLocation.segmentCount()
&& !"true".equals(System.getProperty("egit.assume_307140_fixed"))) { //$NON-NLS-1$//$NON-NLS-2$
// Graceful handling of bug, i.e. refuse to destroy your code
tree.failed(new Status(
IStatus.ERROR,
Activator.getPluginId(),
0,
"Cannot move project. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=307140 (not resolved in 3.7)", //$NON-NLS-1$
null));
return true;
}
File newLocationFile = newLocation.toFile();
// check if new location is below the same repository
Path workTree = new Path(srcm.getRepository().getWorkTree().getAbsolutePath());
int matchingFirstSegments = workTree.matchingFirstSegments(newLocation);
if (matchingFirstSegments == workTree.segmentCount()) {
return moveProjectHelperMoveOnlyProject(tree, source, description, updateFlags,
monitor, srcm, newLocationFile);
} else {