ItemLatestState (FilePath filePath) { VirtualFile vcsRoot = VcsUtil.getVcsRootFor(project, filePath); if (vcsRoot == null) { return null; } HgWorkingCopyRevisionsCommand command = new HgWorkingCopyRevisionsCommand(project); HgRevisionNumber currentRevision = command.identify(vcsRoot).getFirst(); if (currentRevision == null) { return null; } boolean fileExists = filePath.getIOFile().exists(); if (currentRevision.isWorkingVersion()) { return new ItemLatestState(command.firstParent(vcsRoot), fileExists, true); } return new ItemLatestState(currentRevision, fileExists, true); }