Skip to content

Commit

Permalink
Merge pull request #22 from nimeacuerdo/fix-multiple-revisions-per-bu…
Browse files Browse the repository at this point in the history
…ild-issue

[FIXED JENKINS-12829] A failed update sets revision of build to 000000+
  • Loading branch information
Jesse Glick committed May 7, 2012
2 parents 99d221c + 84205ec commit a7483f9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/hudson/plugins/mercurial/MercurialSCM.java
Expand Up @@ -610,7 +610,9 @@ private void clone(AbstractBuild<?,?> build, Launcher launcher, FilePath reposit
ArgumentListBuilder upArgs = new ArgumentListBuilder();
upArgs.add("update");
upArgs.add("--rev", getBranch(env));
hg.run(upArgs).pwd(repository).join();
if (hg.run(upArgs).pwd(repository).join() != 0) {
throw new AbortException("Failed to update " + source + " to rev " + getBranch(env));
}

String tip = hg.tip(repository, null);
String rev = hg.tipNumber(repository, null);
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/hudson/plugins/mercurial/MercurialSCMTest.java
Expand Up @@ -3,6 +3,7 @@
import hudson.Launcher;
import hudson.Proc;
import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.model.Cause.UserCause;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
Expand Down Expand Up @@ -581,6 +582,22 @@ public void testTrailingUrlWhitespace() throws Exception {
AbstractBuild<?, ?> b = p.scheduleBuild2(0).get();
assertEquals(Result.SUCCESS, b.getResult());
}

@Bug(12829)
public void testNonExistingBranchesDontGenerateMercurialTagActionsInTheBuild() throws Exception {
AbstractBuild<?, ?> b;
FreeStyleProject p = createFreeStyleProject();
p.setScm(new MercurialSCM(hgInstallation, repo.getPath(), "non-existing-branch", null,
null, null, false));
hg(repo, "init");
touchAndCommit(repo, "dir1/f1");
b = p.scheduleBuild2(0).get();
for (Action action : b.getActions()) {
if (action instanceof MercurialTagAction) {
fail("There should not be any MercurialTagAction");
}
}
}

private PretendSlave createNoopPretendSlave() throws Exception {
return createPretendSlave(new NoopFakeLauncher());
Expand Down

0 comments on commit a7483f9

Please sign in to comment.