public int getDepth(final ObjectId commitId) { synchronized (delegate) { return delegate.getDepth(commitId); } }
public int getDepth(final ObjectId commitId) { synchronized (delegate) { return delegate.getDepth(commitId); } }
/** * Gets the depth of the given commit. * * @param commitId the commit id * @return the depth, or 0 if the commit was not found */ @Override public int getDepth(ObjectId commitId) { return localRepository.graphDatabase().getDepth(commitId); }
/** * Gets the depth of the given commit. * * @param commitId the commit id * @return the depth, or 0 if the commit was not found */ @Override public int getDepth(ObjectId commitId) { return localRepository.graphDatabase().getDepth(commitId); }
public Integer getDepth(RepositoryProvider provider, String repoName, ObjectId commitId) { Optional<Integer> depth = Optional.absent(); Repository repository = getRepository(provider, repoName); if (repository != null) { if (commitId != null) { depth = Optional.of(repository.graphDatabase().getDepth(commitId)); } else { depth = repository.getDepth(); } } return depth.orNull(); }
changedRefs.add(changedRef); } else if (depth.isPresent()) { int commitDepth = graphDatabase().getDepth(local.get().getObjectId()); if (depth.get() > commitDepth) { RefDiff RefDiff = new RefDiff(local.get(), remoteRef);
changedRefs.add(changedRef); } else if (depth.isPresent()) { int commitDepth = graphDatabase().getDepth(local.get().getObjectId()); if (depth.get() > commitDepth) { RefDiff RefDiff = new RefDiff(local.get(), remoteRef);
@Test public void testConcurrentUses() throws Exception { ConcurrentLinkedQueue<String> errorLog = new ConcurrentLinkedQueue<String>(); // ExecutorService executor = Executors.newCachedThreadPool(); ExecutorService executor = Executors.newSingleThreadExecutor(); List<Future<?>> futures = new ArrayList<Future<?>>(); for (String s : new String[] { "a", "b", "c", "d" }) { Runnable task = new InsertMany(s, errorLog); futures.add(executor.submit(task)); } for (Future<?> f : futures) { f.get(); } executor.shutdown(); executor.awaitTermination(10, TimeUnit.SECONDS); assertEquals(errorLog.toString(), 0, errorLog.size()); assertEquals(100, database.getDepth(RevObjectTestSupport.hashString("a_commit_100"))); }
@Test public void testConcurrentUses() throws Exception { ConcurrentLinkedQueue<String> errorLog = new ConcurrentLinkedQueue<String>(); // ExecutorService executor = Executors.newCachedThreadPool(); ExecutorService executor = Executors.newSingleThreadExecutor(); List<Future<?>> futures = new ArrayList<Future<?>>(); for (String s : new String[] { "a", "b", "c", "d" }) { Runnable task = new InsertMany(s, errorLog); futures.add(executor.submit(task)); } for (Future<?> f : futures) { f.get(); } executor.shutdown(); executor.awaitTermination(10, TimeUnit.SECONDS); assertEquals(errorLog.toString(), 0, errorLog.size()); assertEquals(100, database.getDepth(RevObjectTestSupport.hashString("a_commit_100"))); }
int newDepth = repository.graphDatabase().getDepth(newRef.getObjectId());
int newDepth = repository.graphDatabase().getDepth(newRef.getObjectId());
database.put(commit11, parents); assertEquals(0, database.getDepth(rootId)); assertEquals(2, database.getDepth(commit9)); assertEquals(3, database.getDepth(commit8)); assertEquals(5, database.getDepth(commit6)); assertEquals(4, database.getDepth(commit4)); assertEquals(1, database.getDepth(commit11));
database.put(commit11, parents); assertEquals(0, database.getDepth(rootId)); assertEquals(2, database.getDepth(commit9)); assertEquals(3, database.getDepth(commit8)); assertEquals(5, database.getDepth(commit6)); assertEquals(4, database.getDepth(commit4)); assertEquals(1, database.getDepth(commit11));
@Test public void testTruncate() throws IOException { 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)); assertTrue(database.exists(rootId)); assertTrue(database.exists(commit1)); assertTrue(database.exists(commit2)); assertNotNull(database.getNode(rootId)); assertNotNull(database.getNode(commit1)); assertNotNull(database.getNode(commit2)); assertEquals(1, database.getDepth(commit2)); database.truncate(); // not using getNode for assertions cause it's contract is not well defined for an invalid // argument and implementations behave differently. Created an issue to fix it. // assertNull(database.getNode(rootId)); // assertNull(database.getNode(commit1)); // assertNull(database.getNode(commit2)); // assertEquals(0, database.getDepth(commit2)); assertFalse(database.exists(rootId)); assertFalse(database.exists(commit1)); assertFalse(database.exists(commit2)); }
@Test public void testTruncate() throws IOException { 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)); assertTrue(database.exists(rootId)); assertTrue(database.exists(commit1)); assertTrue(database.exists(commit2)); assertNotNull(database.getNode(rootId)); assertNotNull(database.getNode(commit1)); assertNotNull(database.getNode(commit2)); assertEquals(1, database.getDepth(commit2)); database.truncate(); // not using getNode for assertions cause it's contract is not well defined for an invalid // argument and implementations behave differently. Created an issue to fix it. // assertNull(database.getNode(rootId)); // assertNull(database.getNode(commit1)); // assertNull(database.getNode(commit2)); // assertEquals(0, database.getDepth(commit2)); assertFalse(database.exists(rootId)); assertFalse(database.exists(commit1)); assertFalse(database.exists(commit2)); }