/** * Pass through to {@link StagingDatabase}, replacing the namespace with the transaction * namespace. */ @Override public void addConflict(@Nullable String namespace, Conflict conflict) { database.addConflict(txNamespace, conflict); }
/** * Pass through to {@link StagingDatabase}, replacing the namespace with the transaction * namespace. */ @Override public Optional<Conflict> getConflict(@Nullable String namespace, String path) { return database.getConflict(txNamespace, path); }
/** * @param pathFilter the path filter for the conflicts * @return the number of conflicts that match the path filter, or the total number of conflicts * if a path filter was not specified */ @Override public long countConflicted(@Nullable String pathFilter) { return conflictsDb.getCountByPrefix(null, pathFilter); }
private CheckoutException buildConflictsException(final ConflictsDatabase conflictsDatabase) { final long conflictCount = conflictsDatabase.getCountByPrefix(null, null); Iterator<Conflict> conflicts = Iterators .limit(conflictsDatabase.getByPrefix(branchOrCommit, null), 25); StringBuilder msg = new StringBuilder(); while (conflicts.hasNext()) { Conflict conflict = conflicts.next(); msg.append("error: " + conflict.getPath() + " needs merge.\n"); } if (conflictCount > 25) { msg.append(String.format("and %,d more.\n", (conflictCount - 25))); } msg.append("You need to resolve your index first.\n"); return new CheckoutException(msg.toString(), StatusCode.UNMERGED_PATHS); } }
@Test public void testRemoveConflictsIterableNS() { final String ns = UUID.randomUUID().toString(); add(ns, c1, c2, c3); add(null, c1, c2, c3); conflicts.removeConflicts(ns, ImmutableList.of(c3.getPath(), c2.getPath())); assertTrue(conflicts.getConflict(ns, c1.getPath()).isPresent()); assertFalse(conflicts.getConflict(ns, c2.getPath()).isPresent()); assertFalse(conflicts.getConflict(ns, c3.getPath()).isPresent()); assertEquals(3, conflicts.getCountByPrefix(null, null)); }
@Test public void testGetCountByPrefix() { List<Conflict> rivers = createConflicts("rivers", 1555); List<Conflict> highways = createConflicts("roads/highways", 77); conflicts.addConflicts(null, rivers); conflicts.addConflicts("someTxId", highways); // create also conflict entries for the tree objects conflicts.addConflict(null, createTestConflict("rivers")); conflicts.addConflict("someTxId", createTestConflict("roads/highways")); assertEquals(0, conflicts.getCountByPrefix("someTxId", "rivers")); assertEquals(1 + rivers.size(), conflicts.getCountByPrefix(null, "rivers")); assertEquals(0, conflicts.getCountByPrefix(null, "highways")); assertEquals(1 + highways.size(), conflicts.getCountByPrefix("someTxId", "roads/highways")); }
@Test public void testRemoveByPrefix() { final String ns = UUID.randomUUID().toString(); add(ns, c1, c2, c3); add(ns, b1, b2, b3); add(null, c1, c2, c3); assertEquals(3, conflicts.getCountByPrefix(null, "Rivers")); assertEquals(3, conflicts.getCountByPrefix(ns, "Rivers")); conflicts.removeByPrefix(null, c2.getPath()); assertEquals(2, conflicts.getCountByPrefix(null, "Rivers")); assertEquals(3, conflicts.getCountByPrefix(ns, "Rivers")); assertFalse(conflicts.getConflict(null, c2.getPath()).isPresent()); assertEquals(3, conflicts.getCountByPrefix(ns, "buildings")); conflicts.removeByPrefix(ns, "buildings"); assertEquals(0, conflicts.getCountByPrefix(ns, "buildings")); }
@Test public void testRemoveConflict() { final String ns = UUID.randomUUID().toString(); add(null, c1, c3); add(ns, c2, c3); conflicts.removeConflict(ns, c1.getPath()); assertEquals(c1, conflicts.getConflict(null, c1.getPath()).get()); conflicts.removeConflict(null, c1.getPath()); assertFalse(conflicts.getConflict(null, c1.getPath()).isPresent()); assertFalse(conflicts.getConflict(ns, c1.getPath()).isPresent()); conflicts.removeConflict(null, c2.getPath()); assertEquals(c2, conflicts.getConflict(ns, c2.getPath()).get()); conflicts.removeConflict(ns, c2.getPath()); assertFalse(conflicts.getConflict(null, c2.getPath()).isPresent()); assertFalse(conflicts.getConflict(ns, c2.getPath()).isPresent()); assertTrue(conflicts.hasConflicts(null)); assertTrue(conflicts.hasConflicts(ns)); conflicts.removeConflict(null, c3.getPath()); assertFalse(conflicts.hasConflicts(null)); conflicts.removeConflict(ns, c3.getPath()); assertFalse(conflicts.hasConflicts(ns)); }
@Test public void testAddConflictsNS() { final String ns = UUID.randomUUID().toString(); Iterable<Conflict> list = ImmutableList.of(c1, c2, c3); conflicts.addConflicts(ns, list); assertEquals(c1, conflicts.getConflict(ns, c1.getPath()).get()); assertEquals(c2, conflicts.getConflict(ns, c2.getPath()).get()); assertEquals(c3, conflicts.getConflict(ns, c3.getPath()).get()); }
/** * Pass through to {@link StagingDatabase}, replacing the namespace with the transaction * namespace. */ @Override public void removeConflicts(@Nullable String namespace) { database.removeConflicts(txNamespace); }
conflictsDatabase().removeConflict(null, pattern); } else { repository.index().stage(subProgress((1.f / patterns.size()) * 100.f), diff, command(UpdateSymRef.class).setName(Ref.HEAD).setNewValue(currentBranch).call(); conflictsDatabase().removeConflicts(null); if (clean) { command(CleanRefsOp.class).call();
/** * Pass through to {@link StagingDatabase}, replacing the namespace with the transaction * namespace. */ @Override public boolean hasConflicts(String namespace) { return database.hasConflicts(txNamespace); }
@Test public void testRemoveConflicts() { final String ns = UUID.randomUUID().toString(); add(null, c1, c3); add(ns, c2, c3); assertTrue(conflicts.hasConflicts(null)); assertTrue(conflicts.hasConflicts(ns)); conflicts.removeConflicts(null); assertFalse(conflicts.hasConflicts(null)); assertTrue(conflicts.hasConflicts(ns)); add(null, c1); conflicts.removeConflicts(ns); assertTrue(conflicts.hasConflicts(null)); assertFalse(conflicts.hasConflicts(ns)); }
/** * @param pathFilter the path filter for the conflicts * @return the conflicts that match the path filter, if no path filter is specified, all * conflicts will be returned */ @Override public Iterator<Conflict> getConflicted(@Nullable String pathFilter) { return conflictsDb.getByPrefix(null, pathFilter); }
/** * Pass through to {@link StagingDatabase}, replacing the namespace with the transaction * namespace. */ @Override public void removeConflict(@Nullable String namespace, String path) { database.removeConflict(txNamespace, path); }
@Override public Set<String> findConflicts(@Nullable String namespace, Set<String> paths) { return database.findConflicts(txNamespace, paths); }
@Override public void addConflicts(@Nullable String namespace, Iterable<Conflict> conflicts) { database.addConflicts(txNamespace, conflicts); }
/** * Pass through to {@link StagingDatabase}, replacing the namespace with the transaction * namespace. */ @Override public List<Conflict> getConflicts(@Nullable String namespace, @Nullable String pathFilter) { return database.getConflicts(txNamespace, pathFilter); }
@Test public void testRemoveConflictsIterableNS() { final String ns = UUID.randomUUID().toString(); add(ns, c1, c2, c3); add(null, c1, c2, c3); conflicts.removeConflicts(ns, ImmutableList.of(c3.getPath(), c2.getPath())); assertTrue(conflicts.getConflict(ns, c1.getPath()).isPresent()); assertFalse(conflicts.getConflict(ns, c2.getPath()).isPresent()); assertFalse(conflicts.getConflict(ns, c3.getPath()).isPresent()); assertEquals(3, conflicts.getCountByPrefix(null, null)); }
@Test public void testGetCountByPrefix() { List<Conflict> rivers = createConflicts("rivers", 1555); List<Conflict> highways = createConflicts("roads/highways", 77); conflicts.addConflicts(null, rivers); conflicts.addConflicts("someTxId", highways); // create also conflict entries for the tree objects conflicts.addConflict(null, createTestConflict("rivers")); conflicts.addConflict("someTxId", createTestConflict("roads/highways")); assertEquals(0, conflicts.getCountByPrefix("someTxId", "rivers")); assertEquals(1 + rivers.size(), conflicts.getCountByPrefix(null, "rivers")); assertEquals(0, conflicts.getCountByPrefix(null, "highways")); assertEquals(1 + highways.size(), conflicts.getCountByPrefix("someTxId", "roads/highways")); }