# HG changeset patch # User Dmitry Neverov # Date 1311584647 -14400 # Node ID 9c06a500681c1fdee6033fe5690f26133b7fc722 # Parent 7270e63059f7fa80e883676fe3f99e99bca7fb81 Improve logging diff -r 7270e63059f7 -r 9c06a500681c mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java --- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java Thu Jul 07 14:10:26 2011 +0400 +++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java Mon Jul 25 13:04:07 2011 +0400 @@ -46,13 +46,20 @@ final boolean useLocalMirrors = isUseLocalMirrors(build); return new IncludeRuleUpdater() { public void process(@NotNull final IncludeRule includeRule, @NotNull final File workingDir) throws VcsException { - checkRuleIsValid(includeRule); - Settings settings = new Settings(vcsRoot); - if (useLocalMirrors) { - updateLocalMirror(vcsRoot, logger); + try { + checkRuleIsValid(includeRule); + Settings settings = new Settings(vcsRoot); + if (useLocalMirrors) { + updateLocalMirror(vcsRoot, logger); + } + updateRepository(workingDir, settings, logger, useLocalMirrors); + updateWorkingDir(settings, workingDir, toVersion, logger); + } catch (Exception e) { + if (e instanceof VcsException) + throw (VcsException) e; + else + throw new VcsException(e); } - updateRepository(workingDir, settings, logger, useLocalMirrors); - updateWorkingDir(settings, workingDir, toVersion, logger); } public void dispose() throws VcsException { @@ -79,21 +86,21 @@ private void initRepository(File workingDir, Settings settings, BuildProgressLogger logger, boolean useLocalMirrors) throws VcsException { try { - logger.message("Init repository at " + workingDir.getAbsolutePath()); String defaultPullUrl = getDefaultPullUrl(settings, useLocalMirrors); + logger.message("Init repository at " + workingDir.getAbsolutePath() + ", remote repository is " + defaultPullUrl); new Init(settings, workingDir, defaultPullUrl).execute(); } catch (IOException e) { throw new VcsException("Error while initializing repository at " + workingDir.getAbsolutePath(), e); } } - private void updateRepository(File workingDir, Settings settings, BuildProgressLogger logger, boolean useLocalMirrors) throws VcsException { + private void updateRepository(File workingDir, Settings settings, BuildProgressLogger logger, boolean useLocalMirrors) throws VcsException, IOException { if (!Settings.isValidRepository(workingDir)) { initRepository(workingDir, settings, logger, useLocalMirrors); } else { ensureUseRightRepository(workingDir, settings, logger, useLocalMirrors); } - logger.message("Start pulling changes"); + logger.message("Start pulling changes from " + getDefaultPullUrl(settings, useLocalMirrors)); new PullCommand(settings, workingDir).execute(); logger.message("Changes successfully pulled"); } @@ -111,24 +118,25 @@ } } - private void updateLocalMirror(VcsRoot root, BuildProgressLogger logger) throws VcsException { + private void updateLocalMirror(VcsRoot root, BuildProgressLogger logger) throws VcsException, IOException { Settings settings = new Settings(root); File mirrorDir = myMirrorManager.getMirrorDir(settings.getRepositoryUrl()); + logger.message("Update local mirror at " + mirrorDir); if (!Settings.isValidRepository(mirrorDir)) { initRepository(mirrorDir, settings, logger, false); } - logger.message("Start pulling changes to local mirror at " + mirrorDir); + logger.message("Start pulling changes from " + getDefaultPullUrl(settings, true)); new PullCommand(settings, mirrorDir).execute(); logger.message("Local mirror changes successfully pulled"); } - private void updateWorkingDir(final Settings settings, File workingDir, final String version, final BuildProgressLogger logger) throws VcsException { - logger.message("Updating working directory from the local repository copy"); + private void updateWorkingDir(final Settings settings, File workingDir, @NotNull final String version, final BuildProgressLogger logger) throws VcsException { + logger.message("Updating folder " + workingDir.getAbsolutePath() + " to revision " + version); UpdateCommand uc = new UpdateCommand(settings, workingDir); ChangeSet cs = new ChangeSet(version); uc.setToId(cs.getId()); uc.execute(); - logger.message("Working directory updated successfully"); + logger.message("Folder successfully updated"); } private String getDefaultPullUrl(Settings settings, boolean useLocalMirror) throws IOException {