Index: src/main/java/hudson/plugins/mercurial/MercurialSCM.java =================================================================== --- src/main/java/hudson/plugins/mercurial/MercurialSCM.java (révision 12555) +++ src/main/java/hudson/plugins/mercurial/MercurialSCM.java (copie de travail) @@ -28,7 +28,7 @@ /** * Mercurial SCM. - * + * * @author Kohsuke Kawaguchi */ public class MercurialSCM extends SCM implements Serializable { @@ -36,7 +36,7 @@ * Source repository URL from which we pull. */ private final String source; - + /** * Prefixes of files within the repository which we're dependent on. * Storing as member variable so as to only parse the dependencies string once. @@ -44,9 +44,9 @@ private transient final Set _modules = new HashSet(); // Same thing, but not parsed for jelly. private final String modules; - + /** - * In-repository branch to follow. Null indicates "default". + * In-repository branch to follow. Null indicates "default". */ private final String branch; @@ -113,8 +113,15 @@ FilePath tmpFile = workspace.createTextTempFile("tmp", "style", FILES_STYLE); // Get the list of changed files. + ArgumentListBuilder args = new ArgumentListBuilder(); + args.add(getDescriptor().getHgExe(), "incoming", "--style", + tmpFile.getRemote()); + if (branch != null) { + args.add("-r", branch); + } + launcher.launch( - new String[]{getDescriptor().getHgExe(), "incoming", "--style", tmpFile.getRemote()}, + args.toCommandArray(), EnvVars.masterEnvVars, new ForkOutputStream(baos, output), workspace).join(); @@ -272,9 +279,28 @@ listener.error("Failed to pull"); return false; } + // pull + hgBundle.delete(); // do not leave it in workspace - hgBundle.delete(); // do not leave it in workspace + // nuxeo patch update to the right branch after a pull + try { + ArgumentListBuilder args = new ArgumentListBuilder(); + args.add(getDescriptor().getHgExe(), "update", "-C"); + if (branch != null) { + args.add("-r", branch); + } + if (launcher.launch(args.toCommandArray(), build.getEnvVars(), + listener.getLogger(), workspace).join() != 0) { + listener.error("Failed to update"); + return false; + } + } catch (IOException e) { + listener.error("Failed to update"); + return false; + } + + return true; }