1 | /** | | 1 | /** |
2 | * Execute task. | | 2 | * Execute task |
3 | * | | 3 | * |
4 | * @exception BuildException if an error occurs | | 4 | * @exception BuildException if something goes wrong executing the |
5 | */ | | 5 | * cvs command |
6 | public void execute() throws BuildException { | | 6 | */ |
7 | // validate the input parameters | | 7 | public void execute() throws BuildException { |
8 | validate(); | | 8 | File savedDir = inputDir; // may be altered in validate |
9 | | | 9 | |
10 | // build the rdiff command | | 10 | try { |
11 | addCommandArgument("rdiff"); | | 11 | |
12 | addCommandArgument("-s"); | | 12 | validate(); |
13 | if (mystartTag != null) { | | 13 | final Properties userList = new Properties(); |
14 | addCommandArgument("-r"); | | 14 | |
15 | addCommandArgument(mystartTag); | | 15 | loadUserlist(userList); |
16 | } else { | | 16 | |
17 | addCommandArgument("-D"); | | 17 | for (int i = 0, size = cvsUsers.size(); i < size; i++) { |
18 | addCommandArgument(mystartDate); | | 18 | final CvsUser user = (CvsUser) cvsUsers.get(i); |
19 | } | | 19 | user.validate(); |
20 | if (myendTag != null) { | | 20 | userList.put(user.getUserID(), user.getDisplayname()); |
21 | addCommandArgument("-r"); | | 21 | } |
22 | addCommandArgument(myendTag); | | 22 | |
23 | } else { | | 23 | setCommand("log"); |
24 | addCommandArgument("-D"); | | 24 | |
25 | addCommandArgument(myendDate); | | 25 | if (getTag() != null) { |
26 | } | | 26 | CvsVersion myCvsVersion = new CvsVersion(); |
27 | // support multiple packages | | 27 | myCvsVersion.setProject(getProject()); |
28 | StringTokenizer myTokenizer = new StringTokenizer(mypackage); | | 28 | myCvsVersion.setTaskName("cvsversion"); |
29 | while (myTokenizer.hasMoreTokens()) { | | 29 | myCvsVersion.setCvsRoot(getCvsRoot()); |
30 | addCommandArgument(myTokenizer.nextToken()); | | 30 | myCvsVersion.setCvsRsh(getCvsRsh()); |
31 | } | | 31 | myCvsVersion.setPassfile(getPassFile()); |
32 | // force command not to be null | | 32 | myCvsVersion.setDest(inputDir); |
33 | setCommand(""); | | 33 | myCvsVersion.execute(); |
34 | File tmpFile = null; | | 34 | if (myCvsVersion.supportsCvsLogWithSOption()) { |
35 | try { | | 35 | addCommandArgument("-S"); |
36 | tmpFile = FILE_UTILS.createTempFile("cvstagdiff", ".log", null); | | 36 | } |
37 | tmpFile.deleteOnExit(); | | 37 | } |
38 | setOutput(tmpFile); | | 38 | if (null != startDate) { |
39 | | | 39 | final SimpleDateFormat outputDate = |
40 | // run the cvs command | | 40 | new SimpleDateFormat("yyyy-MM-dd"); |
41 | super.execute(); | | 41 | |
42 | | | 42 | // We want something of the form: -d ">=YYYY-MM-dd" |
43 | // parse the rdiff | | 43 | final String dateRange = ">=" + outputDate.format(startDate); |
44 | CvsTagEntry[] entries = parseRDiff(tmpFile); | | 44 | |
45 | | | 45 | // Supply '-d' as a separate argument - Bug# 14397 |
46 | // write the tag diff | | 46 | addCommandArgument("-d"); |
47 | writeTagDiff(entries); | | 47 | addCommandArgument(dateRange); |
48 | | | 48 | } |
49 | } finally { | | 49 | |
50 | if (tmpFile != null) { | | 50 | // Check if list of files to check has been specified |
51 | tmpFile.delete(); | | 51 | if (!filesets.isEmpty()) { |
52 | } | | 52 | final Enumeration e = filesets.elements(); |
53 | } | | 53 | |
54 | } | | 54 | while (e.hasMoreElements()) { |
| | | 55 | final FileSet fileSet = (FileSet) e.nextElement(); |
| | | 56 | final DirectoryScanner scanner = |
| | | 57 | fileSet.getDirectoryScanner(getProject()); |
| | | 58 | final String[] files = scanner.getIncludedFiles(); |
| | | 59 | |
| | | 60 | for (int i = 0; i < files.length; i++) { |
| | | 61 | addCommandArgument(files[i]); |
| | | 62 | } |
| | | 63 | } |
| | | 64 | } |
| | | 65 | |
| | | 66 | final ChangeLogParser parser = new ChangeLogParser(); |
| | | 67 | final RedirectingStreamHandler handler = |
| | | 68 | new RedirectingStreamHandler(parser); |
| | | 69 | |
| | | 70 | log(getCommand(), Project.MSG_VERBOSE); |
| | | 71 | |
| | | 72 | setDest(inputDir); |
| | | 73 | setExecuteStreamHandler(handler); |
| | | 74 | try { |
| | | 75 | super.execute(); |
| | | 76 | } finally { |
| | | 77 | final String errors = handler.getErrors(); |
| | | 78 | |
| | | 79 | if (null != errors) { |
| | | 80 | log(errors, Project.MSG_ERR); |
| | | 81 | } |
| | | 82 | } |
| | | 83 | final CVSEntry[] entrySet = parser.getEntrySetAsArray(); |
| | | 84 | final CVSEntry[] filteredEntrySet = filterEntrySet(entrySet); |
| | | 85 | |
| | | 86 | replaceAuthorIdWithName(userList, filteredEntrySet); |
| | | 87 | |
| | | 88 | writeChangeLog(filteredEntrySet); |
| | | 89 | |
| | | 90 | } finally { |
| | | 91 | inputDir = savedDir; |
| | | 92 | } |
| | | 93 | } |