use of org.apache.maven.scm.ScmBranch in project maven-scm by apache.
the class AccuRevChangeLogCommandTckTest method testUpstreamChangesIncludedInChangeLog.
@SuppressWarnings("unchecked")
@Test
public void testUpstreamChangesIncludedInChangeLog() throws Exception {
AccuRevCommandLine accurev = accurevTckTestUtil.getAccuRevCL();
// UpdatingCopy is a workspace rooted at a substream
String workingStream = accurevTckTestUtil.getWorkingStream();
String subStream = accurevTckTestUtil.getDepotName() + "_sub_stream";
accurev.mkstream(workingStream, subStream);
ScmRepository mainRepository = getScmRepository();
ScmProvider provider = getScmManager().getProviderByRepository(mainRepository);
// Create a workspace at the updating copy location backed by the substream
ScmBranch branch = new ScmBranch("sub_stream");
provider.checkOut(mainRepository, new ScmFileSet(getUpdatingCopy()), branch);
Thread.sleep(1000);
ScmFileSet fileSet = new ScmFileSet(getWorkingCopy());
// Make a timestamp that we know are after initial revision but before the second
// Current time
Date timeBeforeUpstreamCheckin = new Date();
// pause a couple seconds... [SCM-244]
Thread.sleep(2000);
// Make a change to the readme.txt and commit the change
ScmTestCase.makeFile(getWorkingCopy(), "/readme.txt", "changed readme.txt");
ScmTestCase.makeFile(getWorkingCopy(), "/src/test/java/Test.java", "changed Test.java");
CheckInScmResult checkInResult = provider.checkIn(mainRepository, fileSet, "upstream workspace promote");
assertTrue("Unable to checkin changes to the repository", checkInResult.isSuccess());
Thread.sleep(2000);
Date timeBeforeDownstreamCheckin = new Date();
Thread.sleep(2000);
ScmFileSet updateFileSet = new ScmFileSet(getUpdatingCopy());
provider.update(mainRepository, updateFileSet);
ScmTestCase.makeFile(getUpdatingCopy(), "/pom.xml", "changed pom.xml");
ScmTestCase.makeFile(getUpdatingCopy(), "/src/test/java/Test.java", "changed again Test.java");
checkInResult = provider.checkIn(mainRepository, updateFileSet, "downstream workspace promote");
assertTrue("Unable to checkin changes to the repository", checkInResult.isSuccess());
Thread.sleep(2000);
Date timeBeforeDownstreamPromote = new Date();
List<File> promotedFiles = new ArrayList<File>();
accurev.promoteStream(subStream, "stream promote", promotedFiles);
Thread.sleep(2000);
Date timeEnd = new Date();
// Changelog beforeUpstreamCheckin to end should contain both upstream and downstream changes. upstream change
// should NOT include Test.java
ChangeLogScmResult result = provider.changeLog(mainRepository, fileSet, timeBeforeUpstreamCheckin, timeEnd, 0, branch);
assertTrue("changelog beforeUpstreamCheckin to end", result.isSuccess());
List<ChangeSet> changeSets = result.getChangeLog().getChangeSets();
assertThat(changeSets.size(), is(2));
assertThat(changeSets, Matchers.<ChangeSet>hasItems(changeSet("Upstream changes", "/readme.txt"), changeSet("downstream workspace promote", "/./pom.xml", "/./src/test/java/Test.java")));
// Changelog beforeUpstreamCheckin to beforeDownstreamCheckin should include just upstream change including
// Test.java
result = provider.changeLog(mainRepository, fileSet, timeBeforeUpstreamCheckin, timeBeforeDownstreamCheckin, 0, branch);
assertTrue("changelog beforeUpstreamCheckin to beforeDownstreamCheckin", result.isSuccess());
changeSets = result.getChangeLog().getChangeSets();
assertThat(changeSets.size(), is(1));
assertThat(changeSets.get(0), changeSet("Upstream changes", "/readme.txt", "/src/test/java/Test.java"));
// Changelog beforeDownstreamCheckin to end should include just downstream change
result = provider.changeLog(mainRepository, fileSet, timeBeforeDownstreamCheckin, timeEnd, 0, branch);
assertTrue("changelog beforeDownstreamCheckin to end", result.isSuccess());
changeSets = result.getChangeLog().getChangeSets();
assertThat(changeSets.size(), is(1));
assertThat(changeSets.get(0), changeSet("downstream workspace promote", "/./pom.xml", "/./src/test/java/Test.java"));
// Changelog beforeDownstreamPromote to end should be empty
result = provider.changeLog(mainRepository, fileSet, timeBeforeDownstreamPromote, timeEnd, 0, branch);
assertTrue("changelog beforeDownstreamPromote to end", result.isSuccess());
changeSets = result.getChangeLog().getChangeSets();
assertThat(changeSets.size(), is(0));
}
use of org.apache.maven.scm.ScmBranch in project maven-scm by apache.
the class ChangeLogCommandTckTest method testChangeLogCommand.
public void testChangeLogCommand() throws Exception {
Thread.sleep(1000);
ScmProvider provider = getScmManager().getProviderByRepository(getScmRepository());
ScmFileSet fileSet = new ScmFileSet(getWorkingCopy());
ChangeLogScmResult firstResult = provider.changeLog(getScmRepository(), fileSet, null, null, 0, (ScmBranch) null, null);
assertTrue(firstResult.getProviderMessage() + ": " + firstResult.getCommandLine() + "\n" + firstResult.getCommandOutput(), firstResult.isSuccess());
// for svn, cvs, git, the repo get recreated for each test and therefore initial changelog size is 1
// for SCM like perforce, it is not possible to recreate the repo, therefor the size will be greater then 1
int firstLogSize = firstResult.getChangeLog().getChangeSets().size();
assertTrue("Unexpected initial log size", firstLogSize >= 1);
// Make a timestamp that we know are after initial revision but before the second
// Current time
Date timeBeforeSecond = new Date();
// pause a couple seconds... [SCM-244]
Thread.sleep(2000);
// Make a change to the readme.txt and commit the change
this.edit(getWorkingCopy(), "readme.txt", null, getScmRepository());
ScmTestCase.makeFile(getWorkingCopy(), "/readme.txt", "changed readme.txt");
CheckInScmResult checkInResult = provider.checkIn(getScmRepository(), fileSet, COMMIT_MSG);
assertTrue("Unable to checkin changes to the repository", checkInResult.isSuccess());
ChangeLogScmResult secondResult = provider.changeLog(getScmRepository(), fileSet, (ScmVersion) null, null);
assertTrue(secondResult.getProviderMessage(), secondResult.isSuccess());
assertEquals(firstLogSize + 1, secondResult.getChangeLog().getChangeSets().size());
// Now only retrieve the changelog after timeBeforeSecondChangeLog
Date currentTime = new Date();
ChangeLogScmResult thirdResult = provider.changeLog(getScmRepository(), fileSet, timeBeforeSecond, currentTime, 0, new ScmBranch(""));
// Thorough assert of the last result
assertTrue(thirdResult.getProviderMessage(), thirdResult.isSuccess());
assertEquals(1, thirdResult.getChangeLog().getChangeSets().size());
ChangeSet changeset = thirdResult.getChangeLog().getChangeSets().get(0);
assertTrue(changeset.getDate().after(timeBeforeSecond));
assertEquals(COMMIT_MSG, changeset.getComment());
}
use of org.apache.maven.scm.ScmBranch in project maven-scm by apache.
the class SvnTagBranchUtilsTest method testResolveBranchUrl.
private void testResolveBranchUrl(String scmUrl, String branchBase, String branch, String expected) throws Exception {
SvnScmProviderRepository repository = getSvnRepository(scmUrl);
if (branchBase != null) {
repository.setBranchBase(branchBase);
}
if (branchBase != null) {
assertEquals(repository.getBranchBase(), branchBase);
} else {
assertEquals(repository.getBranchBase(), SvnTagBranchUtils.resolveBranchBase(repository.getUrl()));
}
assertEquals(expected, SvnTagBranchUtils.resolveBranchUrl(repository, new ScmBranch(branch)));
}
use of org.apache.maven.scm.ScmBranch in project maven-scm by apache.
the class SvnExeExportCommand method executeExportCommand.
/**
* {@inheritDoc}
*/
protected ExportScmResult executeExportCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, String outputDirectory) throws ScmException {
if (outputDirectory == null) {
outputDirectory = fileSet.getBasedir().getAbsolutePath();
}
SvnScmProviderRepository repository = (SvnScmProviderRepository) repo;
String url = repository.getUrl();
if (version != null && StringUtils.isNotEmpty(version.getName())) {
if (version instanceof ScmTag) {
url = SvnTagBranchUtils.resolveTagUrl(repository, (ScmTag) version);
} else if (version instanceof ScmBranch) {
url = SvnTagBranchUtils.resolveBranchUrl(repository, (ScmBranch) version);
}
}
url = SvnCommandUtils.fixUrl(url, repository.getUser());
Commandline cl = createCommandLine((SvnScmProviderRepository) repo, fileSet.getBasedir(), version, url, outputDirectory);
SvnUpdateConsumer consumer = new SvnUpdateConsumer(getLogger(), fileSet.getBasedir());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
if (cl.getWorkingDirectory() != null && Os.isFamily(Os.FAMILY_WINDOWS)) {
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
}
int exitCode;
try {
exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
if (exitCode != 0) {
return new ExportScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
}
return new ExportScmResultWithRevision(cl.toString(), consumer.getUpdatedFiles(), String.valueOf(consumer.getRevision()));
}
use of org.apache.maven.scm.ScmBranch in project maven-scm by apache.
the class SvnChangeLogCommandTest method testCommandLineWithBranchStartDateOnly.
public void testCommandLineWithBranchStartDateOnly() throws Exception {
Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE);
testCommandLine("scm:svn:http://foo.com/svn/trunk", new ScmBranch("my-test-branch"), startDate, null, "svn --non-interactive log -v -r \"{2003-09-10 01:01:01 +0000}:HEAD\" http://foo.com/svn/branches/my-test-branch http://foo.com/svn/trunk");
}
Aggregations