Class 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 Detail

      • 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 - clientPath
        externalStreamMerge - set true if this is a merge from an external stream
        clientType - clientType
        clientLineEnding - clientLineEnding
        resultType - resultType
        resultLineEnding - resultLineEnding
        tmpDir - the name of a suitable directory for creating temporary files in
        charset - 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.
      • writeYourChunk

        protected void writeYourChunk​(byte[] bytes)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • 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)
      • setBaseTmpFile

        protected void setBaseTmpFile​(RpcPerforceFile baseTmpFile)
      • setTheirTmpFile

        protected void setTheirTmpFile​(RpcPerforceFile theirTmpFile)
      • setYourTmpFile

        protected void setYourTmpFile​(RpcPerforceFile yourTmpFile)
      • setBaseTmpFileStream

        protected void setBaseTmpFileStream​(RpcOutputStream baseTmpFileStream)
      • 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)
      • 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)