ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbaill...@apache.org
Subject cvs commit: jakarta-ant/proposal/sandbox/clearcase/src/main/org/apache/tools/ant/taskdefs/optional/clearcase CCMkelem.java
Date Mon, 17 Jun 2002 14:21:21 GMT
sbailliez    2002/06/17 07:21:21

  Modified:    proposal/sandbox/clearcase/src/main/org/apache/tools/ant/taskdefs/optional/clearcase
                        CCMkelem.java
  Log:
  Make sure the directory is versioned before adding an element
  
  Revision  Changes    Path
  1.3       +36 -0     jakarta-ant/proposal/sandbox/clearcase/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java
  
  Index: CCMkelem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/clearcase/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CCMkelem.java	11 Jan 2002 20:49:37 -0000	1.2
  +++ CCMkelem.java	17 Jun 2002 14:21:21 -0000	1.3
  @@ -88,6 +88,7 @@
           if (parent == null){
               parent = new CCFile(file.getParent());
               if ( !parent.isVersioned() ){
  +                mkelemDirectory(parent);
                   // ensure versioned dir
               } else if ( parent.isCheckedIn() ){
                   utils.checkout( parent );
  @@ -137,6 +138,41 @@
           }
           v.addElement("<pname>"); // dummy arg for file
           return v;
  +    }
  +
  +    private void mkelemDirectory(CCFile dir) throws BuildException {
  +        // resolve symoblic link if any...
  +        dir = new CCFile( utils.resolveSymbolicLink(dir.getAbsoluteFile()).getAbsolutePath()
);
  +
  +        // make sure that the parent is versioned...
  +        CCFile parent = new CCFile(dir.getParent());
  +        boolean should_ci = false;
  +        if ( !parent.isVersioned() ){
  +            mkelemDirectory(parent);
  +            codirs.put(parent.getPath(), parent.getAbsoluteFile());
  +        }
  +        // ...and checkout it if already checked in.
  +        if ( parent.isCheckedIn() ){
  +            utils.checkout(parent.getAbsoluteFile());
  +            codirs.put(parent.getPath(), parent.getAbsoluteFile());
  +        }
  +
  +        // rename the unversioned directory into a temporary one...
  +        File mkelem_file = new File(dir.getAbsolutePath() + "_mkelem");
  +        dir.renameTo( mkelem_file );
  +        // then create it via Clearcase...
  +        utils.mkdir( dir );
  +        codirs.put(dir.getPath(), dir.getAbsoluteFile());
  +        // .. and populate it back with its files...
  +        File[] files = dir.listFiles();
  +        for (int i = 0; i < files.length; i++){
  +            File newFile = new File(dir, files[i].getName());
  +            if ( !files[i].renameTo( newFile ) ) {
  +                throw new BuildException("Could not rename dir '" + files[i] + "' into
'" + newFile + "'" );
  +            }
  +        }
  +        // delete this one only if things went smoothly...
  +        mkelem_file.delete();
       }
   
   // bean setters
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message