Browse Source

iAllow several views per label

PR:	12585
Submitted By: Steve Hunter


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273920 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
3f1bc55590
1 changed files with 16 additions and 13 deletions
  1. +16
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Label.java

+ 16
- 13
src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Label.java View File

@@ -63,9 +63,9 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.StringUtils;


/**
/**
* Creates a new Perforce label and set contents to reflect current
* client file revisions.
*
@@ -99,7 +99,7 @@ public class P4Label extends P4Base {
}

/**
* when set to "locked", Perforce will lock the label once created; optional.
* when set to "locked", Perforce will lock the label once created; optional.
*/
public void setLock(String lock) {
this.lock = lock;
@@ -114,10 +114,14 @@ public class P4Label extends P4Base {
if (P4View == null || P4View.length() < 1) {
log("View not set, assuming //depot/...", Project.MSG_WARN);
P4View = "//depot/...";
} else {
P4View = StringUtils.replace(P4View, ":", "\n\t");
P4View = StringUtils.replace(P4View, ";", "\n\t");
}

if (desc == null || desc.length() < 1) {
log("Label Description not set, assuming 'AntLabel'", Project.MSG_WARN);
log("Label Description not set, assuming 'AntLabel'",
Project.MSG_WARN);
desc = "AntLabel";
}

@@ -126,7 +130,8 @@ public class P4Label extends P4Base {
}

if (name == null || name.length() < 1) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd-hh:mm");
SimpleDateFormat formatter
= new SimpleDateFormat("yyyy.MM.dd-hh:mm");
Date now = new Date();
name = "AntLabel-" + formatter.format(now);
log("name not set, assuming '" + name + "'", Project.MSG_WARN);
@@ -135,10 +140,10 @@ public class P4Label extends P4Base {

//We have to create a unlocked label first
String newLabel =
"Label: " + name + "\n" +
"Description: " + desc + "\n" +
"Options: unlocked\n" +
"View: " + P4View + "\n";
"Label: " + name +
"\nDescription: " + desc +
"\nOptions: unlocked" +
"\nView: \n\t" + P4View;

P4Handler handler = new P4HandlerAdapter() {
public void process(String line) {
@@ -157,7 +162,8 @@ public class P4Label extends P4Base {
});


log("Created Label " + name + " (" + desc + ")", Project.MSG_INFO);
log("Created Label " + name + " (" + desc + ") with view:\n" + P4View,
Project.MSG_INFO);

//Now lock if required
if (lock != null && lock.equalsIgnoreCase("locked")) {
@@ -196,8 +202,5 @@ public class P4Label extends P4Base {
handler.setOutput(labelSpec.toString());
execP4Command("label -i", handler);
}


}

}

Loading…
Cancel
Save