Browse Source

Make sure the directory is versioned before adding an element

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272897 13f79535-47bb-0310-9956-ffa450edef68
master
Stephane Bailliez 23 years ago
parent
commit
faf4cbed41
1 changed files with 36 additions and 0 deletions
  1. +36
    -0
      proposal/sandbox/clearcase/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java

+ 36
- 0
proposal/sandbox/clearcase/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java View File

@@ -88,6 +88,7 @@ public class CCMkelem extends CCMatchingTask {
if (parent == null){
parent = new CCFile(file.getParent());
if ( !parent.isVersioned() ){
mkelemDirectory(parent);
// ensure versioned dir
} else if ( parent.isCheckedIn() ){
utils.checkout( parent );
@@ -139,6 +140,41 @@ public class CCMkelem extends CCMatchingTask {
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
public void setType(String value){
type = value;


Loading…
Cancel
Save