Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share #7

Merged
merged 10 commits into from
Oct 17, 2011
4 changes: 4 additions & 0 deletions src/main/java/hudson/plugins/mercurial/HgRc.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public static File getHgRcFile(File repository) {
return new File(repository,".hg/hgrc");
}

public static File getShareFile(File repository) {
return new File(repository, ".hg/sharedpath");
}

private Section createSection(String name) {
Section s = sections.get(name);
if(s==null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Set;
import java.util.*;

/**
* Parses the changelog.xml.
Expand Down Expand Up @@ -67,6 +65,22 @@ public MercurialChangeSetList parse(AbstractBuild build, File changelogFile) thr
}
}

//sort the changes from oldest to newest, this gives the best result in the Jenkins changes view,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this part needed? Did the rev specification in determineChanges not give the right ordering, or was this to handle backwards compatibility with previous versions of the plugin that may have persisted change log files with incorrect ordering?

//and is like the old situation where 'hg incoming' was used to determine the changelog
Collections.sort(r, new Comparator<MercurialChangeSet>() {
public int compare(MercurialChangeSet o1, MercurialChangeSet o2) {
//don't do return o1.getRev() - o2.getRev(), as that is susceptible to integer overflow
if(o1.getRev() < o2.getRev()) {
return -1;
}
if (o1.getRev() == o2.getRev()) {
return 0;
} else {
return 1;
}
}
});

return new MercurialChangeSetList(build,r);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ public class MercurialInstallation extends ToolInstallation implements NodeSpec
private String downloadForest;
private boolean debug;
private boolean useCaches;
private boolean useSharing;

@DataBoundConstructor
public MercurialInstallation(String name, String home, String executable, String downloadForest, boolean debug, boolean useCaches, List<? extends ToolProperty<?>> properties) {
public MercurialInstallation(String name, String home, String executable, String downloadForest, boolean debug, boolean useCaches, boolean useSharing, List<? extends ToolProperty<?>> properties) {
super(name, home, properties);
this.executable = Util.fixEmpty(executable);
this.downloadForest = Util.fixEmpty(downloadForest);
this.debug = debug;
this.useCaches = useCaches;
this.useCaches = useCaches || useSharing;
this.useSharing = useSharing;
}

public String getExecutable() {
Expand All @@ -81,16 +83,20 @@ public boolean isUseCaches() {
return useCaches;
}

public boolean isUseSharing() {
return useSharing;
}

public static MercurialInstallation[] allInstallations() {
return Hudson.getInstance().getDescriptorByType(DescriptorImpl.class).getInstallations();
}

public MercurialInstallation forNode(Node node, TaskListener log) throws IOException, InterruptedException {
return new MercurialInstallation(getName(), translateFor(node, log), executable, downloadForest, debug, useCaches, getProperties().toList());
return new MercurialInstallation(getName(), translateFor(node, log), executable, downloadForest, debug, useCaches, useSharing, getProperties().toList());
}

public MercurialInstallation forEnvironment(EnvVars environment) {
return new MercurialInstallation(getName(), environment.expand(getHome()), executable, downloadForest, debug, useCaches, getProperties().toList());
return new MercurialInstallation(getName(), environment.expand(getHome()), executable, downloadForest, debug, useCaches, useSharing, getProperties().toList());
}

@Extension
Expand Down