Skip to content

Commit

Permalink
[FIX JENKINS-13227] Remove filters on CVS rlog and parse updated output
Browse files Browse the repository at this point in the history
  • Loading branch information
mc1arke committed May 9, 2012
1 parent e3b432e commit 8c0237c
Show file tree
Hide file tree
Showing 4 changed files with 18,667 additions and 15 deletions.
7 changes: 0 additions & 7 deletions src/main/java/hudson/scm/CVSSCM.java
Expand Up @@ -499,13 +499,6 @@ private String getRemoteLogForModule(final CvsRepository repository, final CvsRe
final String endDate = DATE_FORMATTER.format(endTime);

rlogCommand.setDateFilter(lastBuildDate + "<" + endDate);
rlogCommand.setSuppressHeader(true);
}

// set branch or tag name if selected
CvsRepositoryLocationType locationType = item.getLocation().getLocationType();
if (locationType.equals(CvsRepositoryLocationType.BRANCH) || locationType.equals(CvsRepositoryLocationType.TAG)) {
rlogCommand.setRevisionFilter(envVars.expand(module.getModuleLocation().getLocationName()));
}

// tell CVS which module we're logging
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/hudson/scm/CvsChangeLogHelper.java
Expand Up @@ -44,9 +44,9 @@ public final class CvsChangeLogHelper {
private static CvsChangeLogHelper instance;
private static final String MAIN_REGEX = "[\\r|\\n]+RCS file:\\s(.+?),[a-z]+[\\r|\\n]+head:\\s+(.*?)"
+ "[\\r|\\n]+branch:(.*?)[\\r|\\n]+locks:.*?[\\r|\\n]+access list:.*?[\\r|\\n]+symbolic names:(.*?)"
+ "[\\r|\\n]+keyword substitution:.*?[\\r|\\n]+total revisions:.+?;\\s+selected revisions:.+?[\\r|\\n]+"
+ "description:.*?(([\\r|\\n]+----------------------------[\\r|\\n]+revision\\s+.+?[\\r|\\n]+"
+ "date:\\s+.+?\\;\\s+author:\\s+.+?;.*?[\\r|\\n]+.*?)+)[\\r|\\n]+=============================================================================";
+ "[\\r|\\n]+keyword substitution:.*?[\\r|\\n]+total revisions:.+?;\\s+selected revisions:\\s+[1-9]+[0-9]*\\s*[\\r|\\n]+"
+ "description:.*?(([\\r|\\n]+----------------------------[\\r|\\n]+revision\\s+.+?[\\r|\\n]"
+ "date:\\s+.+?\\;\\s+author:\\s+.+?;.*?[\\r|\\n]+.*?)+)[\\r|\\n]+";
private static final String SECONDARY_REGEX = "\\s+(.+?)[\\r|\\n]+date:\\s+(.+?)\\;\\s+author:\\s+(.+?);\\s+state:\\s+(.+?);.*?[\\r|\\n]+(.*)";

private static final DateFormat[] DATE_FORMATTER = new SimpleDateFormat[] {
Expand Down Expand Up @@ -127,9 +127,13 @@ public CvsChangeSet mapCvsLog(final String logContents,final CvsRepository repos
final List<CvsFile> files = new ArrayList<CvsFile>();

final Pattern mainPattern = Pattern.compile(MAIN_REGEX, Pattern.DOTALL | Pattern.MULTILINE);
final Matcher mainMatcher = mainPattern.matcher(logContents);
final Pattern innerPattern = Pattern.compile(SECONDARY_REGEX, Pattern.MULTILINE | Pattern.DOTALL);
while (mainMatcher.find()) {
for (String section : logContents.split("=============================================================================")) {
final Matcher mainMatcher = mainPattern.matcher(section);

if (!mainMatcher.find()) {
continue;
}

/*
* this is a bit of a hack - we get the root of the module in the
Expand Down
25 changes: 22 additions & 3 deletions src/test/java/hudson/scm/CvsChangeLogHelperTest.java
@@ -1,15 +1,21 @@
package hudson.scm;

import hudson.EnvVars;
import org.junit.Test;
import org.jvnet.hudson.test.HudsonTestCase;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;

import org.jvnet.hudson.test.HudsonTestCase;
import sun.reflect.generics.tree.ArrayTypeSignature;

public class CvsChangeLogHelperTest extends HudsonTestCase {

@Test
public void testMapCvsLog() {
String logContents = "cvs rlog: Logging doc\n"
+ "\n"
Expand Down Expand Up @@ -39,4 +45,17 @@ public void testMapCvsLog() {
.getChanges().get(0).getMsg());
}

@Test
public void testMapNonFilteredCvsLog() throws IOException, URISyntaxException {
File changeLogFile = new File(CvsChangeLogHelperTest.class.getResource("cvsRlogOutput_ISSUE-13227.txt").toURI());
int len = (int)changeLogFile.length();
InputStream in = new FileInputStream(changeLogFile); byte[] b = new byte[len]; int total = 0; while (total < len) { int result = in.read(b, total, len - total); if (result == -1) { break; } total += result; }
String logContents = new String(b, Charset.forName("UTF-8"));

CvsModule module = new CvsModule("portalInt", null);
CvsRepositoryItem item = new CvsRepositoryItem(new CvsRepositoryLocation.BranchRepositoryLocation(/*"d-chg00017366_op_brc_prod-op-2012-04-19"*/ "d-chg00017366_op_impl_2012-05-02_v20", false), new CvsModule[]{module});
CvsRepository repository = new CvsRepository(":pserver:user:password@host:port:/usr/local/cvs/repcvs/", false, null, Arrays.asList(new CvsRepositoryItem[]{item}), new ArrayList<ExcludedRegion>(), -1);
assertEquals(4, CvsChangeLogHelper.getInstance().mapCvsLog(logContents, repository, item, module, new EnvVars()).getChanges().size());
}

}

0 comments on commit 8c0237c

Please sign in to comment.