Class ClientMergeState
java.lang.Object
com.perforce.p4java.impl.mapbased.rpc.func.client.ClientMergeState
Helper class for carrying useful merge state around during the various merge
operations defined in ClientMerge. Modeled somewhat on the C++ API's
clientmerge3.cc object, but tuned more to our more limited purposes.
Also includes support for two-way merge, but this is currently less-well
exercised and tested.
Note: not particularly thread-safe, nor intended to be.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedClientMergeState(String clientPath, boolean externalStreamMerge, RpcPerforceFileType clientType, ClientLineEnding clientLineEnding, RpcPerforceFileType resultType, ClientLineEnding resultLineEnding, String tmpDir, Charset charset) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCloses all merge tmp-file streams, swallowing any IOException.protected booleanfinishMerge(ClientMerge.ResolveChoice choice) protected Stringprotected Stringprotected RpcPerforceFileprotected Stringprotected RpcOutputStreamprotected intgetBits()protected intprotected Stringprotected intprotected Stringprotected Stringprotected intprotected RpcPerforceFileprotected RpcOutputStreamprotected intprotected Stringprotected Stringprotected RpcPerforceFileprotected Stringprotected RpcOutputStreamprotected Stringprotected intprotected Stringprotected Stringprotected RpcPerforceFileprotected Stringprotected RpcOutputStreamprotected intprotected intprotected intprotected intprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected voidopenMergeFiles(RpcConnection rpcConnection) Open and / or create the necessary files for this merge.protected voidsetAutoMerge(boolean autoMerge) protected voidsetBaseDigest(String baseDigest) protected voidsetBaseName(String baseName) protected voidsetBaseTmpFile(RpcPerforceFile baseTmpFile) protected voidsetBaseTmpFilename(String baseTmpFilename) protected voidsetBaseTmpFileStream(RpcOutputStream baseTmpFileStream) protected voidsetBits(int bits) protected voidsetBothChunks(int bothChunks) protected voidsetClientPath(String clientPath) protected voidsetConflictChunks(int conflictChunks) protected voidsetExternalStreamMerge(boolean externalStreamMerge) protected voidsetExternalTmpFilename(String externalTmpFilename) protected voidsetOldBits(int oldBits) protected voidsetResultTmpFile(RpcPerforceFile resultTmpFile) protected voidsetResultTmpFileStream(RpcOutputStream resultTmpFileStream) protected voidsetSafeMerge(boolean safeMerge) protected voidsetShowAll(boolean showAll) protected voidsetTheirChunks(int theirChunks) protected voidsetTheirName(String theirName) protected voidsetTheirTmpFile(RpcPerforceFile theirTmpFile) protected voidsetTheirTmpFilename(String theirTmpFilename) protected voidsetTheirTmpFileStream(RpcOutputStream theirTmpFileStream) protected voidprotected voidsetTwoWayMerge(boolean twoWayMerge) protected voidsetYourChunks(int yourChunks) protected voidsetYourName(String yourName) protected voidsetYourTmpFile(RpcPerforceFile yourTmpFile) protected voidsetYourTmpFilename(String yourTmpFilename) protected voidsetYourTmpFileStream(RpcOutputStream yourTmpFileStream) protected intprotected voidwriteBaseChunk(byte[] bytes) protected voidwriteMarker(String markerString) protected voidwriteResultChunk(byte[] bytes) protected voidwriteTheirChunk(byte[] bytes) protected voidwriteYourChunk(byte[] bytes)
-
Field Details
-
TRACE_PREFIX
- See Also:
-
DEFAULT_TMPFILE_PFX
- See Also:
-
DEFAULT_TMPFILE_SFX
- See Also:
-
twoWayMerge
protected boolean twoWayMerge -
baseDigest
-
-
Constructor Details
-
ClientMergeState
protected ClientMergeState(String clientPath, boolean externalStreamMerge, RpcPerforceFileType clientType, ClientLineEnding clientLineEnding, RpcPerforceFileType resultType, ClientLineEnding resultLineEnding, String tmpDir, Charset charset) - Parameters:
clientPath- clientPathexternalStreamMerge- set true if this is a merge from an external streamclientType- clientTypeclientLineEnding- clientLineEndingresultType- resultTyperesultLineEnding- resultLineEndingtmpDir- the name of a suitable directory for creating temporary files incharset- charset
-
-
Method Details
-
openMergeFiles
Open and / or create the necessary files for this merge. The "yours" file is the original client file, and doesn't need opening. The rest are opened as tmp files in the system tmp directory; this isn't exactly the same as the C++ API's behaviour (which opens them in the target directory) but it should be fairly safe.Note that the file types for each file are copied from the C++ API usage; I'm not entirely sure this arrangement always make sense...
- Parameters:
rpcConnection- rpcConnection- Throws:
IOException- if there's been a problem opening any of the files.
-
writeMarker
protected void writeMarker(String markerString) throws IOException, FileDecoderException, FileEncoderException -
writeBaseChunk
protected void writeBaseChunk(byte[] bytes) throws IOException, FileDecoderException, FileEncoderException -
writeTheirChunk
protected void writeTheirChunk(byte[] bytes) throws IOException, FileDecoderException, FileEncoderException -
writeYourChunk
- Throws:
IOException
-
writeResultChunk
protected void writeResultChunk(byte[] bytes) throws IOException, FileDecoderException, FileEncoderException -
finishMerge
- Throws:
IOException
-
getMergeDigestString
-
getTheirDigestString
-
getYourDigestString
-
incrYourChunks
protected int incrYourChunks() -
theirYourChunks
protected int theirYourChunks() -
incrConflictChunks
protected int incrConflictChunks() -
incrTheirChunks
protected int incrTheirChunks() -
incrBothChunks
protected int incrBothChunks() -
getClientPath
-
setClientPath
-
getBaseName
-
setBaseName
-
getTheirName
-
setTheirName
-
getYourName
-
setYourName
-
getBaseTmpFilename
-
setBaseTmpFilename
-
getTheirTmpFilename
-
setTheirTmpFilename
-
getYourTmpFilename
-
setYourTmpFilename
-
getBaseTmpFile
-
setBaseTmpFile
-
getTheirTmpFile
-
setTheirTmpFile
-
getYourTmpFile
-
setYourTmpFile
-
getBaseTmpFileStream
-
setBaseTmpFileStream
-
getYourTmpFileStream
-
setYourTmpFileStream
-
getTheirTmpFileStream
-
setTheirTmpFileStream
-
getYourChunks
protected int getYourChunks() -
setYourChunks
protected void setYourChunks(int yourChunks) -
getTheirChunks
protected int getTheirChunks() -
setTheirChunks
protected void setTheirChunks(int theirChunks) -
getConflictChunks
protected int getConflictChunks() -
setConflictChunks
protected void setConflictChunks(int conflictChunks) -
getBothChunks
protected int getBothChunks() -
setBothChunks
protected void setBothChunks(int bothChunks) -
getBits
protected int getBits() -
setBits
protected void setBits(int bits) -
getOldBits
protected int getOldBits() -
setOldBits
protected void setOldBits(int oldBits) -
getTmpDir
-
setTmpDir
-
isExternalStreamMerge
protected boolean isExternalStreamMerge() -
setExternalStreamMerge
protected void setExternalStreamMerge(boolean externalStreamMerge) -
getExternalTmpFilename
-
setExternalTmpFilename
-
getResultTmpFile
-
setResultTmpFile
-
getResultTmpFileStream
-
setResultTmpFileStream
-
closeStreams
protected void closeStreams()Closes all merge tmp-file streams, swallowing any IOException. Null-safe and idempotent, so it is safe to call from every cleanup path. -
isSafeMerge
protected boolean isSafeMerge() -
setSafeMerge
protected void setSafeMerge(boolean safeMerge) -
isAutoMerge
protected boolean isAutoMerge() -
setAutoMerge
protected void setAutoMerge(boolean autoMerge) -
isShowAll
protected boolean isShowAll() -
setShowAll
protected void setShowAll(boolean showAll) -
isTwoWayMerge
protected boolean isTwoWayMerge() -
setTwoWayMerge
protected void setTwoWayMerge(boolean twoWayMerge) -
getBaseDigest
-
setBaseDigest
-