final Git git = Git.getInstance();
final File root = git.getTopmostManagedParent(srcFile);
if (root == null) {
return;
}
RequestProcessor rp = git.getRequestProcessor(root.getAbsolutePath());
Git.LOG.log(Level.FINE, "gitMoveImplementation(): File: {0} {1}", new Object[]{srcFile, dstFile}); // NOI18N
srcFile.renameTo(dstFile);
Runnable moveImpl = new Runnable() {
public void run() {
OutputLogger logger = OutputLogger.getLogger(root.getAbsolutePath());
try {
if (dstFile.isDirectory())
throw new IllegalStateException("Rename of directory " + dstFile);
int status = GitCommand.getSingleStatus(root, srcFile).getStatus();
Git.LOG.log(Level.FINE, "gitMoveImplementation(): Status: {0} {1}", new Object[]{srcFile, status}); // NOI18N
if (status == StatusInfo.STATUS_NOTVERSIONED_NEWLOCALLY ||
status == StatusInfo.STATUS_NOTVERSIONED_EXCLUDED) {
} else if (status == StatusInfo.STATUS_VERSIONED_ADDEDLOCALLY) {
IndexBuilder.create(root).
move(srcFile, dstFile).
write();
} else {
throw new IllegalStateException("Rename with status " + status);
}
} catch (Exception e) {
logger.output(e.getMessage());
Git.LOG.log(Level.FINE, "Git failed to rename: File: {0} {1}", new Object[]{srcFile.getAbsolutePath(), dstFile.getAbsolutePath()}); // NOI18N
} finally {
logger.closeLog();
}
}
};
rp.post(moveImpl);
}