diff -Naur perforce-1.6.5/P4Change.java perforce-new/P4Change.java
--- perforce-1.6.5/P4Change.java 2005-06-02 15:20:04.000000000 +0200
+++ perforce-new/P4Change.java 2005-08-25 14:05:53.453125000 +0200
@@ -39,8 +39,10 @@
*/
public class P4Change extends P4Base {
+ protected String specifiedChangeList = null;
protected String emptyChangeList = null;
protected String description = "AutoSubmit By Ant";
+ protected boolean delete = false;
/**
* creates a new Perforce change list
@@ -54,27 +56,41 @@
}
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);
+ if(specifiedChangeList==null) {
+ 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);
- 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");
+ }
- } else if (util.match("/error/", line)) {
- throw new BuildException("Perforce Error, check client settings and/or server");
}
+ };
+
+ handler.setOutput(emptyChangeList);
+ execP4Command("change -i", handler);
+ }
+ else
+ {
+ String p4cmd = "-s change";
+
+ if (delete) {
+ p4cmd += " -d";
}
- };
- handler.setOutput(emptyChangeList);
+ p4cmd += " " + specifiedChangeList;
- execP4Command("change -i", handler);
+ execP4Command(p4cmd, new SimpleP4OutputHandler(this));
+ }
}
/**
@@ -141,4 +157,26 @@
this.description = desc;
}
+ /**
+ * A changelist to work on; optional.
+ * @param revertChange : the change list to work on
+ * @throws BuildException if the change list is null or empty string
+ */
+ public void setChange(String changeList) throws BuildException {
+ if (changeList == null && !changeList.equals("")) {
+ throw new BuildException("P4Change: change cannot be null or empty");
+ }
+
+ this.specifiedChangeList = changeList;
+
+ }
+
+ /**
+ * Delete the specified changelist;optional.
+ * If none is specified, it will default to "false"
+ * @param delete true
if the changelist should be deleted, false
otherwise.
+ */
+ public void setDelete(boolean delete) {
+ this.delete=delete;
+ }
} //EoF