usable"
This reverts commit 2670fd427c
.
By returning an instance of File from the ReceivePack.getPackFile the
abstraction of the persistence implementation was broken.
Change-Id: I28e3ebf3a659a7cbc94be51bba9e1ad338f2b786
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v3.3.0.201403021825-r
</message_arguments> | </message_arguments> | ||||
</filter> | </filter> | ||||
</resource> | </resource> | ||||
<resource path="src/org/eclipse/jgit/transport/BaseReceivePack.java" type="org.eclipse.jgit.transport.BaseReceivePack"> | |||||
<filter comment="Method is only used by those subclassing BaseReceivePack, minor version are allowed to break implementer API according to OSGi semantic versioning (http://www.osgi.org/wiki/uploads/Links/SemanticVersioning.pdf)" id="338792546"> | |||||
<message_arguments> | |||||
<message_argument value="org.eclipse.jgit.transport.BaseReceivePack"/> | |||||
<message_argument value="unlockPack()"/> | |||||
</message_arguments> | |||||
</filter> | |||||
</resource> | |||||
<resource path="src/org/eclipse/jgit/transport/TransportHttp.java" type="org.eclipse.jgit.transport.TransportHttp"> | <resource path="src/org/eclipse/jgit/transport/TransportHttp.java" type="org.eclipse.jgit.transport.TransportHttp"> | ||||
<filter comment="Method is only used by implementers of TransportHttp's API, minor version are allowed to break implementer API according to OSGi semantic versioning (http://www.osgi.org/wiki/uploads/Links/SemanticVersioning.pdf)" id="338792546"> | <filter comment="Method is only used by implementers of TransportHttp's API, minor version are allowed to break implementer API according to OSGi semantic versioning (http://www.osgi.org/wiki/uploads/Links/SemanticVersioning.pdf)" id="338792546"> | ||||
<message_arguments> | <message_arguments> |
public class PackLock { | public class PackLock { | ||||
private final File keepFile; | private final File keepFile; | ||||
private final FS fs; | private final FS fs; | ||||
private final File packFile; | |||||
/** | /** | ||||
* Create a new lock for a pack file. | * Create a new lock for a pack file. | ||||
final String n = packFile.getName(); | final String n = packFile.getName(); | ||||
keepFile = new File(p, n.substring(0, n.length() - 5) + ".keep"); //$NON-NLS-1$ | keepFile = new File(p, n.substring(0, n.length() - 5) + ".keep"); //$NON-NLS-1$ | ||||
this.fs = fs; | this.fs = fs; | ||||
this.packFile = packFile; | |||||
} | } | ||||
/** | /** | ||||
public void unlock() throws IOException { | public void unlock() throws IOException { | ||||
FileUtils.delete(keepFile); | FileUtils.delete(keepFile); | ||||
} | } | ||||
/** | |||||
* @return the pack file being held by this lock | |||||
*/ | |||||
public File getPackFile() { | |||||
return packFile; | |||||
} | |||||
} | } |
import static org.eclipse.jgit.transport.SideBandOutputStream.CH_PROGRESS; | import static org.eclipse.jgit.transport.SideBandOutputStream.CH_PROGRESS; | ||||
import static org.eclipse.jgit.transport.SideBandOutputStream.MAX_BUF; | import static org.eclipse.jgit.transport.SideBandOutputStream.MAX_BUF; | ||||
import java.io.File; | |||||
import java.io.EOFException; | import java.io.EOFException; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | import java.io.InputStream; | ||||
/** | /** | ||||
* Unlock the pack written by this object. | * Unlock the pack written by this object. | ||||
* | * | ||||
* @return the pack file that was unlocked, {@code null} if there was no | |||||
* lock | |||||
* @throws IOException | * @throws IOException | ||||
* the pack could not be unlocked. | * the pack could not be unlocked. | ||||
* @since 3.3 | |||||
*/ | */ | ||||
protected File unlockPack() throws IOException { | |||||
protected void unlockPack() throws IOException { | |||||
if (packLock != null) { | if (packLock != null) { | ||||
File packFile = packLock.getPackFile(); | |||||
packLock.unlock(); | packLock.unlock(); | ||||
packLock = null; | packLock = null; | ||||
return packFile; | |||||
} | } | ||||
return null; | |||||
} | } | ||||
/** | /** |
import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_REPORT_STATUS; | import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_REPORT_STATUS; | ||||
import java.io.File; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
private boolean echoCommandFailures; | private boolean echoCommandFailures; | ||||
/** The pack file that was created by this receive pack */ | |||||
private File packFile; | |||||
/** | /** | ||||
* Create a new pack receive for an open repository. | * Create a new pack receive for an open repository. | ||||
* | * | ||||
} | } | ||||
} | } | ||||
/** | |||||
* @return the pack file that was created by the | |||||
* {@link #receive(InputStream, OutputStream, OutputStream)} method | |||||
* @since 3.3 | |||||
*/ | |||||
public File getPackFile() { | |||||
return packFile; | |||||
} | |||||
@Override | @Override | ||||
protected void enableCapabilities() { | protected void enableCapabilities() { | ||||
reportStatus = isCapabilityEnabled(CAPABILITY_REPORT_STATUS); | reportStatus = isCapabilityEnabled(CAPABILITY_REPORT_STATUS); | ||||
preReceive.onPreReceive(this, filterCommands(Result.NOT_ATTEMPTED)); | preReceive.onPreReceive(this, filterCommands(Result.NOT_ATTEMPTED)); | ||||
executeCommands(); | executeCommands(); | ||||
} | } | ||||
packFile = unlockPack(); | |||||
unlockPack(); | |||||
if (reportStatus) { | if (reportStatus) { | ||||
if (echoCommandFailures && msgOut != null) { | if (echoCommandFailures && msgOut != null) { |