diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-09-16 17:22:37 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-09-16 17:22:37 -0700 |
commit | 5deb5b9a4aebd562a8680167dc6aee93fd7bb5c5 (patch) | |
tree | 3e963186d1f791e8f9f1a2f4113dd94652ea0846 /org.eclipse.jgit | |
parent | 55714f6e73c9f858eb17eadcb9df05de029017aa (diff) | |
parent | 26f507f0df5822df0f19a5ca16462a4bbfeab5fc (diff) | |
download | jgit-5deb5b9a4aebd562a8680167dc6aee93fd7bb5c5.tar.gz jgit-5deb5b9a4aebd562a8680167dc6aee93fd7bb5c5.zip |
Merge branch 'stable-0.9'
* stable-0.9:
Qualify post-0.9.3 builds
JGit 0.9.3
clone: Correct formatting of init message
Fix cloning of repositories with big objects
Qualify post-0.9.1 builds
JGit 0.9.1
Fix PlotCommitList to set lanes on child-less commits
Diffstat (limited to 'org.eclipse.jgit')
7 files changed, 158 insertions, 56 deletions
diff --git a/org.eclipse.jgit/META-INF/MANIFEST.MF b/org.eclipse.jgit/META-INF/MANIFEST.MF index 0c4d102e7f..d3c6055012 100644 --- a/org.eclipse.jgit/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit/META-INF/MANIFEST.MF @@ -2,32 +2,32 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Bundle-SymbolicName: org.eclipse.jgit -Bundle-Version: 0.9.0.qualifier +Bundle-Version: 0.9.4.qualifier Bundle-Localization: plugin Bundle-Vendor: %provider_name -Export-Package: org.eclipse.jgit;version="0.9.0", - org.eclipse.jgit.api;version="0.9.0", - org.eclipse.jgit.api.errors;version="0.9.0", - org.eclipse.jgit.diff;version="0.9.0", - org.eclipse.jgit.dircache;version="0.9.0", - org.eclipse.jgit.errors;version="0.9.0", - org.eclipse.jgit.events;version="0.9.0", - org.eclipse.jgit.fnmatch;version="0.9.0", - org.eclipse.jgit.ignore;version="0.9.0", - org.eclipse.jgit.lib;version="0.9.0", - org.eclipse.jgit.merge;version="0.9.0", - org.eclipse.jgit.nls;version="0.9.0", - org.eclipse.jgit.patch;version="0.9.0", - org.eclipse.jgit.revplot;version="0.9.0", - org.eclipse.jgit.revwalk;version="0.9.0", - org.eclipse.jgit.revwalk.filter;version="0.9.0", - org.eclipse.jgit.storage.file;version="0.9.0", - org.eclipse.jgit.storage.pack;version="0.9.0", - org.eclipse.jgit.transport;version="0.9.0", - org.eclipse.jgit.treewalk;version="0.9.0", - org.eclipse.jgit.treewalk.filter;version="0.9.0", - org.eclipse.jgit.util;version="0.9.0", - org.eclipse.jgit.util.io;version="0.9.0" +Export-Package: org.eclipse.jgit;version="0.9.4", + org.eclipse.jgit.api;version="0.9.4", + org.eclipse.jgit.api.errors;version="0.9.4", + org.eclipse.jgit.diff;version="0.9.4", + org.eclipse.jgit.dircache;version="0.9.4", + org.eclipse.jgit.errors;version="0.9.4", + org.eclipse.jgit.events;version="0.9.4", + org.eclipse.jgit.fnmatch;version="0.9.4", + org.eclipse.jgit.ignore;version="0.9.4", + org.eclipse.jgit.lib;version="0.9.4", + org.eclipse.jgit.merge;version="0.9.4", + org.eclipse.jgit.nls;version="0.9.4", + org.eclipse.jgit.patch;version="0.9.4", + org.eclipse.jgit.revplot;version="0.9.4", + org.eclipse.jgit.revwalk;version="0.9.4", + org.eclipse.jgit.revwalk.filter;version="0.9.4", + org.eclipse.jgit.storage.file;version="0.9.4", + org.eclipse.jgit.storage.pack;version="0.9.4", + org.eclipse.jgit.transport;version="0.9.4", + org.eclipse.jgit.treewalk;version="0.9.4", + org.eclipse.jgit.treewalk.filter;version="0.9.4", + org.eclipse.jgit.util;version="0.9.4", + org.eclipse.jgit.util.io;version="0.9.4" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle: com.jcraft.jsch;bundle-version="[0.1.37,0.2.0)" diff --git a/org.eclipse.jgit/pom.xml b/org.eclipse.jgit/pom.xml index fc8e72e8e4..0f6f12a23a 100644 --- a/org.eclipse.jgit/pom.xml +++ b/org.eclipse.jgit/pom.xml @@ -53,7 +53,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>0.9.0-SNAPSHOT</version> + <version>0.9.4-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit</artifactId> diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java index 55d0206c02..6ffa0336aa 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> + * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>, + * Copyright (C) 2010, Christian Halstrick <christian.halstrick@sap.com> * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -44,6 +45,7 @@ package org.eclipse.jgit.revplot; import java.text.MessageFormat; +import java.util.BitSet; import java.util.Collection; import java.util.HashSet; import java.util.TreeSet; @@ -68,17 +70,17 @@ public class PlotCommitList<L extends PlotLane> extends RevCommitList<PlotCommit<L>> { static final int MAX_LENGTH = 25; - private int lanesAllocated; + private int positionsAllocated; - private final TreeSet<Integer> freeLanes = new TreeSet<Integer>(); + private final TreeSet<Integer> freePositions = new TreeSet<Integer>(); private final HashSet<PlotLane> activeLanes = new HashSet<PlotLane>(32); @Override public void clear() { super.clear(); - lanesAllocated = 0; - freeLanes.clear(); + positionsAllocated = 0; + freePositions.clear(); activeLanes.clear(); } @@ -131,42 +133,104 @@ public class PlotCommitList<L extends PlotLane> extends c.lane = nextFreeLane(); activeLanes.add(c.lane); } - for (int r = index - 1; r >= 0; r--) { final PlotCommit rObj = get(r); if (rObj == c) break; rObj.addPassingLane(c.lane); } + currCommit.lane = c.lane; } else { // More than one child, or our child is a merge. // Use a different lane. // + // Process all our children. Especially important when there is more + // than one child (e.g. a commit is processed where other branches + // fork out). For each child the following is done + // 1. If no lane was assigned to the child a new lane is created and + // assigned + // 2. The lane of the child is closed. If this frees a position, + // this position will be added freePositions list. + // If we have multiple children which where previously not on a lane + // each such child will get his own new lane but all those new lanes + // will be on the same position. We have to take care that not + // multiple newly created (in step 1) lanes occupy that position on + // which the + // parent's lane will be on. Therefore we delay closing the lane + // with the parents position until all children are processed. + + // The lane on that position the current commit will be on + PlotLane reservedLane = null; + for (int i = 0; i < nChildren; i++) { final PlotCommit c = currCommit.children[i]; - if (activeLanes.remove(c.lane)) { - recycleLane((L) c.lane); - freeLanes.add(Integer.valueOf(c.lane.getPosition())); - } + // don't forget to position all of your children if they are + // not already positioned. + if (c.lane == null) { + c.lane = nextFreeLane(); + activeLanes.add(c.lane); + if (reservedLane != null) + closeLane(c.lane); + else + reservedLane = c.lane; + } else if (reservedLane == null && activeLanes.contains(c.lane)) + reservedLane = c.lane; + else + closeLane(c.lane); } + // finally all children are processed. We can close the lane on that + // position our current commit will be on. + if (reservedLane != null) + closeLane(reservedLane); + currCommit.lane = nextFreeLane(); activeLanes.add(currCommit.lane); + // take care: when connecting yourself to your child make sure that + // you will not be located on a lane on which a passed commit is + // located on. Otherwise we would have to draw a line through a + // commit. int remaining = nChildren; + BitSet blockedPositions = new BitSet(); for (int r = index - 1; r >= 0; r--) { final PlotCommit rObj = get(r); if (currCommit.isChild(rObj)) { if (--remaining == 0) break; } - rObj.addPassingLane(currCommit.lane); + if (rObj != null) { + PlotLane lane = rObj.getLane(); + if (lane != null) + blockedPositions.set(lane.getPosition()); + rObj.addPassingLane(currCommit.lane); + } + } + // Now let's check whether we have to reposition the lane + if (blockedPositions.get(currCommit.lane.getPosition())) { + int newPos = -1; + for (Integer pos : freePositions) + if (!blockedPositions.get(pos)) { + newPos = pos; + break; + } + if (newPos == -1) + newPos = positionsAllocated++; + freePositions.add(currCommit.lane.getPosition()); + currCommit.lane.position = newPos; } } } + private void closeLane(PlotLane lane) { + recycleLane((L) lane); + if (activeLanes.remove(lane)) { + freePositions.add(Integer.valueOf(lane.getPosition())); + } + } + private void setupChildren(final PlotCommit<L> currCommit) { final int nParents = currCommit.getParentCount(); for (int i = 0; i < nParents; i++) @@ -175,12 +239,12 @@ public class PlotCommitList<L extends PlotLane> extends private PlotLane nextFreeLane() { final PlotLane p = createLane(); - if (freeLanes.isEmpty()) { - p.position = lanesAllocated++; + if (freePositions.isEmpty()) { + p.position = positionsAllocated++; } else { - final Integer min = freeLanes.first(); + final Integer min = freePositions.first(); p.position = min.intValue(); - freeLanes.remove(min); + freePositions.remove(min); } return p; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/CachedObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/CachedObjectDirectory.java index f0159f626f..a5762b61ee 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/CachedObjectDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/CachedObjectDirectory.java @@ -213,8 +213,22 @@ class CachedObjectDirectory extends FileObjectDatabase { } @Override - boolean insertUnpackedObject(File tmp, ObjectId objectId, boolean force) { - return wrapped.insertUnpackedObject(tmp, objectId, force); + InsertLooseObjectResult insertUnpackedObject(File tmp, ObjectId objectId, + boolean createDuplicate) { + InsertLooseObjectResult result = wrapped.insertUnpackedObject(tmp, + objectId, createDuplicate); + switch (result) { + case INSERTED: + case EXISTS_LOOSE: + if (!unpackedObjects.contains(objectId)) + unpackedObjects.add(objectId); + break; + + case EXISTS_PACKED: + case FAILURE: + break; + } + return result; } @Override diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileObjectDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileObjectDatabase.java index 29c7a25312..8bd3751010 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileObjectDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileObjectDatabase.java @@ -57,6 +57,10 @@ import org.eclipse.jgit.storage.pack.ObjectToPack; import org.eclipse.jgit.storage.pack.PackWriter; abstract class FileObjectDatabase extends ObjectDatabase { + static enum InsertLooseObjectResult { + INSERTED, EXISTS_PACKED, EXISTS_LOOSE, FAILURE; + } + @Override public ObjectReader newReader() { return new WindowCursor(this); @@ -249,7 +253,8 @@ abstract class FileObjectDatabase extends ObjectDatabase { abstract long getObjectSize2(WindowCursor curs, String objectName, AnyObjectId objectId) throws IOException; - abstract boolean insertUnpackedObject(File tmp, ObjectId id, boolean force); + abstract InsertLooseObjectResult insertUnpackedObject(File tmp, + ObjectId id, boolean createDuplicate); abstract FileObjectDatabase newCachedFileObjectDatabase(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectory.java index 372a97813e..e7ccba0820 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectory.java @@ -455,23 +455,33 @@ public class ObjectDirectory extends FileObjectDatabase { } @Override - boolean insertUnpackedObject(File tmp, ObjectId id, boolean force) { - if (!force && has(id)) { - // Object is already in the repository, remove temporary file. - // + InsertLooseObjectResult insertUnpackedObject(File tmp, ObjectId id, + boolean createDuplicate) { + // If the object is already in the repository, remove temporary file. + // + if (unpackedObjectCache.isUnpacked(id)) { tmp.delete(); - return true; + return InsertLooseObjectResult.EXISTS_LOOSE; } + if (!createDuplicate && has(id)) { + tmp.delete(); + return InsertLooseObjectResult.EXISTS_PACKED; + } + tmp.setReadOnly(); final File dst = fileFor(id); - if (force && dst.exists()) { + if (dst.exists()) { + // We want to be extra careful and avoid replacing an object + // that already exists. We can't be sure renameTo() would + // fail on all platforms if dst exists, so we check first. + // tmp.delete(); - return true; + return InsertLooseObjectResult.EXISTS_LOOSE; } if (tmp.renameTo(dst)) { unpackedObjectCache.add(id); - return true; + return InsertLooseObjectResult.INSERTED; } // Maybe the directory doesn't exist yet as the object @@ -481,12 +491,12 @@ public class ObjectDirectory extends FileObjectDatabase { dst.getParentFile().mkdir(); if (tmp.renameTo(dst)) { unpackedObjectCache.add(id); - return true; + return InsertLooseObjectResult.INSERTED; } - if (!force && has(id)) { + if (!createDuplicate && has(id)) { tmp.delete(); - return true; + return InsertLooseObjectResult.EXISTS_PACKED; } // The object failed to be renamed into its proper @@ -495,7 +505,7 @@ public class ObjectDirectory extends FileObjectDatabase { // fail. // tmp.delete(); - return false; + return InsertLooseObjectResult.FAILURE; } boolean tryAgain1() { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectoryInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectoryInserter.java index d92285de8c..074ebb9617 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectoryInserter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectoryInserter.java @@ -83,9 +83,18 @@ class ObjectDirectoryInserter extends ObjectInserter { final MessageDigest md = digest(); final File tmp = toTemp(md, type, len, is); final ObjectId id = ObjectId.fromRaw(md.digest()); - if (db.insertUnpackedObject(tmp, id, false /* no duplicate */)) + + switch (db.insertUnpackedObject(tmp, id, false /* no duplicate */)) { + case INSERTED: + case EXISTS_PACKED: + case EXISTS_LOOSE: return id; + case FAILURE: + default: + break; + } + final File dst = db.fileFor(id); throw new ObjectWritingException("Unable to create new object: " + dst); } |