/** {@inheritDoc} */ @Override public BatchRefUpdate newBatchUpdate() { DfsObjDatabase odb = getRepository().getObjectDatabase(); return new ReftableBatchRefUpdate(this, odb); }
/** * Get configuration to write new reftables with. * * @return configuration to write new reftables with. */ public ReftableConfig getReftableConfig() { return new ReftableConfig(getRepository().getConfig()); }
@Override boolean exists() throws IOException { DfsObjDatabase odb = getRepository().getObjectDatabase(); return odb.getReftables().length > 0; }
/** * Obtain a handle to the stack of reftables. * * @return (possibly cached) handle to the stack. * @throws java.io.IOException * if tables cannot be opened. */ protected ReftableStack stack() throws IOException { lock.lock(); try { if (tableStack == null) { DfsObjDatabase odb = getRepository().getObjectDatabase(); if (ctx == null) { ctx = odb.newReader(); } tableStack = ReftableStack.open(ctx, Arrays.asList(odb.getReftables())); } return tableStack; } finally { lock.unlock(); } }
private void writeLog(ReftableWriter writer, long updateIndex, List<ReceiveCommand> pending) throws IOException { Map<String, ReceiveCommand> cmds = new HashMap<>(); List<String> byName = new ArrayList<>(pending.size()); for (ReceiveCommand cmd : pending) { cmds.put(cmd.getRefName(), cmd); byName.add(cmd.getRefName()); } Collections.sort(byName); PersonIdent ident = getRefLogIdent(); if (ident == null) { ident = new PersonIdent(refdb.getRepository()); } for (String name : byName) { ReceiveCommand cmd = cmds.get(name); if (isRefLogDisabled(cmd)) { continue; } String msg = getRefLogMessage(cmd); if (isRefLogIncludingResult(cmd)) { String strResult = toResultString(cmd); if (strResult != null) { msg = msg.isEmpty() ? strResult : msg + ": " + strResult; //$NON-NLS-1$ } } writer.writeLog(name, updateIndex, ident, cmd.getOldId(), cmd.getNewId(), msg); } }
/** {@inheritDoc} */ @Override protected boolean compareAndPut(Ref oldRef, @Nullable Ref newRef) throws IOException { ReceiveCommand cmd = toCommand(oldRef, newRef); try (RevWalk rw = new RevWalk(getRepository())) { newBatchUpdate().setAllowNonFastForwards(true).addCommand(cmd) .execute(rw, NullProgressMonitor.INSTANCE); } switch (cmd.getResult()) { case OK: return true; case REJECTED_OTHER_REASON: throw new IOException(cmd.getMessage()); case LOCK_FAILURE: default: return false; } }
@Override boolean exists() throws IOException { DfsObjDatabase odb = getRepository().getObjectDatabase(); return odb.getReftables().length > 0; }
/** {@inheritDoc} */ @Override public BatchRefUpdate newBatchUpdate() { DfsObjDatabase odb = getRepository().getObjectDatabase(); return new ReftableBatchRefUpdate(this, odb); }
/** * Get configuration to write new reftables with. * * @return configuration to write new reftables with. */ public ReftableConfig getReftableConfig() { return new ReftableConfig(getRepository().getConfig()); }
/** * Obtain a handle to the stack of reftables. * * @return (possibly cached) handle to the stack. * @throws java.io.IOException * if tables cannot be opened. */ protected ReftableStack stack() throws IOException { lock.lock(); try { if (tableStack == null) { DfsObjDatabase odb = getRepository().getObjectDatabase(); if (ctx == null) { ctx = odb.newReader(); } tableStack = ReftableStack.open(ctx, Arrays.asList(odb.getReftables())); } return tableStack; } finally { lock.unlock(); } }
private void writeLog(ReftableWriter writer, long updateIndex, List<ReceiveCommand> pending) throws IOException { Map<String, ReceiveCommand> cmds = new HashMap<>(); List<String> byName = new ArrayList<>(pending.size()); for (ReceiveCommand cmd : pending) { cmds.put(cmd.getRefName(), cmd); byName.add(cmd.getRefName()); } Collections.sort(byName); PersonIdent ident = getRefLogIdent(); if (ident == null) { ident = new PersonIdent(refdb.getRepository()); } for (String name : byName) { ReceiveCommand cmd = cmds.get(name); if (isRefLogDisabled(cmd)) { continue; } String msg = getRefLogMessage(cmd); if (isRefLogIncludingResult(cmd)) { String strResult = toResultString(cmd); if (strResult != null) { msg = msg.isEmpty() ? strResult : msg + ": " + strResult; //$NON-NLS-1$ } } writer.writeLog(name, updateIndex, ident, cmd.getOldId(), cmd.getNewId(), msg); } }
/** {@inheritDoc} */ @Override protected boolean compareAndPut(Ref oldRef, @Nullable Ref newRef) throws IOException { ReceiveCommand cmd = toCommand(oldRef, newRef); try (RevWalk rw = new RevWalk(getRepository())) { newBatchUpdate().setAllowNonFastForwards(true).addCommand(cmd) .execute(rw, NullProgressMonitor.INSTANCE); } switch (cmd.getResult()) { case OK: return true; case REJECTED_OTHER_REASON: throw new IOException(cmd.getMessage()); case LOCK_FAILURE: default: return false; } }