public ImmutableList<ObjectId> getParents(ObjectId commitId) throws IllegalArgumentException { synchronized (delegate) { return delegate.getParents(commitId); } }
public ImmutableList<ObjectId> getParents(ObjectId commitId) throws IllegalArgumentException { synchronized (delegate) { return delegate.getParents(commitId); } }
@Override protected ImmutableList<ObjectId> getParentsInternal(ObjectId commitId) { return source.graphDatabase().getParents(commitId); }
/** * Gets the parents of the specified commit from the repository. * * @param commit the id of the commit whose parents to retrieve * @return a list of parent ids for the commit */ @Override public ImmutableList<ObjectId> getParents(ObjectId commitId) { return localRepository.graphDatabase().getParents(commitId); }
/** * Gets the parents of the specified commit from the repository. * * @param commit the id of the commit whose parents to retrieve * @return a list of parent ids for the commit */ @Override public ImmutableList<ObjectId> getParents(ObjectId commitId) { return localRepository.graphDatabase().getParents(commitId); }
@Override protected ImmutableList<ObjectId> getParentsInternal(ObjectId commitId) { return source.graphDatabase().getParents(commitId); }
private Optional<ObjectId> resolveAncestor(ObjectId objectId, int ancestorN) { GraphDatabase graph = graphDatabase(); ObjectId ancestor = objectId; for (int i = 0; i < ancestorN; i++) { ImmutableList<ObjectId> parents = graph.getParents(ancestor); if (parents.isEmpty()) { return Optional.absent(); } ancestor = parents.get(0);// use first parent } ObjectDatabase odb = objectDatabase(); if (!odb.exists(ancestor)) { // the ancestor might not exist in case the commit was the origin of a shallow clone ancestor = null; } return Optional.fromNullable(ancestor); }
private Optional<ObjectId> resolveAncestor(ObjectId objectId, int ancestorN) { GraphDatabase graph = graphDatabase(); ObjectId ancestor = objectId; for (int i = 0; i < ancestorN; i++) { ImmutableList<ObjectId> parents = graph.getParents(ancestor); if (parents.isEmpty()) { return Optional.absent(); } ancestor = parents.get(0);// use first parent } ObjectDatabase odb = objectDatabase(); if (!odb.exists(ancestor)) { // the ancestor might not exist in case the commit was the origin of a shallow clone ancestor = null; } return Optional.fromNullable(ancestor); }
public Parents getParents(RepositoryProvider provider, String repoName, ObjectId oid) { Repository repository = getRepository(provider, repoName); Parents parents = new Parents(); if (repository != null && oid != null) { parents.setParents(repository.graphDatabase().getParents(oid)); } return parents; } }
@Test public void testGetParents() { ObjectId rootId = RevObjectTestSupport.hashString("root"); database.put(rootId, ImmutableList.of()); ObjectId commit1 = RevObjectTestSupport.hashString("c1"); database.put(commit1, ImmutableList.of(rootId)); ObjectId commit2 = RevObjectTestSupport.hashString("c2"); database.put(commit2, ImmutableList.of(commit1, rootId)); ImmutableList<ObjectId> parents = database.getParents(rootId); assertEquals(0, parents.size()); parents = database.getParents(commit1); assertEquals(1, parents.size()); assertTrue(parents.contains(rootId)); parents = database.getParents(commit2); assertEquals(2, parents.size()); assertEquals(commit1, parents.get(0)); assertEquals(rootId, parents.get(1)); parents = database.getParents(RevObjectTestSupport.hashString("nonexistent")); assertEquals(0, parents.size()); }
@Test public void testGetParents() { ObjectId rootId = RevObjectTestSupport.hashString("root"); database.put(rootId, ImmutableList.of()); ObjectId commit1 = RevObjectTestSupport.hashString("c1"); database.put(commit1, ImmutableList.of(rootId)); ObjectId commit2 = RevObjectTestSupport.hashString("c2"); database.put(commit2, ImmutableList.of(commit1, rootId)); ImmutableList<ObjectId> parents = database.getParents(rootId); assertEquals(0, parents.size()); parents = database.getParents(commit1); assertEquals(1, parents.size()); assertTrue(parents.contains(rootId)); parents = database.getParents(commit2); assertEquals(2, parents.size()); assertTrue(parents.contains(rootId)); assertTrue(parents.contains(commit1)); parents = database.getParents(RevObjectTestSupport.hashString("nonexistent")); assertEquals(0, parents.size()); }
parents = database.getParents(commit2); assertTrue(database.exists(commit2)); assertEquals("Size of " + children, 0, children.size()); assertEquals(commit1, parents.get(0)); children = database.getChildren(commit1); parents = database.getParents(commit1); assertTrue(database.exists(commit1)); assertEquals(1, children.size()); assertEquals(rootId, parents.get(0)); children = database.getChildren(rootId); parents = database.getParents(rootId); assertTrue(database.exists(rootId)); assertEquals(1, children.size());
parents = database.getParents(commit2); assertTrue(database.exists(commit2)); assertEquals("Size of " + children, 0, children.size()); assertEquals(commit1, parents.get(0)); children = database.getChildren(commit1); parents = database.getParents(commit1); assertTrue(database.exists(commit1)); assertEquals(1, children.size()); assertEquals(rootId, parents.get(0)); children = database.getChildren(rootId); parents = database.getParents(rootId); assertTrue(database.exists(rootId)); assertEquals(1, children.size());