Class ClientMergeState
- java.lang.Object
-
- com.perforce.p4java.impl.mapbased.rpc.func.client.ClientMergeState
-
public class ClientMergeState extends java.lang.Object
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 Modifier and Type Field Description protected java.lang.String
baseDigest
static java.lang.String
DEFAULT_TMPFILE_PFX
static java.lang.String
DEFAULT_TMPFILE_SFX
static java.lang.String
TRACE_PREFIX
protected boolean
twoWayMerge
-
Constructor Summary
Constructors Modifier Constructor Description 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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
finishMerge(ClientMerge.ResolveChoice choice)
protected java.lang.String
getBaseDigest()
protected java.lang.String
getBaseName()
protected RpcPerforceFile
getBaseTmpFile()
protected java.lang.String
getBaseTmpFilename()
protected RpcOutputStream
getBaseTmpFileStream()
protected int
getBits()
protected int
getBothChunks()
protected java.lang.String
getClientPath()
protected int
getConflictChunks()
protected java.lang.String
getExternalTmpFilename()
protected java.lang.String
getMergeDigestString()
protected int
getOldBits()
protected RpcPerforceFile
getResultTmpFile()
protected RpcOutputStream
getResultTmpFileStream()
protected int
getTheirChunks()
protected java.lang.String
getTheirDigestString()
protected java.lang.String
getTheirName()
protected RpcPerforceFile
getTheirTmpFile()
protected java.lang.String
getTheirTmpFilename()
protected RpcOutputStream
getTheirTmpFileStream()
protected java.lang.String
getTmpDir()
protected int
getYourChunks()
protected java.lang.String
getYourDigestString()
protected java.lang.String
getYourName()
protected RpcPerforceFile
getYourTmpFile()
protected java.lang.String
getYourTmpFilename()
protected RpcOutputStream
getYourTmpFileStream()
protected int
incrBothChunks()
protected int
incrConflictChunks()
protected int
incrTheirChunks()
protected int
incrYourChunks()
protected boolean
isAutoMerge()
protected boolean
isExternalStreamMerge()
protected boolean
isSafeMerge()
protected boolean
isShowAll()
protected boolean
isTwoWayMerge()
protected void
openMergeFiles(RpcConnection rpcConnection)
Open and / or create the necessary files for this merge.protected void
setAutoMerge(boolean autoMerge)
protected void
setBaseDigest(java.lang.String baseDigest)
protected void
setBaseName(java.lang.String baseName)
protected void
setBaseTmpFile(RpcPerforceFile baseTmpFile)
protected void
setBaseTmpFilename(java.lang.String baseTmpFilename)
protected void
setBaseTmpFileStream(RpcOutputStream baseTmpFileStream)
protected void
setBits(int bits)
protected void
setBothChunks(int bothChunks)
protected void
setClientPath(java.lang.String clientPath)
protected void
setConflictChunks(int conflictChunks)
protected void
setExternalStreamMerge(boolean externalStreamMerge)
protected void
setExternalTmpFilename(java.lang.String externalTmpFilename)
protected void
setOldBits(int oldBits)
protected void
setResultTmpFile(RpcPerforceFile resultTmpFile)
protected void
setResultTmpFileStream(RpcOutputStream resultTmpFileStream)
protected void
setSafeMerge(boolean safeMerge)
protected void
setShowAll(boolean showAll)
protected void
setTheirChunks(int theirChunks)
protected void
setTheirName(java.lang.String theirName)
protected void
setTheirTmpFile(RpcPerforceFile theirTmpFile)
protected void
setTheirTmpFilename(java.lang.String theirTmpFilename)
protected void
setTheirTmpFileStream(RpcOutputStream theirTmpFileStream)
protected void
setTmpDir(java.lang.String tmpDir)
protected void
setTwoWayMerge(boolean twoWayMerge)
protected void
setYourChunks(int yourChunks)
protected void
setYourName(java.lang.String yourName)
protected void
setYourTmpFile(RpcPerforceFile yourTmpFile)
protected void
setYourTmpFilename(java.lang.String yourTmpFilename)
protected void
setYourTmpFileStream(RpcOutputStream yourTmpFileStream)
protected int
theirYourChunks()
protected void
writeBaseChunk(byte[] bytes)
protected void
writeMarker(java.lang.String markerString)
protected void
writeResultChunk(byte[] bytes)
protected void
writeTheirChunk(byte[] bytes)
protected void
writeYourChunk(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.IOException
FileDecoderException
FileEncoderException
-
writeBaseChunk
protected void writeBaseChunk(byte[] bytes) throws java.io.IOException, FileDecoderException, FileEncoderException
- Throws:
java.io.IOException
FileDecoderException
FileEncoderException
-
writeTheirChunk
protected void writeTheirChunk(byte[] bytes) throws java.io.IOException, FileDecoderException, FileEncoderException
- Throws:
java.io.IOException
FileDecoderException
FileEncoderException
-
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.IOException
FileDecoderException
FileEncoderException
-
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)
-
-