Mercurial > hg > mercurial
changeset 627:eadc7e5c2236 Gaya-8.0.x
TW-28975, TW-30345 re-clone repository in case of "abandoned transaction" error
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Thu, 01 Aug 2013 15:14:04 +0400 |
parents | d5b4cd89ce46 |
children | 5b248e0be596 376e35ed7801 |
files | mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/exception/AbandonedTransactionFound.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java |
diffstat | 4 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java Thu Aug 01 13:42:40 2013 +0400 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java Thu Aug 01 15:14:04 2013 +0400 @@ -177,6 +177,7 @@ checkUnknownRevision(stderr); checkFileNotUnderTheRoot(stderr); checkConnectionRefused(stderr); + checkAbandonedTransaction(stderr); } private void checkUnrelatedRepository(@NotNull final String stderr) throws UnrelatedRepositoryException { @@ -213,6 +214,11 @@ throw new ConnectionRefusedException(); } + private void checkAbandonedTransaction(@NotNull final String stderr) throws AbandonedTransactionFound { + if (stderr.contains("abort: abandoned transaction found - run hg recover")) + throw new AbandonedTransactionFound(); + } + private static Set<Integer> setOf(Integer... ints) { return new HashSet<Integer>(asList(ints)); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/exception/AbandonedTransactionFound.java Thu Aug 01 15:14:04 2013 +0400 @@ -0,0 +1,11 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception; + +import jetbrains.buildServer.vcs.VcsException; + +public class AbandonedTransactionFound extends VcsException { + + public AbandonedTransactionFound() { + super("Abandoned transaction found"); + } + +}
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Thu Aug 01 13:42:40 2013 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Thu Aug 01 15:14:04 2013 +0400 @@ -18,6 +18,7 @@ import jetbrains.buildServer.Used; import jetbrains.buildServer.buildTriggers.vcs.AbstractVcsPropertiesProcessor; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.*; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.AbandonedTransactionFound; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.UnrelatedRepositoryException; import jetbrains.buildServer.log.Loggers; import jetbrains.buildServer.serverSide.*; @@ -448,6 +449,10 @@ Loggers.VCS.warn("Repository at " + root.getRepository() + " is unrelated, clone it again"); myMirrorManager.forgetDir(workingDir); syncRepository(root); + } catch (AbandonedTransactionFound e) { + Loggers.VCS.warn("Abandoned transaction found in repository " + root.getRepository() + ", clone it again"); + myMirrorManager.forgetDir(workingDir); + syncRepository(root); } } else { repo.doClone().fromRepository(root.getRepository())
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java Thu Aug 01 13:42:40 2013 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java Thu Aug 01 15:14:04 2013 +0400 @@ -3,6 +3,7 @@ import com.intellij.openapi.diagnostic.Logger; import jetbrains.buildServer.ExecResult; import jetbrains.buildServer.StreamGobbler; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.AbandonedTransactionFound; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.UnknownRevisionException; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.UnrelatedRepositoryException; import jetbrains.buildServer.vcs.VcsException; @@ -71,6 +72,13 @@ commandResult.checkCommandFailed(); } + @Test(expectedExceptions = AbandonedTransactionFound.class) + public void should_detect_abandoned_transaction_error() throws VcsException { + String abandonedTransactionError = "abort: abandoned transaction found - run hg recover!\n"; + CommandResult commandResult = commandResultFor(execResult().withStderr(abandonedTransactionError).withExitCode(255)); + commandResult.checkCommandFailed(); + } + @Test public void should_detect_unknown_revision_error() throws VcsException { String unknownRevision = "9c6a6b4aede0";