Browse Source

iStarteam - when checking out to a revision label, directories are

never created unless needed.

PR:	14295
Submitted By: Steve Cohen


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274054 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
6409f0ec87
2 changed files with 72 additions and 13 deletions
  1. +61
    -12
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckout.java
  2. +11
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/TreeBasedTask.java

+ 61
- 12
src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamCheckout.java View File

@@ -241,7 +241,12 @@ public class StarTeamCheckout extends TreeBasedTask {
* and viewRootLocalFolder are defined * and viewRootLocalFolder are defined
*/ */
protected void testPreconditions() throws BuildException { protected void testPreconditions() throws BuildException {
//intentionally do nothing
if (this.isUsingRevisionLabel() && this.createDirs) {
log("Ignoring createworkingdirs while using a revision label." +
" Folders will be created only as needed.",
Project.MSG_WARN);
this.createDirs=false;
}
} }


/** /**
@@ -288,9 +293,9 @@ public class StarTeamCheckout extends TreeBasedTask {
if (this.deleteUncontrolled) { if (this.deleteUncontrolled) {
log(" Local items not found in the repository will be deleted."); log(" Local items not found in the repository will be deleted.");
} }
log(" Working directories will "+
(this.createDirs ? "be created as needed."
: "not be created."));
log(" Directories will be created"+
(this.createDirs ? " wherever they exist in the repository, even if empty."
: " only where needed to check out files."));
} }
/** /**
@@ -313,9 +318,45 @@ public class StarTeamCheckout extends TreeBasedTask {
targetFolder.getAbsolutePath()); targetFolder.getAbsolutePath());
} }
if (!targetFolder.exists()) {
if (!this.isUsingRevisionLabel()) {
if (this.createDirs) {
if (targetFolder.mkdirs()) {
log("Creating folder: " + targetFolder);
} else {
throw new BuildException(
"Failed to create local folder " + targetFolder);
}
}
}
}
Folder[] foldersList = starteamFolder.getSubFolders(); Folder[] foldersList = starteamFolder.getSubFolders();
Item[] filesList = starteamFolder.getItems(getTypeNames().FILE); Item[] filesList = starteamFolder.getItems(getTypeNames().FILE);

if (this.isUsingRevisionLabel()) {

// prune away any files not belonging to the revision label
// this is one ugly API from Starteam SDK
Hashtable labelItems = new Hashtable(filesList.length);
int s = filesList.length;
int[] ids = new int[s];
for (int i=0; i < s; i++) {
ids[i]=filesList[i].getItemID();
labelItems.put(new Integer(ids[i]), new Integer(i));
}
int[] foundIds = getLabelInUse().getLabeledItemIDs(ids);
s = foundIds.length;
Item[] labeledFiles = new Item[s];
for (int i=0; i < s; i++) {
Integer ID = new Integer(foundIds[i]);
labeledFiles[i] =
filesList[((Integer) labelItems.get(ID)).intValue()];
}
filesList = labeledFiles;
}
// note, it's important to scan the items BEFORE we make the // note, it's important to scan the items BEFORE we make the
@@ -338,17 +379,9 @@ public class StarTeamCheckout extends TreeBasedTask {
ufm.removeControlledItem(subfolder); ufm.removeControlledItem(subfolder);


if (isRecursive()) { if (isRecursive()) {
if (!subfolder.exists()) {
if (this.createDirs) {
log("Creating folder: " + subfolder);
subfolder.mkdirs();
}
}
if (subfolder.exists()) {
visit(stFolder, subfolder); visit(stFolder, subfolder);
} }
} }
}


for (int i = 0; i < filesList.length; i++) { for (int i = 0; i < filesList.length; i++) {
com.starbase.starteam.File stFile = com.starbase.starteam.File stFile =
@@ -413,6 +446,14 @@ public class StarTeamCheckout extends TreeBasedTask {
} }


if (this.isUsingRevisionLabel()) { if (this.isUsingRevisionLabel()) {
if (!targetFolder.exists()) {
if (targetFolder.mkdirs()) {
log("Creating folder: " + targetFolder);
} else {
throw new BuildException(
"Failed to create local folder " + targetFolder);
}
}
boolean success = eachFile.checkoutByLabelID( boolean success = eachFile.checkoutByLabelID(
localFile, localFile,
getIDofLabelInUse(), getIDofLabelInUse(),
@@ -472,6 +513,14 @@ public class StarTeamCheckout extends TreeBasedTask {
} }


if (checkout) { if (checkout) {
if (!targetFolder.exists()) {
if (targetFolder.mkdirs()) {
log("Creating folder: " + targetFolder);
} else {
throw new BuildException(
"Failed to create local folder " + targetFolder);
}
}
eachFile.checkout(this.lockStatus, eachFile.checkout(this.lockStatus,
!this.useRepositoryTimeStamp, true, true); !this.useRepositoryTimeStamp, true, true);
} }


+ 11
- 1
src/main/org/apache/tools/ant/taskdefs/optional/starteam/TreeBasedTask.java View File

@@ -380,6 +380,15 @@ public abstract class TreeBasedTask extends StarTeamTask {
this.labelInUse.isRevisionLabel(); this.labelInUse.isRevisionLabel();
} }


/**
* returns the label being used
*
* @return
*/
protected Label getLabelInUse() {
return this.labelInUse;
}

/** /**
* show the label in the log and its type. * show the label in the log and its type.
*/ */
@@ -532,7 +541,6 @@ public abstract class TreeBasedTask extends StarTeamTask {


public final void execute() throws BuildException { public final void execute() throws BuildException {
try { try {
testPreconditions();


Folder starteamrootfolder = configureRootStarteamFolder(); Folder starteamrootfolder = configureRootStarteamFolder();


@@ -540,6 +548,8 @@ public abstract class TreeBasedTask extends StarTeamTask {
java.io.File localrootfolder = java.io.File localrootfolder =
getLocalRootMapping(starteamrootfolder); getLocalRootMapping(starteamrootfolder);


testPreconditions();
// Tell user what he is doing // Tell user what he is doing
logOperationDescription(starteamrootfolder, localrootfolder); logOperationDescription(starteamrootfolder, localrootfolder);


Loading…
Cancel
Save