Browse Source

Add a Merger.merge method that makes flushing optional

This allows callers performing multiple separate merges to reuse a
single ObjectInserter without flushing the inserter on each iteration
(which can be slow in the DFS case).

Change-Id: Icaff7d2bc2c20c873ce5a7d9af5002da84ae1c2b
stable-3.5
Dave Borowitz 12 years ago committed by Shawn Pearce
parent
commit
8ea4319388
  1. 34
      org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java

34
org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java

@ -153,6 +153,35 @@ public abstract class Merger {
* be written to the Repository.
*/
public boolean merge(final AnyObjectId... tips) throws IOException {
return merge(true, tips);
}
/**
* Merge together two or more tree-ish objects.
* <p>
* Any tree-ish may be supplied as inputs. Commits and/or tags pointing at
* trees or commits may be passed as input objects.
*
* @since 3.5
* @param flush
* whether to flush the underlying object inserter when finished to
* store any content-merged blobs and virtual merged bases; if
* false, callers are responsible for flushing.
* @param tips
* source trees to be combined together. The merge base is not
* included in this set.
* @return true if the merge was completed without conflicts; false if the
* merge strategy cannot handle this merge or there were conflicts
* preventing it from automatically resolving all paths.
* @throws IncorrectObjectTypeException
* one of the input objects is not a commit, but the strategy
* requires it to be a commit.
* @throws IOException
* one or more sources could not be read, or outputs could not
* be written to the Repository.
*/
public boolean merge(final boolean flush, final AnyObjectId... tips)
throws IOException {
sourceObjects = new RevObject[tips.length];
for (int i = 0; i < tips.length; i++)
sourceObjects[i] = walk.parseAny(tips[i]);
@ -172,11 +201,12 @@ public abstract class Merger {
try {
boolean ok = mergeImpl();
if (ok)
if (ok && flush)
inserter.flush();
return ok;
} finally {
inserter.release();
if (flush)
inserter.release();
reader.release();
}
}

Loading…
Cancel
Save