Refactor RepositoryTestCase to use LocalDiskRepository instead
Change-Id: I07014d1b8cc2fab0761d644a12e4ae04f0adf3ef Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
49aac32500
commit
1e84e8ad93
|
@ -10,6 +10,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||||
Import-Package: com.jcraft.jsch,
|
Import-Package: com.jcraft.jsch,
|
||||||
junit.framework,
|
junit.framework,
|
||||||
junit.textui,
|
junit.textui,
|
||||||
|
org.eclipse.jgit.junit,
|
||||||
org.eclipse.jgit.diff,
|
org.eclipse.jgit.diff,
|
||||||
org.eclipse.jgit.dircache,
|
org.eclipse.jgit.dircache,
|
||||||
org.eclipse.jgit.errors,
|
org.eclipse.jgit.errors,
|
||||||
|
|
|
@ -67,6 +67,11 @@
|
||||||
<groupId>org.eclipse.jgit</groupId>
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
<artifactId>org.eclipse.jgit</artifactId>
|
<artifactId>org.eclipse.jgit</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
|
<artifactId>org.eclipse.jgit.junit</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -72,7 +72,7 @@ public void testObjectInNewPack() throws IncorrectObjectTypeException,
|
||||||
IOException {
|
IOException {
|
||||||
// Create a new object in a new pack, and test that it is present.
|
// Create a new object in a new pack, and test that it is present.
|
||||||
//
|
//
|
||||||
final Repository eden = createNewEmptyRepo();
|
final Repository eden = createBareRepository();
|
||||||
final RevObject o1 = writeBlob(eden, "o1");
|
final RevObject o1 = writeBlob(eden, "o1");
|
||||||
pack(eden, o1);
|
pack(eden, o1);
|
||||||
assertEquals(o1.name(), parse(o1).name());
|
assertEquals(o1.name(), parse(o1).name());
|
||||||
|
@ -84,7 +84,7 @@ public void testObjectMovedToNewPack1()
|
||||||
// object into a different pack file, with some other object. We
|
// object into a different pack file, with some other object. We
|
||||||
// still should be able to access the objects.
|
// still should be able to access the objects.
|
||||||
//
|
//
|
||||||
final Repository eden = createNewEmptyRepo();
|
final Repository eden = createBareRepository();
|
||||||
final RevObject o1 = writeBlob(eden, "o1");
|
final RevObject o1 = writeBlob(eden, "o1");
|
||||||
final File[] out1 = pack(eden, o1);
|
final File[] out1 = pack(eden, o1);
|
||||||
assertEquals(o1.name(), parse(o1).name());
|
assertEquals(o1.name(), parse(o1).name());
|
||||||
|
@ -108,7 +108,7 @@ public void testObjectMovedWithinPack()
|
||||||
throws IncorrectObjectTypeException, IOException {
|
throws IncorrectObjectTypeException, IOException {
|
||||||
// Create an object and pack it.
|
// Create an object and pack it.
|
||||||
//
|
//
|
||||||
final Repository eden = createNewEmptyRepo();
|
final Repository eden = createBareRepository();
|
||||||
final RevObject o1 = writeBlob(eden, "o1");
|
final RevObject o1 = writeBlob(eden, "o1");
|
||||||
final File[] out1 = pack(eden, o1);
|
final File[] out1 = pack(eden, o1);
|
||||||
assertEquals(o1.name(), parse(o1).name());
|
assertEquals(o1.name(), parse(o1).name());
|
||||||
|
@ -141,7 +141,7 @@ public void testObjectMovedToNewPack2()
|
||||||
// object into a different pack file, with some other object. We
|
// object into a different pack file, with some other object. We
|
||||||
// still should be able to access the objects.
|
// still should be able to access the objects.
|
||||||
//
|
//
|
||||||
final Repository eden = createNewEmptyRepo();
|
final Repository eden = createBareRepository();
|
||||||
final RevObject o1 = writeBlob(eden, "o1");
|
final RevObject o1 = writeBlob(eden, "o1");
|
||||||
final File[] out1 = pack(eden, o1);
|
final File[] out1 = pack(eden, o1);
|
||||||
assertEquals(o1.name(), parse(o1).name());
|
assertEquals(o1.name(), parse(o1).name());
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2009, Google Inc.
|
|
||||||
* Copyright (C) 2009, Robin Rosenberg <robin.rosenberg@dewire.com>
|
|
||||||
* Copyright (C) 2009, Yann Simon <yann.simon.fr@gmail.com>
|
|
||||||
* and other copyright owners as documented in the project's IP log.
|
|
||||||
*
|
|
||||||
* This program and the accompanying materials are made available
|
|
||||||
* under the terms of the Eclipse Distribution License v1.0 which
|
|
||||||
* accompanies this distribution, is reproduced below, and is
|
|
||||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or
|
|
||||||
* without modification, are permitted provided that the following
|
|
||||||
* conditions are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above
|
|
||||||
* copyright notice, this list of conditions and the following
|
|
||||||
* disclaimer in the documentation and/or other materials provided
|
|
||||||
* with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
|
||||||
* names of its contributors may be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.eclipse.jgit.lib;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.util.SystemReader;
|
|
||||||
|
|
||||||
class MockSystemReader extends SystemReader {
|
|
||||||
final Map<String, String> values = new HashMap<String, String>();
|
|
||||||
|
|
||||||
FileBasedConfig userGitConfig;
|
|
||||||
|
|
||||||
MockSystemReader() {
|
|
||||||
init(Constants.OS_USER_NAME_KEY);
|
|
||||||
init(Constants.GIT_AUTHOR_NAME_KEY);
|
|
||||||
init(Constants.GIT_AUTHOR_EMAIL_KEY);
|
|
||||||
init(Constants.GIT_COMMITTER_NAME_KEY);
|
|
||||||
init(Constants.GIT_COMMITTER_EMAIL_KEY);
|
|
||||||
userGitConfig = new FileBasedConfig(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(final String n) {
|
|
||||||
values.put(n, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getenv(String variable) {
|
|
||||||
return values.get(variable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProperty(String key) {
|
|
||||||
return values.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileBasedConfig openUserConfig() {
|
|
||||||
return userGitConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHostname() {
|
|
||||||
return "fake.host.example.com";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getCurrentTime() {
|
|
||||||
return 1250379778668L; // Sat Aug 15 20:12:58 GMT-03:30 2009
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTimezone(long when) {
|
|
||||||
return TimeZone.getTimeZone("GMT-3:30").getOffset(when);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2009, Christian Halstrick <christian.halstrick@sap.com>
|
* Copyright (C) 2009, Christian Halstrick <christian.halstrick@sap.com>
|
||||||
* Copyright (C) 2009, Christian Halstrick, Matthias Sohn, SAP AG
|
* Copyright (C) 2009, Christian Halstrick, Matthias Sohn, SAP AG
|
||||||
|
* Copyright (C) 2009, Google Inc.
|
||||||
* and other copyright owners as documented in the project's IP log.
|
* and other copyright owners as documented in the project's IP log.
|
||||||
*
|
*
|
||||||
* This program and the accompanying materials are made available
|
* This program and the accompanying materials are made available
|
||||||
|
@ -61,8 +62,8 @@ public void testlogAllRefUpdates() throws Exception {
|
||||||
// written
|
// written
|
||||||
final Tree t = new Tree(db);
|
final Tree t = new Tree(db);
|
||||||
addFileToTree(t, "i-am-a-file", "and this is the data in me\n");
|
addFileToTree(t, "i-am-a-file", "and this is the data in me\n");
|
||||||
commit(t, "A Commit\n", new PersonIdent(jauthor, commitTime, tz),
|
commit(t, "A Commit\n", new PersonIdent(author, commitTime, tz),
|
||||||
new PersonIdent(jcommitter, commitTime, tz));
|
new PersonIdent(committer, commitTime, tz));
|
||||||
commitTime += 100;
|
commitTime += 100;
|
||||||
assertTrue(
|
assertTrue(
|
||||||
"Reflog for HEAD still contain no entry",
|
"Reflog for HEAD still contain no entry",
|
||||||
|
@ -74,8 +75,8 @@ public void testlogAllRefUpdates() throws Exception {
|
||||||
|
|
||||||
// do one commit and check that reflog size is increased to 1
|
// do one commit and check that reflog size is increased to 1
|
||||||
addFileToTree(t, "i-am-another-file", "and this is other data in me\n");
|
addFileToTree(t, "i-am-another-file", "and this is other data in me\n");
|
||||||
commit(t, "A Commit\n", new PersonIdent(jauthor, commitTime, tz),
|
commit(t, "A Commit\n", new PersonIdent(author, commitTime, tz),
|
||||||
new PersonIdent(jcommitter, commitTime, tz));
|
new PersonIdent(committer, commitTime, tz));
|
||||||
commitTime += 100;
|
commitTime += 100;
|
||||||
assertTrue(
|
assertTrue(
|
||||||
"Reflog for HEAD should contain one entry",
|
"Reflog for HEAD should contain one entry",
|
||||||
|
@ -88,8 +89,8 @@ public void testlogAllRefUpdates() throws Exception {
|
||||||
// do one commit and check that reflog size is 2
|
// do one commit and check that reflog size is 2
|
||||||
addFileToTree(t, "i-am-anotheranother-file",
|
addFileToTree(t, "i-am-anotheranother-file",
|
||||||
"and this is other other data in me\n");
|
"and this is other other data in me\n");
|
||||||
commit(t, "A Commit\n", new PersonIdent(jauthor, commitTime, tz),
|
commit(t, "A Commit\n", new PersonIdent(author, commitTime, tz),
|
||||||
new PersonIdent(jcommitter, commitTime, tz));
|
new PersonIdent(committer, commitTime, tz));
|
||||||
assertTrue(
|
assertTrue(
|
||||||
"Reflog for HEAD should contain two entries",
|
"Reflog for HEAD should contain two entries",
|
||||||
db.getReflogReader(Constants.HEAD).getReverseEntries().size() == 2);
|
db.getReflogReader(Constants.HEAD).getReverseEntries().size() == 2);
|
||||||
|
|
|
@ -64,7 +64,7 @@ public void testNonBareFileKey() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBareFileKey() throws IOException {
|
public void testBareFileKey() throws IOException {
|
||||||
Repository bare = createNewEmptyRepo(true);
|
Repository bare = createBareRepository();
|
||||||
File gitdir = bare.getDirectory();
|
File gitdir = bare.getDirectory();
|
||||||
File parent = gitdir.getParentFile();
|
File parent = gitdir.getParentFile();
|
||||||
String name = gitdir.getName();
|
String name = gitdir.getName();
|
||||||
|
@ -92,7 +92,7 @@ public void testFileKeyOpenExisting() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFileKeyOpenNew() throws IOException {
|
public void testFileKeyOpenNew() throws IOException {
|
||||||
final Repository n = createNewEmptyRepo(true);
|
final Repository n = createBareRepository();
|
||||||
final File gitdir = n.getDirectory();
|
final File gitdir = n.getDirectory();
|
||||||
n.close();
|
n.close();
|
||||||
recursiveDelete(gitdir);
|
recursiveDelete(gitdir);
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||||
|
import org.eclipse.jgit.junit.MockSystemReader;
|
||||||
import org.eclipse.jgit.util.SystemReader;
|
import org.eclipse.jgit.util.SystemReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,9 +116,9 @@ public void test007_readUserConfig() {
|
||||||
final MockSystemReader mockSystemReader = new MockSystemReader();
|
final MockSystemReader mockSystemReader = new MockSystemReader();
|
||||||
SystemReader.setInstance(mockSystemReader);
|
SystemReader.setInstance(mockSystemReader);
|
||||||
final String hostname = mockSystemReader.getHostname();
|
final String hostname = mockSystemReader.getHostname();
|
||||||
final Config userGitConfig = mockSystemReader.userGitConfig;
|
final Config userGitConfig = mockSystemReader.openUserConfig();
|
||||||
final Config localConfig = new Config(userGitConfig);
|
final Config localConfig = new Config(userGitConfig);
|
||||||
mockSystemReader.values.clear();
|
mockSystemReader.clearProperties();
|
||||||
|
|
||||||
String authorName;
|
String authorName;
|
||||||
String authorEmail;
|
String authorEmail;
|
||||||
|
@ -129,7 +130,7 @@ public void test007_readUserConfig() {
|
||||||
assertEquals(Constants.UNKNOWN_USER_DEFAULT + "@" + hostname, authorEmail);
|
assertEquals(Constants.UNKNOWN_USER_DEFAULT + "@" + hostname, authorEmail);
|
||||||
|
|
||||||
// the system user name is defined
|
// the system user name is defined
|
||||||
mockSystemReader.values.put(Constants.OS_USER_NAME_KEY, "os user name");
|
mockSystemReader.setProperty(Constants.OS_USER_NAME_KEY, "os user name");
|
||||||
localConfig.uncache(UserConfig.KEY);
|
localConfig.uncache(UserConfig.KEY);
|
||||||
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
|
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
|
||||||
assertEquals("os user name", authorName);
|
assertEquals("os user name", authorName);
|
||||||
|
@ -140,8 +141,8 @@ public void test007_readUserConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// the git environment variables are defined
|
// the git environment variables are defined
|
||||||
mockSystemReader.values.put(Constants.GIT_AUTHOR_NAME_KEY, "git author name");
|
mockSystemReader.setProperty(Constants.GIT_AUTHOR_NAME_KEY, "git author name");
|
||||||
mockSystemReader.values.put(Constants.GIT_AUTHOR_EMAIL_KEY, "author@email");
|
mockSystemReader.setProperty(Constants.GIT_AUTHOR_EMAIL_KEY, "author@email");
|
||||||
localConfig.uncache(UserConfig.KEY);
|
localConfig.uncache(UserConfig.KEY);
|
||||||
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
|
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
|
||||||
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
|
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
/*
|
/*
|
||||||
|
* Copyright (C) 2009, Google Inc.
|
||||||
|
* Copyright (C) 2008-2009, Jonas Fonseca <fonseca@diku.dk>
|
||||||
* Copyright (C) 2007-2009, Robin Rosenberg <robin.rosenberg@dewire.com>
|
* Copyright (C) 2007-2009, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||||
* Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
|
* Copyright (C) 2006-2007, Shawn O. Pearce <spearce@spearce.org>
|
||||||
|
* Copyright (C) 2009, Yann Simon <yann.simon.fr@gmail.com>
|
||||||
* and other copyright owners as documented in the project's IP log.
|
* and other copyright owners as documented in the project's IP log.
|
||||||
*
|
*
|
||||||
* This program and the accompanying materials are made available
|
* This program and the accompanying materials are made available
|
||||||
|
@ -49,117 +52,18 @@
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
|
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
|
||||||
import org.eclipse.jgit.util.JGitTestUtil;
|
import org.eclipse.jgit.util.JGitTestUtil;
|
||||||
import org.eclipse.jgit.util.SystemReader;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for most JGit unit tests.
|
* Base class for most JGit unit tests.
|
||||||
*
|
*
|
||||||
* Sets up a predefined test repository and has support for creating additional
|
* Sets up a predefined test repository and has support for creating additional
|
||||||
* repositories and destroying them when the tests are finished.
|
* repositories and destroying them when the tests are finished.
|
||||||
*
|
|
||||||
* A system property <em>jgit.junit.usemmap</em> defines whether memory mapping
|
|
||||||
* is used. Memory mapping has an effect on the file system, in that memory
|
|
||||||
* mapped files in java cannot be deleted as long as they mapped arrays have not
|
|
||||||
* been reclaimed by the garbage collector. The programmer cannot control this
|
|
||||||
* with precision, though hinting using <em>{@link java.lang.System#gc}</em>
|
|
||||||
* often helps.
|
|
||||||
*/
|
*/
|
||||||
public abstract class RepositoryTestCase extends TestCase {
|
public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
|
||||||
|
|
||||||
protected final File trashParent = new File("trash");
|
|
||||||
|
|
||||||
protected File trash;
|
|
||||||
|
|
||||||
protected File trash_git;
|
|
||||||
|
|
||||||
protected static final PersonIdent jauthor;
|
|
||||||
|
|
||||||
protected static final PersonIdent jcommitter;
|
|
||||||
|
|
||||||
static {
|
|
||||||
jauthor = new PersonIdent("J. Author", "jauthor@example.com");
|
|
||||||
jcommitter = new PersonIdent("J. Committer", "jcommitter@example.com");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean packedGitMMAP;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure JGit before setting up test repositories.
|
|
||||||
*/
|
|
||||||
protected void configure() {
|
|
||||||
final WindowCacheConfig c = new WindowCacheConfig();
|
|
||||||
c.setPackedGitLimit(128 * WindowCacheConfig.KB);
|
|
||||||
c.setPackedGitWindowSize(8 * WindowCacheConfig.KB);
|
|
||||||
c.setPackedGitMMAP("true".equals(System.getProperty("jgit.junit.usemmap")));
|
|
||||||
c.setDeltaBaseCacheLimit(8 * WindowCacheConfig.KB);
|
|
||||||
WindowCache.reconfigure(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility method to delete a directory recursively. It is
|
|
||||||
* also used internally. If a file or directory cannot be removed
|
|
||||||
* it throws an AssertionFailure.
|
|
||||||
*
|
|
||||||
* @param dir
|
|
||||||
*/
|
|
||||||
protected void recursiveDelete(final File dir) {
|
|
||||||
recursiveDelete(dir, false, getClass().getName() + "." + getName(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean recursiveDelete(final File dir, boolean silent,
|
|
||||||
final String name, boolean failOnError) {
|
|
||||||
assert !(silent && failOnError);
|
|
||||||
if (!dir.exists())
|
|
||||||
return silent;
|
|
||||||
final File[] ls = dir.listFiles();
|
|
||||||
if (ls != null) {
|
|
||||||
for (int k = 0; k < ls.length; k++) {
|
|
||||||
final File e = ls[k];
|
|
||||||
if (e.isDirectory()) {
|
|
||||||
silent = recursiveDelete(e, silent, name, failOnError);
|
|
||||||
} else {
|
|
||||||
if (!e.delete()) {
|
|
||||||
if (!silent) {
|
|
||||||
reportDeleteFailure(name, failOnError, e);
|
|
||||||
}
|
|
||||||
silent = !failOnError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!dir.delete()) {
|
|
||||||
if (!silent) {
|
|
||||||
reportDeleteFailure(name, failOnError, dir);
|
|
||||||
}
|
|
||||||
silent = !failOnError;
|
|
||||||
}
|
|
||||||
return silent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void reportDeleteFailure(final String name,
|
|
||||||
boolean failOnError, final File e) {
|
|
||||||
String severity;
|
|
||||||
if (failOnError)
|
|
||||||
severity = "Error";
|
|
||||||
else
|
|
||||||
severity = "Warning";
|
|
||||||
String msg = severity + ": Failed to delete " + e;
|
|
||||||
if (name != null)
|
|
||||||
msg += " in " + name;
|
|
||||||
if (failOnError)
|
|
||||||
fail(msg);
|
|
||||||
else
|
|
||||||
System.out.println(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void copyFile(final File src, final File dst)
|
protected static void copyFile(final File src, final File dst)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final FileInputStream fis = new FileInputStream(src);
|
final FileInputStream fis = new FileInputStream(src);
|
||||||
|
@ -181,18 +85,9 @@ protected static void copyFile(final File src, final File dst)
|
||||||
|
|
||||||
protected File writeTrashFile(final String name, final String data)
|
protected File writeTrashFile(final String name, final String data)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
File tf = new File(trash, name);
|
File path = new File(db.getWorkDir(), name);
|
||||||
File tfp = tf.getParentFile();
|
write(path, data);
|
||||||
if (!tfp.exists() && !tf.getParentFile().mkdirs())
|
return path;
|
||||||
throw new Error("Could not create directory " + tf.getParentFile());
|
|
||||||
final OutputStreamWriter fw = new OutputStreamWriter(
|
|
||||||
new FileOutputStream(tf), "UTF-8");
|
|
||||||
try {
|
|
||||||
fw.write(data);
|
|
||||||
} finally {
|
|
||||||
fw.close();
|
|
||||||
}
|
|
||||||
return tf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void checkFile(File f, final String checkData)
|
protected static void checkFile(File f, final String checkData)
|
||||||
|
@ -208,46 +103,17 @@ protected static void checkFile(File f, final String checkData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Test repository, initialized for this test case. */
|
||||||
protected Repository db;
|
protected Repository db;
|
||||||
|
|
||||||
private static Thread shutdownhook;
|
/** Working directory of {@link #db}. */
|
||||||
private static List<Runnable> shutDownCleanups = new ArrayList<Runnable>();
|
protected File trash;
|
||||||
private static int testcount;
|
|
||||||
|
|
||||||
private ArrayList<Repository> repositoriesToClose = new ArrayList<Repository>();
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
public void setUp() throws Exception {
|
|
||||||
super.setUp();
|
super.setUp();
|
||||||
configure();
|
db = createWorkRepository();
|
||||||
final String name = getClass().getName() + "." + getName();
|
trash = db.getWorkDir();
|
||||||
recursiveDelete(trashParent, true, name, false); // Cleanup old failed stuff
|
|
||||||
trash = new File(trashParent,"trash"+System.currentTimeMillis()+"."+(testcount++));
|
|
||||||
trash_git = new File(trash, ".git").getCanonicalFile();
|
|
||||||
if (shutdownhook == null) {
|
|
||||||
shutdownhook = new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// This may look superfluous, but is an extra attempt
|
|
||||||
// to clean up. First GC to release as many resources
|
|
||||||
// as possible and then try to clean up one test repo
|
|
||||||
// at a time (to record problems) and finally to drop
|
|
||||||
// the directory containing all test repositories.
|
|
||||||
System.gc();
|
|
||||||
for (Runnable r : shutDownCleanups)
|
|
||||||
r.run();
|
|
||||||
recursiveDelete(trashParent, false, null, false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Runtime.getRuntime().addShutdownHook(shutdownhook);
|
|
||||||
}
|
|
||||||
|
|
||||||
final MockSystemReader mockSystemReader = new MockSystemReader();
|
|
||||||
mockSystemReader.userGitConfig = new FileBasedConfig(new File(
|
|
||||||
trash_git, "usergitconfig"));
|
|
||||||
SystemReader.setInstance(mockSystemReader);
|
|
||||||
|
|
||||||
db = new Repository(trash_git);
|
|
||||||
db.create();
|
|
||||||
|
|
||||||
final String[] packs = {
|
final String[] packs = {
|
||||||
"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f",
|
"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f",
|
||||||
|
@ -259,70 +125,12 @@ public void run() {
|
||||||
"pack-3280af9c07ee18a87705ef50b0cc4cd20266cf12"
|
"pack-3280af9c07ee18a87705ef50b0cc4cd20266cf12"
|
||||||
};
|
};
|
||||||
final File packDir = new File(db.getObjectsDirectory(), "pack");
|
final File packDir = new File(db.getObjectsDirectory(), "pack");
|
||||||
for (int k = 0; k < packs.length; k++) {
|
for (String n : packs) {
|
||||||
copyFile(JGitTestUtil.getTestResourceFile(packs[k] + ".pack"), new File(packDir,
|
copyFile(JGitTestUtil.getTestResourceFile(n + ".pack"), new File(packDir, n + ".pack"));
|
||||||
packs[k] + ".pack"));
|
copyFile(JGitTestUtil.getTestResourceFile(n + ".idx"), new File(packDir, n + ".idx"));
|
||||||
copyFile(JGitTestUtil.getTestResourceFile(packs[k] + ".idx"), new File(packDir,
|
|
||||||
packs[k] + ".idx"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
copyFile(JGitTestUtil.getTestResourceFile("packed-refs"), new File(trash_git,"packed-refs"));
|
copyFile(JGitTestUtil.getTestResourceFile("packed-refs"), new File(db
|
||||||
}
|
.getDirectory(), "packed-refs"));
|
||||||
|
|
||||||
protected void tearDown() throws Exception {
|
|
||||||
RepositoryCache.clear();
|
|
||||||
db.close();
|
|
||||||
for (Repository r : repositoriesToClose)
|
|
||||||
r.close();
|
|
||||||
|
|
||||||
// Since memory mapping is controlled by the GC we need to
|
|
||||||
// tell it this is a good time to clean up and unlock
|
|
||||||
// memory mapped files.
|
|
||||||
if (packedGitMMAP)
|
|
||||||
System.gc();
|
|
||||||
|
|
||||||
final String name = getClass().getName() + "." + getName();
|
|
||||||
recursiveDelete(trash, false, name, true);
|
|
||||||
for (Repository r : repositoriesToClose)
|
|
||||||
recursiveDelete(r.getWorkDir(), false, name, true);
|
|
||||||
repositoriesToClose.clear();
|
|
||||||
|
|
||||||
super.tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper for creating extra empty repos
|
|
||||||
*
|
|
||||||
* @return a new empty git repository for testing purposes
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
protected Repository createNewEmptyRepo() throws IOException {
|
|
||||||
return createNewEmptyRepo(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper for creating extra empty repos
|
|
||||||
*
|
|
||||||
* @param bare if true, create a bare repository.
|
|
||||||
* @return a new empty git repository for testing purposes
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
protected Repository createNewEmptyRepo(boolean bare) throws IOException {
|
|
||||||
final File newTestRepo = new File(trashParent, "new"
|
|
||||||
+ System.currentTimeMillis() + "." + (testcount++)
|
|
||||||
+ (bare ? "" : "/") + ".git").getCanonicalFile();
|
|
||||||
assertFalse(newTestRepo.exists());
|
|
||||||
final Repository newRepo = new Repository(newTestRepo);
|
|
||||||
newRepo.create();
|
|
||||||
final String name = getClass().getName() + "." + getName();
|
|
||||||
shutDownCleanups.add(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
recursiveDelete(newTestRepo, false, name, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
repositoriesToClose.add(newRepo);
|
|
||||||
return newRepo;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public void test002_WriteEmptyTree() throws IOException {
|
||||||
// open when we create it we won't write the object file out as a loose
|
// open when we create it we won't write the object file out as a loose
|
||||||
// object (as it already exists in the pack).
|
// object (as it already exists in the pack).
|
||||||
//
|
//
|
||||||
final Repository newdb = createNewEmptyRepo();
|
final Repository newdb = createBareRepository();
|
||||||
final Tree t = new Tree(newdb);
|
final Tree t = new Tree(newdb);
|
||||||
t.accept(new WriteTree(trash, newdb), TreeEntry.MODIFIED_ONLY);
|
t.accept(new WriteTree(trash, newdb), TreeEntry.MODIFIED_ONLY);
|
||||||
assertEquals("4b825dc642cb6eb9a060e54bf8d69288fbee4904", t.getId()
|
assertEquals("4b825dc642cb6eb9a060e54bf8d69288fbee4904", t.getId()
|
||||||
|
@ -101,7 +101,8 @@ public void test002_WriteEmptyTree2() throws IOException {
|
||||||
t.accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
|
t.accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
|
||||||
assertEquals("4b825dc642cb6eb9a060e54bf8d69288fbee4904", t.getId()
|
assertEquals("4b825dc642cb6eb9a060e54bf8d69288fbee4904", t.getId()
|
||||||
.name());
|
.name());
|
||||||
final File o = new File(new File(new File(trash_git, "objects"), "4b"),
|
final File o = new File(new File(
|
||||||
|
new File(db.getDirectory(), "objects"), "4b"),
|
||||||
"825dc642cb6eb9a060e54bf8d69288fbee4904");
|
"825dc642cb6eb9a060e54bf8d69288fbee4904");
|
||||||
assertFalse("Exists " + o, o.isFile());
|
assertFalse("Exists " + o, o.isFile());
|
||||||
}
|
}
|
||||||
|
@ -115,12 +116,12 @@ public void test003_WriteShouldBeEmptyTree() throws IOException {
|
||||||
.name());
|
.name());
|
||||||
|
|
||||||
File o;
|
File o;
|
||||||
o = new File(new File(new File(trash_git, "objects"), "7b"),
|
o = new File(new File(new File(db.getDirectory(), "objects"), "7b"),
|
||||||
"b943559a305bdd6bdee2cef6e5df2413c3d30a");
|
"b943559a305bdd6bdee2cef6e5df2413c3d30a");
|
||||||
assertTrue("Exists " + o, o.isFile());
|
assertTrue("Exists " + o, o.isFile());
|
||||||
assertTrue("Read-only " + o, !o.canWrite());
|
assertTrue("Read-only " + o, !o.canWrite());
|
||||||
|
|
||||||
o = new File(new File(new File(trash_git, "objects"), "e6"),
|
o = new File(new File(new File(db.getDirectory(), "objects"), "e6"),
|
||||||
"9de29bb2d1d6434b8b29ae775ad8c2e48c5391");
|
"9de29bb2d1d6434b8b29ae775ad8c2e48c5391");
|
||||||
assertTrue("Exists " + o, o.isFile());
|
assertTrue("Exists " + o, o.isFile());
|
||||||
assertTrue("Read-only " + o, !o.canWrite());
|
assertTrue("Read-only " + o, !o.canWrite());
|
||||||
|
@ -202,8 +203,8 @@ public void test009_CreateCommitOldFormat() throws IOException,
|
||||||
t.getTreeId());
|
t.getTreeId());
|
||||||
|
|
||||||
final Commit c = new Commit(db);
|
final Commit c = new Commit(db);
|
||||||
c.setAuthor(new PersonIdent(jauthor, 1154236443000L, -4 * 60));
|
c.setAuthor(new PersonIdent(author, 1154236443000L, -4 * 60));
|
||||||
c.setCommitter(new PersonIdent(jcommitter, 1154236443000L, -4 * 60));
|
c.setCommitter(new PersonIdent(committer, 1154236443000L, -4 * 60));
|
||||||
c.setMessage("A Commit\n");
|
c.setMessage("A Commit\n");
|
||||||
c.setTree(t);
|
c.setTree(t);
|
||||||
assertEquals(t.getTreeId(), c.getTreeId());
|
assertEquals(t.getTreeId(), c.getTreeId());
|
||||||
|
@ -258,7 +259,7 @@ public void test020_createBlobTag() throws IOException {
|
||||||
t.setObjId(emptyId);
|
t.setObjId(emptyId);
|
||||||
t.setType("blob");
|
t.setType("blob");
|
||||||
t.setTag("test020");
|
t.setTag("test020");
|
||||||
t.setAuthor(new PersonIdent(jauthor, 1154236443000L, -4 * 60));
|
t.setAuthor(new PersonIdent(author, 1154236443000L, -4 * 60));
|
||||||
t.setMessage("test020 tagged\n");
|
t.setMessage("test020 tagged\n");
|
||||||
t.tag();
|
t.tag();
|
||||||
assertEquals("6759556b09fbb4fd8ae5e315134481cc25d46954", t.getTagId().name());
|
assertEquals("6759556b09fbb4fd8ae5e315134481cc25d46954", t.getTagId().name());
|
||||||
|
@ -266,7 +267,7 @@ public void test020_createBlobTag() throws IOException {
|
||||||
Tag mapTag = db.mapTag("test020");
|
Tag mapTag = db.mapTag("test020");
|
||||||
assertEquals("blob", mapTag.getType());
|
assertEquals("blob", mapTag.getType());
|
||||||
assertEquals("test020 tagged\n", mapTag.getMessage());
|
assertEquals("test020 tagged\n", mapTag.getMessage());
|
||||||
assertEquals(new PersonIdent(jauthor, 1154236443000L, -4 * 60), mapTag.getAuthor());
|
assertEquals(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag.getAuthor());
|
||||||
assertEquals("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", mapTag.getObjId().name());
|
assertEquals("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", mapTag.getObjId().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +293,7 @@ public void test021_createTreeTag() throws IOException {
|
||||||
t.setObjId(almostEmptyTreeId);
|
t.setObjId(almostEmptyTreeId);
|
||||||
t.setType("tree");
|
t.setType("tree");
|
||||||
t.setTag("test021");
|
t.setTag("test021");
|
||||||
t.setAuthor(new PersonIdent(jauthor, 1154236443000L, -4 * 60));
|
t.setAuthor(new PersonIdent(author, 1154236443000L, -4 * 60));
|
||||||
t.setMessage("test021 tagged\n");
|
t.setMessage("test021 tagged\n");
|
||||||
t.tag();
|
t.tag();
|
||||||
assertEquals("b0517bc8dbe2096b419d42424cd7030733f4abe5", t.getTagId().name());
|
assertEquals("b0517bc8dbe2096b419d42424cd7030733f4abe5", t.getTagId().name());
|
||||||
|
@ -300,7 +301,7 @@ public void test021_createTreeTag() throws IOException {
|
||||||
Tag mapTag = db.mapTag("test021");
|
Tag mapTag = db.mapTag("test021");
|
||||||
assertEquals("tree", mapTag.getType());
|
assertEquals("tree", mapTag.getType());
|
||||||
assertEquals("test021 tagged\n", mapTag.getMessage());
|
assertEquals("test021 tagged\n", mapTag.getMessage());
|
||||||
assertEquals(new PersonIdent(jauthor, 1154236443000L, -4 * 60), mapTag.getAuthor());
|
assertEquals(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag.getAuthor());
|
||||||
assertEquals("417c01c8795a35b8e835113a85a5c0c1c77f67fb", mapTag.getObjId().name());
|
assertEquals("417c01c8795a35b8e835113a85a5c0c1c77f67fb", mapTag.getObjId().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,8 +311,8 @@ public void test022_createCommitTag() throws IOException {
|
||||||
almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
|
almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
|
||||||
final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree);
|
final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree);
|
||||||
final Commit almostEmptyCommit = new Commit(db);
|
final Commit almostEmptyCommit = new Commit(db);
|
||||||
almostEmptyCommit.setAuthor(new PersonIdent(jauthor, 1154236443000L, -2 * 60)); // not exactly the same
|
almostEmptyCommit.setAuthor(new PersonIdent(author, 1154236443000L, -2 * 60)); // not exactly the same
|
||||||
almostEmptyCommit.setCommitter(new PersonIdent(jauthor, 1154236443000L, -2 * 60));
|
almostEmptyCommit.setCommitter(new PersonIdent(author, 1154236443000L, -2 * 60));
|
||||||
almostEmptyCommit.setMessage("test022\n");
|
almostEmptyCommit.setMessage("test022\n");
|
||||||
almostEmptyCommit.setTreeId(almostEmptyTreeId);
|
almostEmptyCommit.setTreeId(almostEmptyTreeId);
|
||||||
ObjectId almostEmptyCommitId = new ObjectWriter(db).writeCommit(almostEmptyCommit);
|
ObjectId almostEmptyCommitId = new ObjectWriter(db).writeCommit(almostEmptyCommit);
|
||||||
|
@ -319,7 +320,7 @@ public void test022_createCommitTag() throws IOException {
|
||||||
t.setObjId(almostEmptyCommitId);
|
t.setObjId(almostEmptyCommitId);
|
||||||
t.setType("commit");
|
t.setType("commit");
|
||||||
t.setTag("test022");
|
t.setTag("test022");
|
||||||
t.setAuthor(new PersonIdent(jauthor, 1154236443000L, -4 * 60));
|
t.setAuthor(new PersonIdent(author, 1154236443000L, -4 * 60));
|
||||||
t.setMessage("test022 tagged\n");
|
t.setMessage("test022 tagged\n");
|
||||||
t.tag();
|
t.tag();
|
||||||
assertEquals("0ce2ebdb36076ef0b38adbe077a07d43b43e3807", t.getTagId().name());
|
assertEquals("0ce2ebdb36076ef0b38adbe077a07d43b43e3807", t.getTagId().name());
|
||||||
|
@ -327,7 +328,7 @@ public void test022_createCommitTag() throws IOException {
|
||||||
Tag mapTag = db.mapTag("test022");
|
Tag mapTag = db.mapTag("test022");
|
||||||
assertEquals("commit", mapTag.getType());
|
assertEquals("commit", mapTag.getType());
|
||||||
assertEquals("test022 tagged\n", mapTag.getMessage());
|
assertEquals("test022 tagged\n", mapTag.getMessage());
|
||||||
assertEquals(new PersonIdent(jauthor, 1154236443000L, -4 * 60), mapTag.getAuthor());
|
assertEquals(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag.getAuthor());
|
||||||
assertEquals("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag.getObjId().name());
|
assertEquals("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag.getObjId().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,19 +393,19 @@ public void test025_packedRefs() throws IOException {
|
||||||
assertNotNull("have tag test020", mapTag20);
|
assertNotNull("have tag test020", mapTag20);
|
||||||
assertEquals("blob", mapTag20.getType());
|
assertEquals("blob", mapTag20.getType());
|
||||||
assertEquals("test020 tagged\n", mapTag20.getMessage());
|
assertEquals("test020 tagged\n", mapTag20.getMessage());
|
||||||
assertEquals(new PersonIdent(jauthor, 1154236443000L, -4 * 60), mapTag20.getAuthor());
|
assertEquals(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag20.getAuthor());
|
||||||
assertEquals("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", mapTag20.getObjId().name());
|
assertEquals("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", mapTag20.getObjId().name());
|
||||||
|
|
||||||
Tag mapTag21 = db.mapTag("test021");
|
Tag mapTag21 = db.mapTag("test021");
|
||||||
assertEquals("tree", mapTag21.getType());
|
assertEquals("tree", mapTag21.getType());
|
||||||
assertEquals("test021 tagged\n", mapTag21.getMessage());
|
assertEquals("test021 tagged\n", mapTag21.getMessage());
|
||||||
assertEquals(new PersonIdent(jauthor, 1154236443000L, -4 * 60), mapTag21.getAuthor());
|
assertEquals(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag21.getAuthor());
|
||||||
assertEquals("417c01c8795a35b8e835113a85a5c0c1c77f67fb", mapTag21.getObjId().name());
|
assertEquals("417c01c8795a35b8e835113a85a5c0c1c77f67fb", mapTag21.getObjId().name());
|
||||||
|
|
||||||
Tag mapTag22 = db.mapTag("test022");
|
Tag mapTag22 = db.mapTag("test022");
|
||||||
assertEquals("commit", mapTag22.getType());
|
assertEquals("commit", mapTag22.getType());
|
||||||
assertEquals("test022 tagged\n", mapTag22.getMessage());
|
assertEquals("test022 tagged\n", mapTag22.getMessage());
|
||||||
assertEquals(new PersonIdent(jauthor, 1154236443000L, -4 * 60), mapTag22.getAuthor());
|
assertEquals(new PersonIdent(author, 1154236443000L, -4 * 60), mapTag22.getAuthor());
|
||||||
assertEquals("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag22.getObjId().name());
|
assertEquals("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag22.getObjId().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,8 +427,8 @@ public void test026_CreateCommitMultipleparents() throws IOException {
|
||||||
t.getTreeId());
|
t.getTreeId());
|
||||||
|
|
||||||
final Commit c1 = new Commit(db);
|
final Commit c1 = new Commit(db);
|
||||||
c1.setAuthor(new PersonIdent(jauthor, 1154236443000L, -4 * 60));
|
c1.setAuthor(new PersonIdent(author, 1154236443000L, -4 * 60));
|
||||||
c1.setCommitter(new PersonIdent(jcommitter, 1154236443000L, -4 * 60));
|
c1.setCommitter(new PersonIdent(committer, 1154236443000L, -4 * 60));
|
||||||
c1.setMessage("A Commit\n");
|
c1.setMessage("A Commit\n");
|
||||||
c1.setTree(t);
|
c1.setTree(t);
|
||||||
assertEquals(t.getTreeId(), c1.getTreeId());
|
assertEquals(t.getTreeId(), c1.getTreeId());
|
||||||
|
@ -437,8 +438,8 @@ public void test026_CreateCommitMultipleparents() throws IOException {
|
||||||
assertEquals(cmtid1, c1.getCommitId());
|
assertEquals(cmtid1, c1.getCommitId());
|
||||||
|
|
||||||
final Commit c2 = new Commit(db);
|
final Commit c2 = new Commit(db);
|
||||||
c2.setAuthor(new PersonIdent(jauthor, 1154236443000L, -4 * 60));
|
c2.setAuthor(new PersonIdent(author, 1154236443000L, -4 * 60));
|
||||||
c2.setCommitter(new PersonIdent(jcommitter, 1154236443000L, -4 * 60));
|
c2.setCommitter(new PersonIdent(committer, 1154236443000L, -4 * 60));
|
||||||
c2.setMessage("A Commit 2\n");
|
c2.setMessage("A Commit 2\n");
|
||||||
c2.setTree(t);
|
c2.setTree(t);
|
||||||
assertEquals(t.getTreeId(), c2.getTreeId());
|
assertEquals(t.getTreeId(), c2.getTreeId());
|
||||||
|
@ -458,8 +459,8 @@ public void test026_CreateCommitMultipleparents() throws IOException {
|
||||||
assertEquals(c1.getCommitId(), rm2.getParentIds()[0]);
|
assertEquals(c1.getCommitId(), rm2.getParentIds()[0]);
|
||||||
|
|
||||||
final Commit c3 = new Commit(db);
|
final Commit c3 = new Commit(db);
|
||||||
c3.setAuthor(new PersonIdent(jauthor, 1154236443000L, -4 * 60));
|
c3.setAuthor(new PersonIdent(author, 1154236443000L, -4 * 60));
|
||||||
c3.setCommitter(new PersonIdent(jcommitter, 1154236443000L, -4 * 60));
|
c3.setCommitter(new PersonIdent(committer, 1154236443000L, -4 * 60));
|
||||||
c3.setMessage("A Commit 3\n");
|
c3.setMessage("A Commit 3\n");
|
||||||
c3.setTree(t);
|
c3.setTree(t);
|
||||||
assertEquals(t.getTreeId(), c3.getTreeId());
|
assertEquals(t.getTreeId(), c3.getTreeId());
|
||||||
|
@ -480,8 +481,8 @@ public void test026_CreateCommitMultipleparents() throws IOException {
|
||||||
assertEquals(c2.getCommitId(), rm3.getParentIds()[1]);
|
assertEquals(c2.getCommitId(), rm3.getParentIds()[1]);
|
||||||
|
|
||||||
final Commit c4 = new Commit(db);
|
final Commit c4 = new Commit(db);
|
||||||
c4.setAuthor(new PersonIdent(jauthor, 1154236443000L, -4 * 60));
|
c4.setAuthor(new PersonIdent(author, 1154236443000L, -4 * 60));
|
||||||
c4.setCommitter(new PersonIdent(jcommitter, 1154236443000L, -4 * 60));
|
c4.setCommitter(new PersonIdent(committer, 1154236443000L, -4 * 60));
|
||||||
c4.setMessage("A Commit 4\n");
|
c4.setMessage("A Commit 4\n");
|
||||||
c4.setTree(t);
|
c4.setTree(t);
|
||||||
assertEquals(t.getTreeId(), c3.getTreeId());
|
assertEquals(t.getTreeId(), c3.getTreeId());
|
||||||
|
|
|
@ -147,8 +147,8 @@ protected RevCommit commit(final int secDelta, final RevTree tree,
|
||||||
final Commit c = new Commit(db);
|
final Commit c = new Commit(db);
|
||||||
c.setTreeId(tree);
|
c.setTreeId(tree);
|
||||||
c.setParentIds(parents);
|
c.setParentIds(parents);
|
||||||
c.setAuthor(new PersonIdent(jauthor, new Date(nowTick)));
|
c.setAuthor(new PersonIdent(author, new Date(nowTick)));
|
||||||
c.setCommitter(new PersonIdent(jcommitter, new Date(nowTick)));
|
c.setCommitter(new PersonIdent(committer, new Date(nowTick)));
|
||||||
c.setMessage("");
|
c.setMessage("");
|
||||||
return rw.lookupCommit(ow.writeCommit(c));
|
return rw.lookupCommit(ow.writeCommit(c));
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ protected RevTag tag(final String name, final RevObject dst)
|
||||||
t.setType(Constants.typeString(dst.getType()));
|
t.setType(Constants.typeString(dst.getType()));
|
||||||
t.setObjId(dst.toObjectId());
|
t.setObjId(dst.toObjectId());
|
||||||
t.setTag(name);
|
t.setTag(name);
|
||||||
t.setTagger(new PersonIdent(jcommitter, new Date(nowTick)));
|
t.setTagger(new PersonIdent(committer, new Date(nowTick)));
|
||||||
t.setMessage("");
|
t.setMessage("");
|
||||||
return (RevTag) rw.lookupAny(ow.writeTag(t), Constants.OBJ_TAG);
|
return (RevTag) rw.lookupAny(ow.writeTag(t), Constants.OBJ_TAG);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2008, Google Inc.
|
* Copyright (C) 2008-2009, Google Inc.
|
||||||
* Copyright (C) 2008, Mike Ralphson <mike@abacus.co.uk>
|
* Copyright (C) 2008, Mike Ralphson <mike@abacus.co.uk>
|
||||||
* Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
|
* Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||||
* and other copyright owners as documented in the project's IP log.
|
* and other copyright owners as documented in the project's IP log.
|
||||||
|
@ -74,7 +74,7 @@ public void testWrite0() throws Exception {
|
||||||
// Then we clone a new repo from that bundle and do a simple test. This
|
// Then we clone a new repo from that bundle and do a simple test. This
|
||||||
// makes sure
|
// makes sure
|
||||||
// we could read the bundle we created.
|
// we could read the bundle we created.
|
||||||
Repository newRepo = createNewEmptyRepo();
|
Repository newRepo = createBareRepository();
|
||||||
FetchResult fetchResult = fetchFromBundle(newRepo, bundle);
|
FetchResult fetchResult = fetchFromBundle(newRepo, bundle);
|
||||||
Ref advertisedRef = fetchResult
|
Ref advertisedRef = fetchResult
|
||||||
.getAdvertisedRef("refs/heads/firstcommit");
|
.getAdvertisedRef("refs/heads/firstcommit");
|
||||||
|
@ -101,7 +101,7 @@ public void testWrite1() throws Exception {
|
||||||
// Then we clone a new repo from that bundle and do a simple test. This
|
// Then we clone a new repo from that bundle and do a simple test. This
|
||||||
// makes sure
|
// makes sure
|
||||||
// we could read the bundle we created.
|
// we could read the bundle we created.
|
||||||
Repository newRepo = createNewEmptyRepo();
|
Repository newRepo = createBareRepository();
|
||||||
FetchResult fetchResult = fetchFromBundle(newRepo, bundle);
|
FetchResult fetchResult = fetchFromBundle(newRepo, bundle);
|
||||||
Ref advertisedRef = fetchResult.getAdvertisedRef("refs/heads/aa");
|
Ref advertisedRef = fetchResult.getAdvertisedRef("refs/heads/aa");
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ public void testWrite1() throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check that we actually needed the first bundle
|
// Check that we actually needed the first bundle
|
||||||
Repository newRepo2 = createNewEmptyRepo();
|
Repository newRepo2 = createBareRepository();
|
||||||
fetchResult = fetchFromBundle(newRepo2, bundle);
|
fetchResult = fetchFromBundle(newRepo2, bundle);
|
||||||
fail("We should not be able to fetch from bundle with prerequisites that are not fulfilled");
|
fail("We should not be able to fetch from bundle with prerequisites that are not fulfilled");
|
||||||
} catch (MissingBundlePrerequisiteException e) {
|
} catch (MissingBundlePrerequisiteException e) {
|
||||||
|
|
Loading…
Reference in New Issue