View | Details | Raw Unified | Return to bug 36357
Collapse All | Expand All

(-)perforce-1.6.5/P4Change.java (-14 / +52 lines)
Lines 39-46 Link Here
39
 */
39
 */
40
public class P4Change extends P4Base {
40
public class P4Change extends P4Base {
41
41
42
    protected String specifiedChangeList = null;
42
    protected String emptyChangeList = null;
43
    protected String emptyChangeList = null;
43
    protected String description = "AutoSubmit By Ant";
44
    protected String description = "AutoSubmit By Ant";
45
    protected boolean delete = false;
44
46
45
    /**
47
    /**
46
     * creates a new Perforce change list
48
     * creates a new Perforce change list
Lines 54-80 Link Here
54
        }
56
        }
55
        final Project myProj = getProject();
57
        final Project myProj = getProject();
56
58
57
        P4Handler handler = new P4HandlerAdapter() {
59
        if(specifiedChangeList==null) {
58
            public void process(String line) {
60
            P4Handler handler = new P4HandlerAdapter() {
59
                if (util.match("/Change/", line)) {
61
                public void process(String line) {
60
62
                    if (util.match("/Change/", line)) {
61
                    //Remove any non-numerical chars - should leave the change number
63
62
                    line = util.substitute("s/[^0-9]//g", line);
64
                        //Remove any non-numerical chars - should leave the change number
65
                        line = util.substitute("s/[^0-9]//g", line);
66
67
                        int changenumber = Integer.parseInt(line);
68
                        log("Change Number is " + changenumber, Project.MSG_INFO);
69
                        myProj.setProperty("p4.change", "" + changenumber);
63
70
64
                    int changenumber = Integer.parseInt(line);
71
                    } else if (util.match("/error/", line)) {
65
                    log("Change Number is " + changenumber, Project.MSG_INFO);
72
                        throw new BuildException("Perforce Error, check client settings and/or server");
66
                    myProj.setProperty("p4.change", "" + changenumber);
73
                    }
67
74
68
                } else if (util.match("/error/", line)) {
69
                    throw new BuildException("Perforce Error, check client settings and/or server");
70
                }
75
                }
76
            };
77
78
            handler.setOutput(emptyChangeList);
71
79
80
            execP4Command("change -i", handler);        	
81
        }
82
        else
83
        {
84
            String p4cmd = "-s change";
85
            
86
            if (delete) {
87
                p4cmd += " -d";
72
            }
88
            }
73
        };
74
89
75
        handler.setOutput(emptyChangeList);
90
            p4cmd += " " + specifiedChangeList;
76
91
77
        execP4Command("change -i", handler);
92
            execP4Command(p4cmd, new SimpleP4OutputHandler(this));
93
        }
78
    }
94
    }
79
95
80
    /**
96
    /**
Lines 141-144 Link Here
141
        this.description = desc;
157
        this.description = desc;
142
    }
158
    }
143
159
160
    /**
161
     * A changelist to work on; optional.
162
     * @param revertChange : the change list to work on
163
     * @throws BuildException if the change list is null or empty string
164
     */
165
    public void setChange(String changeList) throws BuildException {
166
        if (changeList == null && !changeList.equals("")) {
167
            throw new BuildException("P4Change: change cannot be null or empty");
168
        }
169
170
        this.specifiedChangeList = changeList;
171
172
    }
173
    
174
    /**
175
     * Delete the specified changelist;optional.
176
     * If none is specified, it will default to "false"
177
     * @param delete <code>true</code> if the changelist should be deleted, <code>false</code> otherwise.
178
     */
179
    public void setDelete(boolean delete) {
180
    	this.delete=delete;
181
    }
144
} //EoF
182
} //EoF

Return to bug 36357