svn merge -c 1301303 from trunk for HADOOP-8175.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1301305 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a8f0027ac0
commit
540fa6ea58
|
@ -276,6 +276,8 @@ Release 0.23.2 - UNRELEASED
|
||||||
HADOOP-8173. FsShell needs to handle quoted metachars. (Daryn Sharp via
|
HADOOP-8173. FsShell needs to handle quoted metachars. (Daryn Sharp via
|
||||||
szetszwo)
|
szetszwo)
|
||||||
|
|
||||||
|
HADOOP-8175. Add -p option to mkdir in FsShell. (Daryn Sharp via szetszwo)
|
||||||
|
|
||||||
Release 0.23.1 - 2012-02-17
|
Release 0.23.1 - 2012-02-17
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -39,20 +39,26 @@ class Mkdir extends FsCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String NAME = "mkdir";
|
public static final String NAME = "mkdir";
|
||||||
public static final String USAGE = "<path> ...";
|
public static final String USAGE = "[-p] <path> ...";
|
||||||
public static final String DESCRIPTION =
|
public static final String DESCRIPTION =
|
||||||
"Create a directory in specified location.";
|
"Create a directory in specified location.\n" +
|
||||||
|
" -p Do not fail if the directory already exists";
|
||||||
|
|
||||||
|
private boolean createParents;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processOptions(LinkedList<String> args) {
|
protected void processOptions(LinkedList<String> args) {
|
||||||
CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE);
|
CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE, "p");
|
||||||
cf.parse(args);
|
cf.parse(args);
|
||||||
|
createParents = cf.getOpt("p");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processPath(PathData item) throws IOException {
|
protected void processPath(PathData item) throws IOException {
|
||||||
if (item.stat.isDirectory()) {
|
if (item.stat.isDirectory()) {
|
||||||
|
if (!createParents) {
|
||||||
throw new PathExistsException(item.toString());
|
throw new PathExistsException(item.toString());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new PathIsNotDirectoryException(item.toString());
|
throw new PathIsNotDirectoryException(item.toString());
|
||||||
}
|
}
|
||||||
|
@ -60,6 +66,7 @@ class Mkdir extends FsCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processNonexistentPath(PathData item) throws IOException {
|
protected void processNonexistentPath(PathData item) throws IOException {
|
||||||
|
// TODO: should use createParents to control intermediate dir creation
|
||||||
if (!item.fs.mkdirs(item.path)) {
|
if (!item.fs.mkdirs(item.path)) {
|
||||||
throw new PathIOException(item.toString());
|
throw new PathIOException(item.toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -526,7 +526,11 @@
|
||||||
<comparators>
|
<comparators>
|
||||||
<comparator>
|
<comparator>
|
||||||
<type>RegexpComparator</type>
|
<type>RegexpComparator</type>
|
||||||
<expected-output>^-mkdir <path> \.\.\.:( |\t)*Create a directory in specified location.( )*</expected-output>
|
<expected-output>^-mkdir \[-p\] <path> \.\.\.:( |\t)*Create a directory in specified location.( )*</expected-output>
|
||||||
|
</comparator>
|
||||||
|
<comparator>
|
||||||
|
<type>TokenComparator</type>
|
||||||
|
<expected-output>-p Do not fail if the directory already exists</expected-output>
|
||||||
</comparator>
|
</comparator>
|
||||||
</comparators>
|
</comparators>
|
||||||
</test>
|
</test>
|
||||||
|
|
Loading…
Reference in New Issue