copy templates folder into lib/hg folder

This commit is contained in:
Sebastian Sdorra
2010-12-25 19:23:04 +01:00
parent cf62ffae35
commit d544722a65
2 changed files with 48 additions and 20 deletions

View File

@@ -64,7 +64,7 @@ public class WindowsHgInstaller extends AbstractHgInstaller
{
// TortoiseHg
"TortoiseHg\\hg.exe"
"TortoiseHg"
};
/** Field description */
@@ -80,7 +80,7 @@ public class WindowsHgInstaller extends AbstractHgInstaller
{
// TortoiseHg
"TortoiseHg\\template"
"TortoiseHg\\templates"
};
/** Field description */
@@ -91,6 +91,8 @@ public class WindowsHgInstaller extends AbstractHgInstaller
private static final Logger logger =
LoggerFactory.getLogger(WindowsHgInstaller.class);
public static String BINARY_MERCURIAL = "hg";
//~--- constructors ---------------------------------------------------------
/**
@@ -120,38 +122,29 @@ public class WindowsHgInstaller extends AbstractHgInstaller
super.install(config);
String progDir = getProgrammDirectory();
String path = null;
File libraryZip = find(progDir, PATH_LIBRARY_ZIP);
File libDir = null;
if (libraryZip != null)
{
File libDir = new File(baseDirectory, "lib\\hg");
libDir = new File(baseDirectory, "lib\\hg");
IOUtil.extract(libraryZip, libDir);
path = libDir.getAbsolutePath();
config.setPythonPath(libDir.getAbsolutePath());
}
if ( libDir != null )
{
File templateDir = find(progDir, PATH_TEMPLATE);
if (templateDir != null)
{
if (path != null)
{
path = path.concat(";").concat(templateDir.getAbsolutePath());
}
else
{
path = templateDir.getAbsolutePath();
IOUtil.copy(templateDir, new File(libDir, "templates"));
}
}
if (path != null)
{
config.setPythonPath(path);
}
checkForOptimizedByteCode(config);
config.setPythonBinary(getPythonBinary());
config.setHgBinary( search(PATH_HG, BINARY_MERCURIAL) );
}
/**

View File

@@ -44,6 +44,8 @@ import sonia.scm.io.ZipUnArchiver;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -163,6 +165,39 @@ public class IOUtil
}
}
public static void copy( File source, File target ) throws IOException
{
if ( source.isDirectory() )
{
if ( ! target.exists() )
{
mkdirs(target);
}
String[] children = source.list();
for ( String child : children )
{
copy(new File(source, child), new File(target, child));
}
}
else
{
FileInputStream input = null;
FileOutputStream output = null;
try
{
input = new FileInputStream( source );
output = new FileOutputStream( target );
copy(input, output);
}
finally
{
close(input);
close(output);
}
}
}
/**
* Method description
*