List<HgFileRevision> (@NotNull FilePath filePath, @NotNull VirtualFile vcsRoot, @NotNull Project project, @Nullable HgRevisionNumber revisionNumber, int limit) { /* The standard way to get history following renames is to call hg log --follow. However: 1. It is broken in case of uncommitted rename (i.e. if the file is currently renamed in the working dir): in this case we use a special python template "follow(path)" which handles this case. 2. We don't use this python "follow(path)" function for all cases, because it is fully supported only since hg 2.6, and it is a bit slower and possibly less reliable than plain --follow parameter. 3. It doesn't work with "-r": in this case --follow is simply ignored (hg commit 24208:8b4b9ee6001a). As a workaround we could use the same follow(path) python, but this function requires current name of the file, which is unknown in case of "-r", and identifying it would be very slow. As a result we don't follow renames in annotate called from diff or from an old revision, which we can survive. */ FilePath originalFilePath = HgUtil.getOriginalFileName(filePath, ChangeListManager.getInstance(project)); if (revisionNumber == null && !filePath.isDirectory() && !filePath.equals(originalFilePath)) { // uncommitted renames detected return getHistoryForUncommittedRenamed(originalFilePath, vcsRoot, project, limit); } final HgLogCommand logCommand = new HgLogCommand(project); logCommand.setFollowCopies(!filePath.isDirectory()); logCommand.setIncludeRemoved(true); List<String> args = new ArrayList<>(); if (revisionNumber != null) { args.add("--rev"); args.add("reverse(0::" + revisionNumber.getChangeset() + ")"); } return logCommand.execute(new HgFile(vcsRoot, filePath), limit, false, args); }