use system environment when executing "hg create"

This commit is contained in:
Sebastian Sdorra
2012-12-14 20:11:33 +01:00
parent 8b22788fe8
commit 4cee27b744
2 changed files with 41 additions and 1 deletions

View File

@@ -105,6 +105,21 @@ public class SimpleCommand implements Command
return getResult(process); return getResult(process);
} }
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*
* @since 1.23
*/
public boolean isUseSystemEnvironment()
{
return useSystemEnvironment;
}
//~--- set methods ---------------------------------------------------------- //~--- set methods ----------------------------------------------------------
/** /**
@@ -119,6 +134,19 @@ public class SimpleCommand implements Command
this.environment = environment; this.environment = environment;
} }
/**
* Method description
*
*
* @param useSystemEnvironment
*
* @since 1.23
*/
public void setUseSystemEnvironment(boolean useSystemEnvironment)
{
this.useSystemEnvironment = useSystemEnvironment;
}
/** /**
* Method description * Method description
* *
@@ -162,9 +190,15 @@ public class SimpleCommand implements Command
processBuilder = processBuilder.directory(workDirectory); processBuilder = processBuilder.directory(workDirectory);
} }
Map<String,String> env = processBuilder.environment();
if ( useSystemEnvironment )
{
env.putAll(System.getenv());
}
if (environment != null) if (environment != null)
{ {
processBuilder.environment().putAll(environment); env.putAll(environment);
} }
return processBuilder.redirectErrorStream(true).start(); return processBuilder.redirectErrorStream(true).start();
@@ -244,6 +278,9 @@ public class SimpleCommand implements Command
/** Field description */ /** Field description */
private Map<String, String> environment; private Map<String, String> environment;
/** Field description */
private boolean useSystemEnvironment = false;
/** Field description */ /** Field description */
private File workDirectory; private File workDirectory;
} }

View File

@@ -546,6 +546,9 @@ public class HgRepositoryHandler
ExtendedCommand cmd = new ExtendedCommand(config.getHgBinary(), "init", ExtendedCommand cmd = new ExtendedCommand(config.getHgBinary(), "init",
directory.getAbsolutePath()); directory.getAbsolutePath());
// copy system environment, because of the PATH variable
cmd.setUseSystemEnvironment(true);
// issue-97 // issue-97
cmd.setWorkDirectory(baseDirectory); cmd.setWorkDirectory(baseDirectory);