Skip to content
Permalink
Browse files

[FIXED JENKINS-13329] --debug triggered fresh clones rather than upda…

…tes.
  • Loading branch information...
Jesse Glick
Jesse Glick committed May 1, 2012
1 parent 7728f3b commit 2dadbc8944937ad3a00fe5c82ef2584f71d26e31
@@ -62,6 +62,7 @@
*/
public class HgExe {
private final ArgumentListBuilder base;
private final ArgumentListBuilder baseNoDebug;
/**
* Environment variables to invoke hg with.
*/
@@ -77,6 +78,8 @@ public HgExe(MercurialSCM scm, Launcher launcher, AbstractBuild build, TaskListe

public HgExe(MercurialSCM scm, Launcher launcher, Node node, TaskListener listener, EnvVars env) throws IOException, InterruptedException {
base = scm.findHgExe(node, listener, true);
// XXX might be more efficient to have a single call returning ArgumentListBuilder[2]?
baseNoDebug = scm.findHgExe(node, listener, false);
this.node = node;
this.env = env;
this.launcher = launcher;
@@ -89,24 +92,24 @@ private ProcStarter l(ArgumentListBuilder args) {
return MercurialSCM.launch(launcher).cmds(args).stdout(listener).envs(env);
}

private ArgumentListBuilder seed() {
return base.clone();
private ArgumentListBuilder seed(boolean allowDebug) {
return (allowDebug ? base : baseNoDebug).clone();
}

public ProcStarter pull() {
return run("pull");
}

public ProcStarter clone(String... args) {
return l(seed().add("clone").add(args));
return l(seed(true).add("clone").add(args));
}

public ProcStarter bundleAll(String file) {
return run("bundle","--all",file);
}

public ProcStarter bundle(Collection<String> bases, String file) {
ArgumentListBuilder args = seed().add("bundle");
ArgumentListBuilder args = seed(true).add("bundle");
for (String head : bases) {
args.add("--base", head);
}
@@ -130,11 +133,11 @@ public ProcStarter cleanAll() {
* Runs arbitrary command.
*/
public ProcStarter run(String... args) {
return l(seed().add(args));
return l(seed(true).add(args));
}

public ProcStarter run(ArgumentListBuilder args) {
return l(seed().add(args.toCommandArray()));
return l(seed(true).add(args.toCommandArray()));
}

/**
@@ -207,7 +210,7 @@ public String config(FilePath repository, String name) throws IOException, Inter
*/
public String popen(FilePath repository, TaskListener listener, boolean useTimeout, ArgumentListBuilder args)
throws IOException, InterruptedException {
args = seed().add(args.toCommandArray());
args = seed(false).add(args.toCommandArray());

ByteArrayOutputStream rev = new ByteArrayOutputStream();
if (MercurialSCM.joinWithPossibleTimeout(l(args).pwd(repository).stdout(rev), useTimeout, listener) == 0) {
@@ -237,7 +240,7 @@ synchronized static Capability get(HgExe hg) {
MAP.put(hg.node, m);
}

List<String> hgConfig = hg.base.toList();
List<String> hgConfig = hg.seed(false).toList();
Capability cap = m.get(hgConfig);
if (cap==null)
m.put(hgConfig,cap = new Capability());
@@ -41,16 +41,20 @@ void setUp() throws Exception {
repo = createTmpDir();
}

@Bug(13329)
public void testBasicOps() throws Exception {
FreeStyleProject p = createFreeStyleProject();
p.setScm(new MercurialSCM(hgInstallation, repo.getPath(), null, null,
null, null, false));

hg(repo, "init");
touchAndCommit(repo, "a");
buildAndCheck(p, "a"); // this tests the clone op
String log = buildAndCheck(p, "a");
assertTrue(log, log.contains(" clone --"));
touchAndCommit(repo, "b");
buildAndCheck(p, "b"); // this tests the update op
log = buildAndCheck(p, "b");
assertTrue(log, log.contains(" update --"));
assertFalse(log, log.contains(" clone --"));
}

@Bug(4281)

0 comments on commit 2dadbc8

Please sign in to comment.
You can’t perform that action at this time.