fix mercurial version informations

This commit is contained in:
Sebastian Sdorra
2012-06-24 16:00:46 +02:00
parent 1a31608f41
commit db42d835cf
3 changed files with 75 additions and 6 deletions

View File

@@ -127,7 +127,8 @@ public class HgRepositoryHandler
try try
{ {
this.jaxbContext = JAXBContext.newInstance(BrowserResult.class, this.jaxbContext = JAXBContext.newInstance(BrowserResult.class,
BlameResult.class, Changeset.class, ChangesetPagingResult.class); BlameResult.class, Changeset.class, ChangesetPagingResult.class,
HgVersion.class);
} }
catch (JAXBException ex) catch (JAXBException ex)
{ {
@@ -362,15 +363,23 @@ public class HgRepositoryHandler
try try
{ {
JAXBContext context = JAXBContext.newInstance(HgVersion.class);
HgVersion hgVersion = new HgVersionHandler(this, hgContextProvider.get(), HgVersion hgVersion = new HgVersionHandler(this, hgContextProvider.get(),
baseDirectory).getVersion(); baseDirectory).getVersion();
if (hgVersion != null) if (hgVersion != null)
{ {
if (logger.isDebugEnabled())
{
logger.debug("mercurial/python informations: {}", hgVersion);
}
version = MessageFormat.format(version, hgVersion.getPython(), version = MessageFormat.format(version, hgVersion.getPython(),
hgVersion.getMercurial()); hgVersion.getMercurial());
} }
else if (logger.isWarnEnabled())
{
logger.warn("could not retrieve version informations");
}
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -31,6 +31,10 @@
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
@@ -46,6 +50,64 @@ import javax.xml.bind.annotation.XmlRootElement;
public class HgVersion public class HgVersion
{ {
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final HgVersion other = (HgVersion) obj;
return Objects.equal(mercurial, other.mercurial)
&& Objects.equal(python, other.python);
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
return Objects.hashCode(mercurial, python);
}
/**
* Method description
*
*
* @return
*/
@Override
public String toString()
{
//J-
return Objects.toStringHelper(this)
.add("mercurial", mercurial)
.add("python", python)
.toString();
//J+
}
//~--- get methods ----------------------------------------------------------
/** /**
* Method description * Method description
* *

View File

@@ -36,8 +36,6 @@ package sonia.scm.repository;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import javax.xml.bind.JAXBContext;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
@@ -54,8 +52,8 @@ public class HgVersionHandler extends AbstractHgHandler
* @param context * @param context
* @param directory * @param directory
*/ */
public HgVersionHandler(HgRepositoryHandler handler, public HgVersionHandler(HgRepositoryHandler handler, HgContext context,
HgContext context, File directory) File directory)
{ {
super(handler, context, null, directory); super(handler, context, null, directory);
} }