<commit_before>package hu.sebcsaba.gitrelocate;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class MockedGitRunner implements GitRunner {
	
	private static final String ZERO = "0000000000000000000000000000000000000000";
	
	private final int[] branches;
	private final int[] tags;
	private final int[][] parents;
	
	public MockedGitRunner(int[] branches, int[] tags, int[][] parents) {
		this.branches = branches;
		this.tags = tags;
		this.parents = parents;
	}

	public CommitID getCommitId(String anyGitCommitRef) {
		int cid = resolve(anyGitCommitRef);
		return intToCommitID(cid);
	}

	public List<CommitID> getCommitParentIds(CommitID commitId) {
		int cid = Integer.parseInt(commitId.toString());
		int[] pcids = parents[cid];
		List<CommitID> result = new ArrayList<CommitID>(pcids.length);
		for (int pcid : pcids) {
			result.add(intToCommitID(pcid));
		}
		return result;
	}

	public Collection<String> getTagNames() {
		return toNamesList("T",tags.length);
	}

	public Collection<String> getBranchNames() {
		return toNamesList("B", branches.length);
	}

	private List<String> toNamesList(String prefix, int length) {
		List<String> result = new ArrayList<String>(length);
		for (int i=0; i<length; ++i) {
			result.add(prefix+i);
		}
		return result;
	}
	
	private int resolve(String id) {
		if (id.matches("^B\\d+$")) {
			int key = Integer.parseInt(id.substring(1));
			return branches[key];
		} else if (id.matches("^T\\d+$")) {
			int key = Integer.parseInt(id.substring(1));
			return tags[key];
		} else {
			throw new IllegalArgumentException("Unable to parse commit id for "+id);
		}
	}

	public static CommitID intToCommitID(int cid) {
		String cids = Integer.toString(cid);
		return new CommitID(ZERO.substring(0, ZERO.length()-cids.length()) + cids);
	}
	
}<commit_msg>use GitSubGraph implementation in MockedGitRunner<commit_after>package hu.sebcsaba.gitrelocate;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class MockedGitRunner implements GitRunner {
	
	private static final String ZERO = "0000000000000000000000000000000000000000";
	
	private final GitSubGraph graph;
	
	public MockedGitRunner(int[] branches, int[] tags, int[][] parents) {
		this.graph = new GitSubGraph();
		for (int i=0; i<branches.length; ++i) {
			this.graph.getBranches().put("B"+i, intToCommitID(branches[i]));
		}
		for (int i=0; i<tags.length; ++i) {
			this.graph.getTags().put("T"+i, intToCommitID(tags[i]));
		}
		for (int i=0; i<parents.length; ++i) {
			List<CommitID> parentIDs = new ArrayList<CommitID>();
			for (int j=0; j<parents[i].length; ++j) {
				parentIDs.add(intToCommitID(parents[i][j]));
			}
			Commit c = new Commit(intToCommitID(i), parentIDs);
			this.graph.getCommits().add(c );
		}
	}

	public CommitID getCommitId(String anyGitCommitRef) {
		if (graph.getBranches().containsKey(anyGitCommitRef)) {
			return graph.getBranches().get(anyGitCommitRef);
		} else if (graph.getTags().containsKey(anyGitCommitRef)) {
			return graph.getTags().get(anyGitCommitRef);
		} else {
			throw new IllegalArgumentException("Unable to parse commit id for "+anyGitCommitRef);
		}
	}

	public List<CommitID> getCommitParentIds(CommitID commitId) {
		return graph.getCommit(commitId).getParents();
	}

	public Collection<String> getTagNames() {
		return new ArrayList<String>(this.graph.getTags().keySet());
	}

	public Collection<String> getBranchNames() {
		return new ArrayList<String>(this.graph.getBranches().keySet());
	}

	public static CommitID intToCommitID(int cid) {
		String cids = Integer.toString(cid);
		return new CommitID(ZERO.substring(0, ZERO.length()-cids.length()) + cids);
	}
	
}
{'fraction_non_alphanumeric': 0.14081081081081082, 'fraction_numerical': 0.024054054054054055, 'mean_word_length': 4.931089743589744, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5009731', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1242, 'n_words': 271}