@Override public void flush() throws IOException { delegate().flush(); }
/** * Insert a single object into the store, returning its unique name. * * @param type * type code of the object to store. * @param data * complete content of the object. * @return the name of the object. * @throws java.io.IOException * the object could not be stored. */ public ObjectId insert(int type, byte[] data) throws IOException { return insert(type, data, 0, data.length); }
/** * Performs the merge. * * @param base * base version of the note tree * @param ours * ours version of the note tree * @param theirs * theirs version of the note tree * @return merge result as a new NoteMap * @throws java.io.IOException */ public NoteMap merge(NoteMap base, NoteMap ours, NoteMap theirs) throws IOException { try { InMemoryNoteBucket mergedBucket = merge(0, base.getRoot(), ours.getRoot(), theirs.getRoot()); inserter.flush(); return NoteMap.newMap(mergedBucket, reader); } finally { reader.close(); inserter.close(); } }
/** * Set the inserter this merger will use to create objects. * <p> * If an inserter was already set on this instance (such as by a prior set, * or a prior call to {@link #getObjectInserter()}), the prior inserter as * well as the in-progress walk will be released. * * @param oi * the inserter instance to use. Must be associated with the * repository instance returned by {@link #getRepository()} (if a * repository was provided). Will be closed at the conclusion of * {@code merge}, unless {@code flush} is false. */ public void setObjectInserter(ObjectInserter oi) { walk.close(); reader.close(); inserter.close(); inserter = oi; reader = oi.newReader(); walk = new RevWalk(reader); }
private void receivePack(final ProgressMonitor monitor, OutputStream outputStream) throws IOException { onReceivePack(); InputStream input = in; if (sideband) input = new SideBandInputStream(input, monitor, getMessageWriter(), outputStream); try (ObjectInserter ins = local.newObjectInserter()) { PackParser parser = ins.newPackParser(input); parser.setAllowThin(thinPack); parser.setObjectChecker(transport.getObjectChecker()); parser.setLockMessage(lockMessage); packLock = parser.parse(monitor); ins.flush(); } }
static void commitNoteMap(Repository r, String ref, RevWalk walk, NoteMap map, RevCommit notesCommit, ObjectInserter inserter, String msg) throws IOException { // commit the note CommitBuilder builder = new CommitBuilder(); builder.setTreeId(map.writeTree(inserter)); builder.setAuthor(new PersonIdent(r)); builder.setCommitter(builder.getAuthor()); builder.setMessage(msg); if (notesCommit != null) builder.setParentIds(notesCommit); ObjectId commit = inserter.insert(builder); inserter.flush(); RefUpdate refUpdate = r.updateRef(ref); if (notesCommit != null) refUpdate.setExpectedOldObjectId(notesCommit); else refUpdate.setExpectedOldObjectId(ObjectId.zeroId()); refUpdate.setNewObjectId(commit); refUpdate.update(walk); }
/** * Create a new blob object in the repository. * * @param content * binary file content. * @return reference to the blob. * @throws Exception */ public RevBlob blob(final byte[] content) throws Exception { ObjectId id; try { id = inserter.insert(Constants.OBJ_BLOB, content); inserter.flush(); } finally { inserter.release(); } return pool.lookupBlob(id); }
private ObjectId storeBlob(GitBranchData gbd, String path, long contentLength, long propContentLength) { try { long adjustedContentLength = contentLength - propContentLength; if (propContentLength > 0) { getInputStream().skip(propContentLength); } /* * We want to replace the contents of the path file with the content * that we read from the input stream. */ ObjectInserter objectInserter = repo.newObjectInserter(); ObjectId id = objectInserter.insert(Constants.OBJ_BLOB, adjustedContentLength, new BoundedInputStream( getInputStream(), adjustedContentLength)); objectInserter.flush(); objectInserter.close(); return id; } catch (Exception e) { log.error("onNodeContentChanged failed: ", e); throw new RuntimeException("onNodeContentLength failed", e); } }
@Override protected void run() throws Exception { BufferedInputStream in = new BufferedInputStream(ins); ObjectInserter inserter = db.newObjectInserter(); try { PackParser p = inserter.newPackParser(in); p.setAllowThin(fixThin); if (indexVersion != -1 && p instanceof ObjectDirectoryPackParser) { ObjectDirectoryPackParser imp = (ObjectDirectoryPackParser) p; imp.setIndexVersion(indexVersion); } p.parse(new TextProgressMonitor()); inserter.flush(); } finally { inserter.release(); } } }
/** * Construct a tree from a specific listing of file entries. * * @param entries * the files to include in the tree. The collection does not need * to be sorted properly and may be empty. * @return reference to the tree specified by the entry list. * @throws Exception */ public RevTree tree(final DirCacheEntry... entries) throws Exception { final DirCache dc = DirCache.newInCore(); final DirCacheBuilder b = dc.builder(); for (final DirCacheEntry e : entries) b.add(e); b.finish(); ObjectId root; try { root = dc.writeTree(inserter); inserter.flush(); } finally { inserter.release(); } return pool.lookupTree(root); }
@Override public void close() { delegate().close(); } }
@Override public PackParser newPackParser(InputStream in) throws IOException { return delegate().newPackParser(in); }
private boolean apply(List<Command> todo) throws IOException { if (!tree.apply(todo)) { // apply set rejection information on commands. return false; } Repository repo = refdb.getRepository(); try (ObjectInserter ins = repo.newObjectInserter()) { CommitBuilder b = new CommitBuilder(); b.setTreeId(tree.writeTree(ins)); if (parentTreeId.equals(b.getTreeId())) { for (Command c : todo) { c.setResult(OK); } return true; } if (!parentCommitId.equals(ObjectId.zeroId())) { b.setParentId(parentCommitId); } author = getRefLogIdent(); if (author == null) { author = new PersonIdent(repo); } b.setAuthor(author); b.setCommitter(author); b.setMessage(getRefLogMessage()); newCommitId = ins.insert(b); ins.flush(); } return true; }
/** {@inheritDoc} */ @Override protected void doFetch(final ProgressMonitor monitor, final Collection<Ref> want, final Set<ObjectId> have) throws TransportException { verifyPrerequisites(); try { try (ObjectInserter ins = transport.local.newObjectInserter()) { PackParser parser = ins.newPackParser(bin); parser.setAllowThin(true); parser.setObjectChecker(transport.getObjectChecker()); parser.setLockMessage(lockMessage); packLock = parser.parse(NullProgressMonitor.INSTANCE); ins.flush(); } } catch (IOException err) { close(); throw new TransportException(transport.uri, err.getMessage(), err); } catch (RuntimeException err) { close(); throw new TransportException(transport.uri, err.getMessage(), err); } }
/** {@inheritDoc} */ @Override public void close() { inserter.close(); reader.close(); for (RemotePack p : unfetchedPacks) { if (p.tmpIdx != null) p.tmpIdx.delete(); } for (WalkRemoteObjectDatabase r : remotes) r.close(); }
/** * Set the inserter this merger will use to create objects. * <p> * If an inserter was already set on this instance (such as by a prior set, * or a prior call to {@link #getObjectInserter()}), the prior inserter as * well as the in-progress walk will be released. * * @param oi * the inserter instance to use. Must be associated with the * repository instance returned by {@link #getRepository()}. */ public void setObjectInserter(ObjectInserter oi) { walk.close(); reader.close(); inserter.close(); inserter = oi; reader = oi.newReader(); walk = new RevWalk(reader); }
void downloadPack(ProgressMonitor monitor) throws IOException { String name = "pack/" + packName; //$NON-NLS-1$ WalkRemoteObjectDatabase.FileStream s = connection.open(name); try { PackParser parser = inserter.newPackParser(s.in); parser.setAllowThin(false); parser.setObjectChecker(objCheck); parser.setLockMessage(lockMessage); PackLock lock = parser.parse(monitor); if (lock != null) packLocks.add(lock); } finally { s.in.close(); } } }
RemoteFile rf = callback.readFileWithMode( url, proj.getRevision(), copyfile.src); objectId = inserter.insert(Constants.OBJ_BLOB, rf.getContents()); dcEntry = new DirCacheEntry(copyfile.dest); objectId = inserter.insert(Constants.OBJ_BLOB, link.getBytes(UTF_8)); dcEntry = new DirCacheEntry(linkfile.dest); ObjectId objectId = inserter.insert(Constants.OBJ_BLOB, content.getBytes(UTF_8)); dcEntry.setObjectId(objectId); ObjectId attrId = inserter.insert(Constants.OBJ_BLOB, attributes.toString().getBytes(UTF_8)); dcEntryAttr.setObjectId(attrId); commit.setMessage(RepoText.get().repoCommitMessage); ObjectId commitId = inserter.insert(commit); inserter.flush();
/** * Insert a single object into the store, returning its unique name. * * @param type * type code of the object to store. * @param data * complete content of the object. * @param off * first position within {@code data}. * @param len * number of bytes to copy from {@code data}. * @return the name of the object. * @throws java.io.IOException * the object could not be stored. */ public ObjectId insert(int type, byte[] data, int off, int len) throws IOException { return insert(type, len, new ByteArrayInputStream(data, off, len)); }