private static @NotNull String identifyDefaultHgExecutable() {
    File hgExecutableFromPath = PathEnvironmentVariableUtil.findInPath(SystemInfo.isWindows ? DEFAULT_WINDOWS_HG : DEFAULT_UNIX_HG,
                                                                       PathEnvironmentVariableUtil.getPathVariableValue(),
                                                                       null);
    if (hgExecutableFromPath != null) {
      return hgExecutableFromPath.getPath();
    }

    String[] paths;
    String programName;
    if (SystemInfo.isWindows) {
      programName = DEFAULT_WINDOWS_HG;
      paths = DEFAULT_WINDOWS_PATHS;
    }
    else {
      programName = DEFAULT_UNIX_HG;
      paths = DEFAULT_UNIX_PATHS;
    }

    for (String p : paths) {
      Path programPath = Paths.get(p, programName);
      if (Files.isExecutable(programPath)) {
        return programPath.toAbsolutePath().toString();
      }
    }
    // otherwise, take the first variant and hope it's in $PATH
    return programName;
  }
private static @NotNull String identifyDefaultHgExecutable()