added scm-hg-plugin

This commit is contained in:
Sebastian Sdorra
2010-09-08 17:08:34 +02:00
parent 61c6f2d9bb
commit 5a8288337b
6 changed files with 384 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>sonia.scm.plugins</groupId>
<artifactId>scm-plugins</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>sonia.scm.plugin</groupId>
<artifactId>scm-hg-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<name>scm-hg-plugin</name>
</project>

View File

@@ -0,0 +1,85 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm.repository;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Sebastian Sdorra
*/
@XmlRootElement(name = "config")
public class HgConfig
{
/**
* Constructs ...
*
*/
public HgConfig() {}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public File getConfigDirectory()
{
return configDirectory;
}
/**
* Method description
*
*
* @return
*/
public File getRepositoryDirectory()
{
return repositoryDirectory;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param configDirectory
*/
public void setConfigDirectory(File configDirectory)
{
this.configDirectory = configDirectory;
}
/**
* Method description
*
*
* @param repositoryDirectory
*/
public void setRepositoryDirectory(File repositoryDirectory)
{
this.repositoryDirectory = repositoryDirectory;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private File configDirectory;
/** Field description */
private File repositoryDirectory;
}

View File

@@ -0,0 +1,208 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.SCMContextProvider;
import sonia.scm.util.AssertUtil;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import javax.xml.bind.JAXB;
/**
*
* @author Sebastian Sdorra
*/
public class HgRepositoryManager implements RepositoryManager
{
/** Field description */
public static final String TYPE_DISPLAYNAME = "Mercurial";
/** Field description */
public static final String TYPE_NAME = "hg";
/** Field description */
public static final RepositoryType TYPE = new RepositoryType(TYPE_NAME,
TYPE_DISPLAYNAME);
/** Field description */
public static final String DEFAULT_CONFIGPATH =
"repositories".concat(File.separator).concat(TYPE_NAME);
/** Field description */
public static final String CONFIG_FILE =
"config".concat(File.separator).concat("hg.xml");
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @throws IOException
*/
@Override
public void close() throws IOException {}
/**
* Method description
*
*
* @param repository
*
* @throws IOException
* @throws RepositoryException
*/
@Override
public void create(Repository repository)
throws RepositoryException, IOException
{
throw new UnsupportedOperationException("Not supported yet.");
}
/**
* Method description
*
*
* @param repository
*
* @throws IOException
* @throws RepositoryException
*/
@Override
public void delete(Repository repository)
throws RepositoryException, IOException
{
throw new UnsupportedOperationException("Not supported yet.");
}
/**
* Method description
*
*
* @param context
*/
@Override
public void init(SCMContextProvider context)
{
File baseDirectory = context.getBaseDirectory();
AssertUtil.assertIsNotNull(baseDirectory);
File configFile = new File(baseDirectory, CONFIG_FILE);
if (configFile.exists())
{
config = JAXB.unmarshal(configFile, HgConfig.class);
if (config.getConfigDirectory() == null)
{
File configDirectory = new File(baseDirectory, DEFAULT_CONFIGPATH);
config.setConfigDirectory(configDirectory);
}
}
}
/**
* Method description
*
*
* @param repository
*
* @throws IOException
* @throws RepositoryException
*/
@Override
public void modify(Repository repository)
throws RepositoryException, IOException
{
throw new UnsupportedOperationException("Not supported yet.");
}
/**
* Method description
*
*
* @param repository
*
* @throws IOException
* @throws RepositoryException
*/
@Override
public void refresh(Repository repository)
throws RepositoryException, IOException
{
throw new UnsupportedOperationException("Not supported yet.");
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param name
*
* @return
*/
@Override
public Repository get(String name)
{
throw new UnsupportedOperationException("Not supported yet.");
}
/**
* Method description
*
*
* @return
*/
@Override
public Collection<Repository> getAll()
{
throw new UnsupportedOperationException("Not supported yet.");
}
/**
* Method description
*
*
* @return
*/
@Override
public RepositoryType getType()
{
return TYPE;
}
/**
* Method description
*
*
* @return
*/
@Override
public boolean isConfigured()
{
return config != null;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private HgConfig config;
}

View File

@@ -0,0 +1 @@
sonia.scm.repository.HgRepositoryManager

View File

@@ -0,0 +1,64 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm;
/**
*
* @author Sebastian Sdorra
*/
public class ConfigurationException extends RuntimeException
{
/** Field description */
private static final long serialVersionUID = 3462977946341972841L;
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public ConfigurationException()
{
super();
}
/**
* Constructs ...
*
*
* @param message
*/
public ConfigurationException(String message)
{
super(message);
}
/**
* Constructs ...
*
*
* @param cause
*/
public ConfigurationException(Throwable cause)
{
super(cause);
}
/**
* Constructs ...
*
*
* @param message
* @param cause
*/
public ConfigurationException(String message, Throwable cause)
{
super(message, cause);
}
}

View File

@@ -87,4 +87,12 @@ public interface Manager<T, E extends Exception> extends Initable, Closeable
* @return
*/
public Collection<T> getAll();
/**
* Method description
*
*
* @return
*/
public boolean isConfigured();
}