Class ClientMergeState
- java.lang.Object
-
- com.perforce.p4java.impl.mapbased.rpc.func.client.ClientMergeState
-
public class ClientMergeState extends java.lang.ObjectHelper 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 Modifier and Type Field Description protected java.lang.StringbaseDigeststatic java.lang.StringDEFAULT_TMPFILE_PFXstatic java.lang.StringDEFAULT_TMPFILE_SFXstatic java.lang.StringTRACE_PREFIXprotected booleantwoWayMerge
-
Constructor Summary
Constructors Modifier Constructor Description protectedClientMergeState(java.lang.String clientPath, boolean externalStreamMerge, RpcPerforceFileType clientType, ClientLineEnding clientLineEnding, RpcPerforceFileType resultType, ClientLineEnding resultLineEnding, java.lang.String tmpDir, java.nio.charset.Charset charset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanfinishMerge(ClientMerge.ResolveChoice choice)protected java.lang.StringgetBaseDigest()protected java.lang.StringgetBaseName()protected RpcPerforceFilegetBaseTmpFile()protected java.lang.StringgetBaseTmpFilename()protected RpcOutputStreamgetBaseTmpFileStream()protected intgetBits()protected intgetBothChunks()protected java.lang.StringgetClientPath()protected intgetConflictChunks()protected java.lang.StringgetExternalTmpFilename()protected java.lang.StringgetMergeDigestString()protected intgetOldBits()protected RpcPerforceFilegetResultTmpFile()protected RpcOutputStreamgetResultTmpFileStream()protected intgetTheirChunks()protected java.lang.StringgetTheirDigestString()protected java.lang.StringgetTheirName()protected RpcPerforceFilegetTheirTmpFile()protected java.lang.StringgetTheirTmpFilename()protected RpcOutputStreamgetTheirTmpFileStream()protected java.lang.StringgetTmpDir()protected intgetYourChunks()protected java.lang.StringgetYourDigestString()protected java.lang.StringgetYourName()protected RpcPerforceFilegetYourTmpFile()protected java.lang.StringgetYourTmpFilename()protected RpcOutputStreamgetYourTmpFileStream()protected intincrBothChunks()protected intincrConflictChunks()protected intincrTheirChunks()protected intincrYourChunks()protected booleanisAutoMerge()protected booleanisExternalStreamMerge()protected booleanisSafeMerge()protected booleanisShowAll()protected booleanisTwoWayMerge()protected voidopenMergeFiles(RpcConnection rpcConnection)Open and / or create the necessary files for this merge.protected voidsetAutoMerge(boolean autoMerge)protected voidsetBaseDigest(java.lang.String baseDigest)protected voidsetBaseName(java.lang.String baseName)protected voidsetBaseTmpFile(RpcPerforceFile baseTmpFile)protected voidsetBaseTmpFilename(java.lang.String baseTmpFilename)protected voidsetBaseTmpFileStream(RpcOutputStream baseTmpFileStream)protected voidsetBits(int bits)protected voidsetBothChunks(int bothChunks)protected voidsetClientPath(java.lang.String clientPath)protected voidsetConflictChunks(int conflictChunks)protected voidsetExternalStreamMerge(boolean externalStreamMerge)protected voidsetExternalTmpFilename(java.lang.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(java.lang.String theirName)protected voidsetTheirTmpFile(RpcPerforceFile theirTmpFile)protected voidsetTheirTmpFilename(java.lang.String theirTmpFilename)protected voidsetTheirTmpFileStream(RpcOutputStream theirTmpFileStream)protected voidsetTmpDir(java.lang.String tmpDir)protected voidsetTwoWayMerge(boolean twoWayMerge)protected voidsetYourChunks(int yourChunks)protected voidsetYourName(java.lang.String yourName)protected voidsetYourTmpFile(RpcPerforceFile yourTmpFile)protected voidsetYourTmpFilename(java.lang.String yourTmpFilename)protected voidsetYourTmpFileStream(RpcOutputStream yourTmpFileStream)protected inttheirYourChunks()protected voidwriteBaseChunk(byte[] bytes)protected voidwriteMarker(java.lang.String markerString)protected voidwriteResultChunk(byte[] bytes)protected voidwriteTheirChunk(byte[] bytes)protected voidwriteYourChunk(byte[] bytes)
-
-
-
Field Detail
-
TRACE_PREFIX
public static final java.lang.String TRACE_PREFIX
- See Also:
- Constant Field Values
-
DEFAULT_TMPFILE_PFX
public static final java.lang.String DEFAULT_TMPFILE_PFX
- See Also:
- Constant Field Values
-
DEFAULT_TMPFILE_SFX
public static final java.lang.String DEFAULT_TMPFILE_SFX
- See Also:
- Constant Field Values
-
twoWayMerge
protected boolean twoWayMerge
-
baseDigest
protected java.lang.String baseDigest
-
-
Constructor Detail
-
ClientMergeState
protected ClientMergeState(java.lang.String clientPath, boolean externalStreamMerge, RpcPerforceFileType clientType, ClientLineEnding clientLineEnding, RpcPerforceFileType resultType, ClientLineEnding resultLineEnding, java.lang.String tmpDir, java.nio.charset.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 Detail
-
openMergeFiles
protected void openMergeFiles(RpcConnection rpcConnection) throws java.io.IOException
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:
java.io.IOException- if there's been a problem opening any of the files.
-
writeMarker
protected void writeMarker(java.lang.String markerString) throws java.io.IOException, FileDecoderException, FileEncoderException- Throws:
java.io.IOExceptionFileDecoderExceptionFileEncoderException
-
writeBaseChunk
protected void writeBaseChunk(byte[] bytes) throws java.io.IOException, FileDecoderException, FileEncoderException- Throws:
java.io.IOExceptionFileDecoderExceptionFileEncoderException
-
writeTheirChunk
protected void writeTheirChunk(byte[] bytes) throws java.io.IOException, FileDecoderException, FileEncoderException- Throws:
java.io.IOExceptionFileDecoderExceptionFileEncoderException
-
writeYourChunk
protected void writeYourChunk(byte[] bytes) throws java.io.IOException- Throws:
java.io.IOException
-
writeResultChunk
protected void writeResultChunk(byte[] bytes) throws java.io.IOException, FileDecoderException, FileEncoderException- Throws:
java.io.IOExceptionFileDecoderExceptionFileEncoderException
-
finishMerge
protected boolean finishMerge(ClientMerge.ResolveChoice choice) throws java.io.IOException
- Throws:
java.io.IOException
-
getMergeDigestString
protected java.lang.String getMergeDigestString()
-
getTheirDigestString
protected java.lang.String getTheirDigestString()
-
getYourDigestString
protected java.lang.String getYourDigestString()
-
incrYourChunks
protected int incrYourChunks()
-
theirYourChunks
protected int theirYourChunks()
-
incrConflictChunks
protected int incrConflictChunks()
-
incrTheirChunks
protected int incrTheirChunks()
-
incrBothChunks
protected int incrBothChunks()
-
getClientPath
protected java.lang.String getClientPath()
-
setClientPath
protected void setClientPath(java.lang.String clientPath)
-
getBaseName
protected java.lang.String getBaseName()
-
setBaseName
protected void setBaseName(java.lang.String baseName)
-
getTheirName
protected java.lang.String getTheirName()
-
setTheirName
protected void setTheirName(java.lang.String theirName)
-
getYourName
protected java.lang.String getYourName()
-
setYourName
protected void setYourName(java.lang.String yourName)
-
getBaseTmpFilename
protected java.lang.String getBaseTmpFilename()
-
setBaseTmpFilename
protected void setBaseTmpFilename(java.lang.String baseTmpFilename)
-
getTheirTmpFilename
protected java.lang.String getTheirTmpFilename()
-
setTheirTmpFilename
protected void setTheirTmpFilename(java.lang.String theirTmpFilename)
-
getYourTmpFilename
protected java.lang.String getYourTmpFilename()
-
setYourTmpFilename
protected void setYourTmpFilename(java.lang.String yourTmpFilename)
-
getBaseTmpFile
protected RpcPerforceFile getBaseTmpFile()
-
setBaseTmpFile
protected void setBaseTmpFile(RpcPerforceFile baseTmpFile)
-
getTheirTmpFile
protected RpcPerforceFile getTheirTmpFile()
-
setTheirTmpFile
protected void setTheirTmpFile(RpcPerforceFile theirTmpFile)
-
getYourTmpFile
protected RpcPerforceFile getYourTmpFile()
-
setYourTmpFile
protected void setYourTmpFile(RpcPerforceFile yourTmpFile)
-
getBaseTmpFileStream
protected RpcOutputStream getBaseTmpFileStream()
-
setBaseTmpFileStream
protected void setBaseTmpFileStream(RpcOutputStream baseTmpFileStream)
-
getYourTmpFileStream
protected RpcOutputStream getYourTmpFileStream()
-
setYourTmpFileStream
protected void setYourTmpFileStream(RpcOutputStream yourTmpFileStream)
-
getTheirTmpFileStream
protected RpcOutputStream getTheirTmpFileStream()
-
setTheirTmpFileStream
protected void setTheirTmpFileStream(RpcOutputStream theirTmpFileStream)
-
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
protected java.lang.String getTmpDir()
-
setTmpDir
protected void setTmpDir(java.lang.String tmpDir)
-
isExternalStreamMerge
protected boolean isExternalStreamMerge()
-
setExternalStreamMerge
protected void setExternalStreamMerge(boolean externalStreamMerge)
-
getExternalTmpFilename
protected java.lang.String getExternalTmpFilename()
-
setExternalTmpFilename
protected void setExternalTmpFilename(java.lang.String externalTmpFilename)
-
getResultTmpFile
protected RpcPerforceFile getResultTmpFile()
-
setResultTmpFile
protected void setResultTmpFile(RpcPerforceFile resultTmpFile)
-
getResultTmpFileStream
protected RpcOutputStream getResultTmpFileStream()
-
setResultTmpFileStream
protected void setResultTmpFileStream(RpcOutputStream resultTmpFileStream)
-
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
protected java.lang.String getBaseDigest()
-
setBaseDigest
protected void setBaseDigest(java.lang.String baseDigest)
-
-