P4Changepublic class P4Change extends P4Base Requests a new changelist from the Perforce server.
P4Change creates a new changelist in perforce. P4Change sets the property
${p4.change} with the new changelist number. This should then be passed into
p4edit and p4submit. |
Fields Summary |
---|
protected String | emptyChangeList | protected String | description |
Methods Summary |
---|
public static final java.lang.String | backslash(java.lang.String value)Ensure that a string is backslashing slashes so that it does not
confuse them with Perl substitution delimiter in Oro. Backslashes are
always backslashes in a string unless they escape the delimiter.
final StringBuffer buf = new StringBuffer(value.length());
final int len = value.length();
for (int i = 0; i < len; i++) {
char c = value.charAt(i);
if (c == '/") {
buf.append('\\");
}
buf.append(c);
}
return buf.toString();
| public void | execute()creates a new Perforce change list
sets the p4.change property to the number of the new change list
// CheckStyle:VisibilityModifier ON
if (emptyChangeList == null) {
emptyChangeList = getEmptyChangeList();
}
final Project myProj = getProject();
P4Handler handler = new P4HandlerAdapter() {
public void process(String line) {
if (util.match("/Change/", line)) {
//Remove any non-numerical chars - should leave the change number
line = util.substitute("s/[^0-9]//g", line);
int changenumber = Integer.parseInt(line);
log("Change Number is " + changenumber, Project.MSG_INFO);
myProj.setProperty("p4.change", "" + changenumber);
} else if (util.match("/error/", line)) {
throw new BuildException("Perforce Error, check client settings and/or server");
}
}
};
handler.setOutput(emptyChangeList);
execP4Command("change -i", handler);
| public java.lang.String | getEmptyChangeList()returns the text of an empty change list
final StringBuffer stringbuf = new StringBuffer();
execP4Command("change -o", new P4HandlerAdapter() {
public void process(String line) {
if (!util.match("/^#/", line)) {
if (util.match("/error/", line)) {
log("Client Error", Project.MSG_VERBOSE);
throw new BuildException("Perforce Error, "
+ "check client settings and/or server");
} else if (util.match("/<enter description here>/", line)) {
// we need to escape the description in case there are /
description = backslash(description);
line = util.substitute("s/<enter description here>/"
+ description + "/", line);
} else if (util.match("/\\/\\//", line)) {
//Match "//" for begining of depot filespec
return;
}
stringbuf.append(line);
stringbuf.append("\n");
}
}
});
return stringbuf.toString();
| public void | setDescription(java.lang.String desc)Description for ChangeList;optional.
If none is specified, it will default to "AutoSubmit By Ant"
this.description = desc;
|
|