Mercurial > hg > mercurial
changeset 431:9a2b6a7a3381
Better detection of the case when mercurial not found
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Sat, 12 May 2012 10:12:50 +0400 |
parents | 3600b68a4c0c |
children | 2617dcc70c15 |
files | mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java Fri May 11 19:33:48 2012 +0400 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java Sat May 12 10:12:50 2012 +0400 @@ -33,7 +33,8 @@ private static final Set<Integer> ERROR_EXIT_CODES = setOf(-1, 255); private static final String MERCURIAL_NOT_FOUND_MESSAGE_PREFIX = "Cannot run program \""; - private static final String MERCURIAL_NOT_FOUND_MESSAGE_SUFFIX = "No such file or directory"; + private static final String MERCURIAL_NOT_FOUND_MESSAGE_SUFFIX1 = "No such file or directory"; + private static final String MERCURIAL_NOT_FOUND_MESSAGE_SUFFIX2 = "The system cannot find the file specified"; private final Logger myLogger; private final String myCommand; @@ -91,14 +92,16 @@ } private boolean isMercurialNotFoundException(@Nullable Throwable e) { - if (e == null) - return false; - final String message = e.getMessage(); return e instanceof ProcessNotCreatedException && e.getCause() instanceof IOException && - message != null && + isMercurialNotFoundErrorMessage(e.getMessage()); + } + + private boolean isMercurialNotFoundErrorMessage(@Nullable String message) { + return message != null && message.startsWith(MERCURIAL_NOT_FOUND_MESSAGE_PREFIX) && - message.endsWith(MERCURIAL_NOT_FOUND_MESSAGE_SUFFIX); + (message.endsWith(MERCURIAL_NOT_FOUND_MESSAGE_SUFFIX1) || + message.endsWith(MERCURIAL_NOT_FOUND_MESSAGE_SUFFIX2)); } private void logStderr(String stderr) {