You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by sz...@apache.org on 2012/03/16 00:42:39 UTC

svn commit: r1301273 - in /hadoop/common/trunk/hadoop-common-project/hadoop-common: CHANGES.txt src/main/java/org/apache/hadoop/fs/shell/Mkdir.java

Author: szetszwo
Date: Thu Mar 15 23:42:38 2012
New Revision: 1301273

URL: http://svn.apache.org/viewvc?rev=1301273&view=rev
Log:
HADOOP-8175. FsShell: Add -p option to mkdir.  Contributed by Daryn Sharp

Modified:
    hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1301273&r1=1301272&r2=1301273&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Thu Mar 15 23:42:38 2012
@@ -290,8 +290,8 @@ Release 0.23.2 - UNRELEASED 
 
   INCOMPATIBLE CHANGES
 
-  NEW FEATURES                                                                    
-  
+  NEW FEATURES
+
   IMPROVEMENTS
 
     HADOOP-8048. Allow merging of Credentials (Daryn Sharp via tgraves)
@@ -305,7 +305,10 @@ Release 0.23.2 - UNRELEASED 
     HADOOP-8137. Added links to CLI manuals to the site. (tgraves via
     acmurthy)  
 
+    HADOOP-8175. FsShell: Add -p option to mkdir.  (Daryn Sharp via szetszwo)
+
   OPTIMIZATIONS
+
     HADOOP-8071. Avoid an extra packet in client code when nagling is
     disabled. (todd)
 

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java?rev=1301273&r1=1301272&r2=1301273&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java Thu Mar 15 23:42:38 2012
@@ -43,16 +43,21 @@ class Mkdir extends FsCommand {
   public static final String DESCRIPTION =
     "Create a directory in specified location.";
 
+  private boolean createParents;
+  
   @Override
   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);
+    createParents = cf.getOpt("p");
   }
 
   @Override
   protected void processPath(PathData item) throws IOException {
     if (item.stat.isDirectory()) {
-      throw new PathExistsException(item.toString());
+      if (!createParents) {
+        throw new PathExistsException(item.toString());
+      }
     } else {
       throw new PathIsNotDirectoryException(item.toString());
     }
@@ -60,6 +65,7 @@ class Mkdir extends FsCommand {
 
   @Override
   protected void processNonexistentPath(PathData item) throws IOException {
+    // TODO: should use createParents to control intermediate dir creation 
     if (!item.fs.mkdirs(item.path)) {
       throw new PathIOException(item.toString());
     }