// Path: src/java/main/br/ufpe/cin/groundhog/util/Dates.java
// public class Dates {
// 
// 	private SimpleDateFormat simpleDateFormat;
// 
// 	public Dates() {
// 		simpleDateFormat = new SimpleDateFormat();
// 	}
// 
// 	public Dates(String pattern) {
// 		simpleDateFormat = new SimpleDateFormat(pattern);
// 	}
// 
// 	public String format(Date date) {
// 		return simpleDateFormat.format(date);
// 	}
// 
// 	public Date format(String date) {
// 		try {
// 			return simpleDateFormat.parse(date);
// 		} catch (ParseException e) {
// 			e.printStackTrace();
// 			return null;
// 		}
// 	}
// }


import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.eclipse.jgit.api.AddCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.CheckoutConflictException;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.InvalidRefNameException;
import org.eclipse.jgit.api.errors.InvalidRemoteException;
import org.eclipse.jgit.api.errors.RefAlreadyExistsException;
import org.eclipse.jgit.api.errors.TransportException;
import org.eclipse.jgit.errors.StopWalkException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.revwalk.filter.RevFilter;
import org.gitective.core.CommitFinder;
import org.gitective.core.filter.commit.AllCommitFilter;
import org.gitective.core.filter.commit.AndCommitFilter;
import org.gitective.core.filter.commit.CommitCountFilter;
import org.gitective.core.filter.commit.CommitFilter;
import org.gitective.core.filter.commit.CommitterDateFilter;
import br.ufpe.cin.groundhog.util.Dates;
	 * @throws EmptyProjectAtDateException
	 */
	public void checkout(File repositoryFolder, Date date) throws IOException,
			RefAlreadyExistsException, InvalidRefNameException,
			CheckoutConflictException, GitAPIException,
			EmptyProjectAtDateException {

		Git git = Git.open(repositoryFolder);
		Repository rep = git.getRepository();
		CommitFinder finder = new CommitFinder(rep);
		final List<RevCommit> commits = new ArrayList<RevCommit>();

		finder.setFilter(new CommitterDateFilter(date).negate());
		AllCommitFilter filter = new AllCommitFilter() {
			@Override
			public boolean include(RevWalk walker, RevCommit commit)
					throws IOException {
				boolean include = super.include(walker, commit);
				if (include) {
					commits.add(commit);
				}
				return include;
			}
		};
		finder.setMatcher(filter);
		finder.find();

		if (commits.size() == 0) {
			rep.close();
			throw new EmptyProjectAtDateException(
// Path: src/java/main/br/ufpe/cin/groundhog/util/Dates.java
// public class Dates {
// 
// 	private SimpleDateFormat simpleDateFormat;
// 
// 	public Dates() {
// 		simpleDateFormat = new SimpleDateFormat();
// 	}
// 
// 	public Dates(String pattern) {
// 		simpleDateFormat = new SimpleDateFormat(pattern);
// 	}
// 
// 	public String format(Date date) {
// 		return simpleDateFormat.format(date);
// 	}
// 
// 	public Date format(String date) {
// 		try {
// 			return simpleDateFormat.parse(date);
// 		} catch (ParseException e) {
// 			e.printStackTrace();
// 			return null;
// 		}
// 	}
// }


// Path: src/java/main/br/ufpe/cin/groundhog/scmclient/GitClient.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.eclipse.jgit.api.AddCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.CheckoutConflictException;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.InvalidRefNameException;
import org.eclipse.jgit.api.errors.InvalidRemoteException;
import org.eclipse.jgit.api.errors.RefAlreadyExistsException;
import org.eclipse.jgit.api.errors.TransportException;
import org.eclipse.jgit.errors.StopWalkException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.revwalk.filter.RevFilter;
import org.gitective.core.CommitFinder;
import org.gitective.core.filter.commit.AllCommitFilter;
import org.gitective.core.filter.commit.AndCommitFilter;
import org.gitective.core.filter.commit.CommitCountFilter;
import org.gitective.core.filter.commit.CommitFilter;
import org.gitective.core.filter.commit.CommitterDateFilter;
import br.ufpe.cin.groundhog.util.Dates;

	 * @throws EmptyProjectAtDateException
	 */
	public void checkout(File repositoryFolder, Date date) throws IOException,
			RefAlreadyExistsException, InvalidRefNameException,
			CheckoutConflictException, GitAPIException,
			EmptyProjectAtDateException {

		Git git = Git.open(repositoryFolder);
		Repository rep = git.getRepository();
		CommitFinder finder = new CommitFinder(rep);
		final List<RevCommit> commits = new ArrayList<RevCommit>();

		finder.setFilter(new CommitterDateFilter(date).negate());
		AllCommitFilter filter = new AllCommitFilter() {
			@Override
			public boolean include(RevWalk walker, RevCommit commit)
					throws IOException {
				boolean include = super.include(walker, commit);
				if (include) {
					commits.add(commit);
				}
				return include;
			}
		};
		finder.setMatcher(filter);
		finder.find();

		if (commits.size() == 0) {
			rep.close();
			throw new EmptyProjectAtDateException(
					new Dates("yyyy-MM-dd").format(date));