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

(-)src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java (-2 / +36 lines)
Lines 53-63 Link Here
53
    private String m_comment;
53
    private String m_comment;
54
    private String m_revision;
54
    private String m_revision;
55
    private String m_previousRevision;
55
    private String m_previousRevision;
56
    private boolean m_remote = false;
57
	private String m_module;    
56
58
57
    private int m_status = GET_FILE;
59
    private int m_status = GET_FILE;
58
60
59
    /** rcs entries */
61
    /** rcs entries */
60
    private final Hashtable m_entries = new Hashtable();
62
    private final Hashtable m_entries = new Hashtable();
63
    
64
    /**
65
     * Default constructor for backwards compatibility
66
     *
67
     */
68
    public ChangeLogParser() {
69
    	super();
70
    }
71
    
72
    /**
73
     * Default constructor for remote-capable ChangeLogTask
74
     * 
75
     * @param remote indicates whether cvs log or cvs rlog was used
76
     */
77
    public ChangeLogParser(boolean remote, String module) {
78
    	super();
79
    	m_remote = remote;
80
    	m_module = module;
81
    }
61
82
62
    /**
83
    /**
63
     * Get a list of rcs entries as an array.
84
     * Get a list of rcs entries as an array.
Lines 135-143 Link Here
135
     * @param line the line
156
     * @param line the line
136
     */
157
     */
137
    private void processFile(final String line) {
158
    private void processFile(final String line) {
138
        if (line.startsWith("Working file:")) {
159
        if (!m_remote && line.startsWith("Working file:")) {
139
            m_file = line.substring(14, line.length());
160
            m_file = line.substring(14, line.length());
140
            m_status = GET_REVISION;
161
			m_status = GET_REVISION;
162
        }
163
        else if (m_remote && line.startsWith("RCS file:")) {
164
        	// exclude the part of the RCS filename up to and including the module name (and the path separator)        	
165
        	int startOfFilename = line.indexOf(m_module) + m_module.length() + 1;
166
        	
167
        	// exclude the ,v extension of the RCS filename
168
        	int endOfFilename = line.indexOf(",v");
169
        	
170
        	// the resulting filename has the path relative to the root of the module specified
171
        	m_file = line.substring(startOfFilename, endOfFilename);
172
173
			// update the parser status
174
			m_status = GET_REVISION;
141
        }
175
        }
142
    }
176
    }
143
177
(-)src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java (-20 / +85 lines)
Lines 28-39 Link Here
28
import java.util.Enumeration;
28
import java.util.Enumeration;
29
import java.util.Properties;
29
import java.util.Properties;
30
import java.util.Vector;
30
import java.util.Vector;
31
31
import org.apache.tools.ant.BuildException;
32
import org.apache.tools.ant.BuildException;
32
import org.apache.tools.ant.DirectoryScanner;
33
import org.apache.tools.ant.DirectoryScanner;
33
import org.apache.tools.ant.Project;
34
import org.apache.tools.ant.Project;
34
import org.apache.tools.ant.taskdefs.Execute;
35
import org.apache.tools.ant.taskdefs.AbstractCvsTask;
35
import org.apache.tools.ant.taskdefs.AbstractCvsTask;
36
import org.apache.tools.ant.types.Commandline;
37
import org.apache.tools.ant.types.FileSet;
36
import org.apache.tools.ant.types.FileSet;
38
37
39
/**
38
/**
Lines 85-90 Link Here
85
84
86
    /** The latest date at which to stop processing entries.  */
85
    /** The latest date at which to stop processing entries.  */
87
    private Date m_stop;
86
    private Date m_stop;
87
    
88
    /** The tag at which to start processing revisions */
89
    private String m_startTag;
90
    
91
	/** The tag at which to stop processing revisions */
92
    private String m_endTag;
93
    
94
    /** Determines whether log (false) or rlog (true) is used */
95
    private boolean m_remote = false;
88
96
89
    /**
97
    /**
90
     * Filesets containing list of files against which the cvs log will be
98
     * Filesets containing list of files against which the cvs log will be
Lines 152-159 Link Here
152
    public void setEnd(final Date stop) {
160
    public void setEnd(final Date stop) {
153
        m_stop = stop;
161
        m_stop = stop;
154
    }
162
    }
163
    
164
    /**
165
     * Set the tag at which the changelog should start.
166
     * 
167
     * @param startTag The tag at which the changelog should start.
168
     */
169
    public void setStartTag(final String startTag) {
170
    	m_startTag = startTag;
171
    }
172
    
173
	/**
174
	 * Set the tag at which the changelog should end.
175
	 * 
176
	 * @param endTag The tag at which the changelog should end.
177
	 */
178
    public void setEndTag(final String endTag) {
179
    	m_endTag = endTag;
180
    }
155
181
156
182
183
	public void setRemote(final boolean remote) {
184
		m_remote = remote;
185
	}
186
    
157
    /**
187
    /**
158
     * Set the number of days worth of log entries to process.
188
     * Set the number of days worth of log entries to process.
159
     *
189
     *
Lines 201-223 Link Here
201
                userList.put(user.getUserID(), user.getDisplayname());
231
                userList.put(user.getUserID(), user.getDisplayname());
202
            }
232
            }
203
233
204
234
			if (m_remote) {
205
            setCommand("log");
235
				// supply 'rlog' as argument instead of command
206
236
				setCommand("");
207
            if (getTag() != null) {
237
				addCommandArgument("rlog");
208
                CvsVersion myCvsVersion = new CvsVersion();
238
				// Do not print name/header if no revisions selected. This is quicker: less output to parse.
209
                myCvsVersion.setProject(getProject());
239
				addCommandArgument("-S");
210
                myCvsVersion.setTaskName("cvsversion");
240
				// Do not list tags. This is quicker: less output to parse.
211
                myCvsVersion.setCvsRoot(getCvsRoot());
241
				addCommandArgument("-N");
212
                myCvsVersion.setCvsRsh(getCvsRsh());
242
			} 
213
                myCvsVersion.setPassfile(getPassFile());
243
			else {
214
                myCvsVersion.setDest(m_dir);
244
				setCommand("log");
215
                myCvsVersion.execute();
245
216
                if (myCvsVersion.supportsCvsLogWithSOption()) {
246
				if (getTag() != null) {
217
                    addCommandArgument("-S");
247
					CvsVersion myCvsVersion = new CvsVersion();
218
                }
248
					myCvsVersion.setProject(getProject());
219
            }
249
					myCvsVersion.setTaskName("cvsversion");
220
            if (null != m_start) {
250
					myCvsVersion.setCvsRoot(getCvsRoot());
251
					myCvsVersion.setCvsRsh(getCvsRsh());
252
					myCvsVersion.setPassfile(getPassFile());
253
					myCvsVersion.setDest(m_dir);
254
					myCvsVersion.execute();
255
					if (myCvsVersion.supportsCvsLogWithSOption()) {
256
						addCommandArgument("-S");
257
					}
258
				}
259
			}
260
			
261
			if (null != m_startTag || null != m_endTag) {
262
				String tempStartTag = (m_startTag == null ? "" : m_startTag);
263
				String tempEndTag = (m_endTag == null ? "" : m_endTag);
264
				
265
				addCommandArgument("-r" + tempStartTag + "::" + tempEndTag);
266
			}
267
			else if (null != m_start) {
221
                final SimpleDateFormat outputDate =
268
                final SimpleDateFormat outputDate =
222
                    new SimpleDateFormat("yyyy-MM-dd");
269
                    new SimpleDateFormat("yyyy-MM-dd");
223
270
Lines 245-251 Link Here
245
                }
292
                }
246
            }
293
            }
247
294
248
            final ChangeLogParser parser = new ChangeLogParser();
295
			ChangeLogParser parser = null;
296
297
			if (m_remote) {
298
				parser = new ChangeLogParser(m_remote, getPackage());
299
			} 
300
			else {
301
				parser = new ChangeLogParser();
302
			}
303
249
            final RedirectingStreamHandler handler =
304
            final RedirectingStreamHandler handler =
250
                new RedirectingStreamHandler(parser);
305
                new RedirectingStreamHandler(parser);
251
306
Lines 299-304 Link Here
299
354
300
            throw new BuildException(message);
355
            throw new BuildException(message);
301
        }
356
        }
357
        if ((null != m_startTag || null != m_endTag) && (null != m_start || null != m_stop)) {
358
        	final String message = "Specify either a tag or date range, not both";
359
        	
360
        	throw new BuildException(message);
361
        }
362
		if ((null != m_startTag || null != m_endTag) && null == getPackage()) {
363
			final String message = "Package must be specified when selecting a tag range";
364
        	
365
			throw new BuildException(message);
366
		}
302
    }
367
    }
303
368
304
    /**
369
    /**

Return to bug 27419