PR: 24110 Submitted by: Steve Cohen (scohen at apache dot org) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275572 13f79535-47bb-0310-9956-ffa450edef68master
@@ -76,6 +76,7 @@ import org.apache.tools.ant.BuildException; | |||||
* | * | ||||
* @author Christopher Charlier, ThoughtWorks, Inc. 2001 | * @author Christopher Charlier, ThoughtWorks, Inc. 2001 | ||||
* @author <a href="mailto:jcyip@thoughtworks.com">Jason Yip</a> | * @author <a href="mailto:jcyip@thoughtworks.com">Jason Yip</a> | ||||
* @author <a href="mailto:scohen@apache.org">Steve Cohen</a> | |||||
* @see <A HREF="http://www.starbase.com/">StarBase Web Site</A> | * @see <A HREF="http://www.starbase.com/">StarBase Web Site</A> | ||||
* | * | ||||
* @ant.task name="stlabel" category="scm" | * @ant.task name="stlabel" category="scm" | ||||
@@ -179,25 +180,32 @@ public class StarTeamLabel extends StarTeamTask { | |||||
+ "both specified. A revision label cannot be a build label."); | + "both specified. A revision label cannot be a build label."); | ||||
} | } | ||||
View snapshot = openView(); | |||||
// Create the new label and update the repository | |||||
if (this.revisionlabel) { | |||||
new Label(snapshot, this.labelName, this.description).update(); | |||||
log("Created Revision Label " + this.labelName); | |||||
} else if (null != lastBuild) { | |||||
new Label(snapshot, this.labelName, this.description, this.lastBuild, | |||||
this.buildlabel).update(); | |||||
log("Created View Label (" | |||||
+ (this.buildlabel ? "" : "non-") + "build) " + this.labelName | |||||
+ " as of " + this.lastBuild.toString()); | |||||
} else { | |||||
new Label(snapshot, this.labelName, this.description, | |||||
this.buildlabel).update(); | |||||
log("Created View Label (" | |||||
+ (this.buildlabel ? "" : "non-") + "build) " + this.labelName); | |||||
try { | |||||
View snapshot = openView(); | |||||
// Create the new label and update the repository | |||||
if (this.revisionlabel) { | |||||
new Label(snapshot, this.labelName, this.description).update(); | |||||
log("Created Revision Label " + this.labelName); | |||||
} else if (null != lastBuild) { | |||||
new Label(snapshot, this.labelName, this.description, this.lastBuild, | |||||
this.buildlabel).update(); | |||||
log("Created View Label (" | |||||
+ (this.buildlabel ? "" : "non-") + "build) " + this.labelName | |||||
+ " as of " + this.lastBuild.toString()); | |||||
} else { | |||||
new Label(snapshot, this.labelName, this.description, | |||||
this.buildlabel).update(); | |||||
log("Created View Label (" | |||||
+ (this.buildlabel ? "" : "non-") + "build) " + this.labelName); | |||||
} | |||||
} catch (Exception e) { | |||||
throw new BuildException(e); | |||||
} finally { | |||||
disconnectFromServer(); | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
@@ -117,7 +117,7 @@ public abstract class StarTeamTask extends Task { | |||||
private void logStarteamVersion() { | private void logStarteamVersion() { | ||||
log("StarTeam version: " | log("StarTeam version: " | ||||
+ BuildNumber.getDisplayString(), Project.MSG_DEBUG); | |||||
+ BuildNumber.getDisplayString(), Project.MSG_VERBOSE); | |||||
} | } | ||||
@@ -317,6 +317,18 @@ public abstract class StarTeamTask extends Task { | |||||
return this.server; | return this.server; | ||||
} | } | ||||
/** | |||||
* disconnects from the StarTeam server. Should be called from the | |||||
* finally clause of every StarTeamTask-based execute method. | |||||
*/ | |||||
protected final void disconnectFromServer() { | |||||
if (null != this.server) { | |||||
this.server.disconnect(); | |||||
log("successful disconnect from StarTeam Server " + servername, | |||||
Project.MSG_VERBOSE); | |||||
} | |||||
} | |||||
/** | /** | ||||
* returns a list of TypeNames known to the server. | * returns a list of TypeNames known to the server. | ||||
* | * | ||||
@@ -362,6 +374,8 @@ public abstract class StarTeamTask extends Task { | |||||
} | } | ||||
View snapshot = createSnapshotView(view); | View snapshot = createSnapshotView(view); | ||||
log("Connected to StarTeam view " + getURL(), | |||||
Project.MSG_VERBOSE); | |||||
this.server = snapshot.getServer(); | this.server = snapshot.getServer(); | ||||
return snapshot; | return snapshot; | ||||
} | } | ||||
@@ -723,6 +723,8 @@ public abstract class TreeBasedTask extends StarTeamTask { | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
throw new BuildException(e); | throw new BuildException(e); | ||||
} finally { | |||||
disconnectFromServer(); | |||||
} | } | ||||
} | } | ||||
@@ -735,7 +737,7 @@ public abstract class TreeBasedTask extends StarTeamTask { | |||||
if (!stLabel.isRevisionLabel() && !stLabel.isViewLabel()) { | if (!stLabel.isRevisionLabel() && !stLabel.isViewLabel()) { | ||||
throw new BuildException("Unexpected label type."); | throw new BuildException("Unexpected label type."); | ||||
} | } | ||||
log("using label " + stLabel.getName(), Project.MSG_DEBUG); | |||||
log("using label " + stLabel.getName(), Project.MSG_VERBOSE); | |||||
this.labelInUse = stLabel; | this.labelInUse = stLabel; | ||||
return; | return; | ||||
} | } | ||||