Class ClientMergeState

java.lang.Object
com.perforce.p4java.impl.mapbased.rpc.func.client.ClientMergeState

public class ClientMergeState extends 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 Details

  • Constructor Details

    • ClientMergeState

      protected ClientMergeState(String clientPath, boolean externalStreamMerge, RpcPerforceFileType clientType, ClientLineEnding clientLineEnding, RpcPerforceFileType resultType, ClientLineEnding resultLineEnding, String tmpDir, 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 Details

    • openMergeFiles

      protected void openMergeFiles(RpcConnection rpcConnection) throws 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:
      IOException - if there's been a problem opening any of the files.
    • writeMarker

      protected void writeMarker(String markerString) throws IOException, FileDecoderException, FileEncoderException
      Throws:
      IOException
      FileDecoderException
      FileEncoderException
    • writeBaseChunk

      protected void writeBaseChunk(byte[] bytes) throws IOException, FileDecoderException, FileEncoderException
      Throws:
      IOException
      FileDecoderException
      FileEncoderException
    • writeTheirChunk

      protected void writeTheirChunk(byte[] bytes) throws IOException, FileDecoderException, FileEncoderException
      Throws:
      IOException
      FileDecoderException
      FileEncoderException
    • writeYourChunk

      protected void writeYourChunk(byte[] bytes) throws IOException
      Throws:
      IOException
    • writeResultChunk

      protected void writeResultChunk(byte[] bytes) throws IOException, FileDecoderException, FileEncoderException
      Throws:
      IOException
      FileDecoderException
      FileEncoderException
    • finishMerge

      protected boolean finishMerge(ClientMerge.ResolveChoice choice) throws IOException
      Throws:
      IOException
    • getMergeDigestString

      protected String getMergeDigestString()
    • getTheirDigestString

      protected String getTheirDigestString()
    • getYourDigestString

      protected String getYourDigestString()
    • incrYourChunks

      protected int incrYourChunks()
    • theirYourChunks

      protected int theirYourChunks()
    • incrConflictChunks

      protected int incrConflictChunks()
    • incrTheirChunks

      protected int incrTheirChunks()
    • incrBothChunks

      protected int incrBothChunks()
    • getClientPath

      protected String getClientPath()
    • setClientPath

      protected void setClientPath(String clientPath)
    • getBaseName

      protected String getBaseName()
    • setBaseName

      protected void setBaseName(String baseName)
    • getTheirName

      protected String getTheirName()
    • setTheirName

      protected void setTheirName(String theirName)
    • getYourName

      protected String getYourName()
    • setYourName

      protected void setYourName(String yourName)
    • getBaseTmpFilename

      protected String getBaseTmpFilename()
    • setBaseTmpFilename

      protected void setBaseTmpFilename(String baseTmpFilename)
    • getTheirTmpFilename

      protected String getTheirTmpFilename()
    • setTheirTmpFilename

      protected void setTheirTmpFilename(String theirTmpFilename)
    • getYourTmpFilename

      protected String getYourTmpFilename()
    • setYourTmpFilename

      protected void setYourTmpFilename(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 String getTmpDir()
    • setTmpDir

      protected void setTmpDir(String tmpDir)
    • isExternalStreamMerge

      protected boolean isExternalStreamMerge()
    • setExternalStreamMerge

      protected void setExternalStreamMerge(boolean externalStreamMerge)
    • getExternalTmpFilename

      protected String getExternalTmpFilename()
    • setExternalTmpFilename

      protected void setExternalTmpFilename(String externalTmpFilename)
    • getResultTmpFile

      protected RpcPerforceFile getResultTmpFile()
    • setResultTmpFile

      protected void setResultTmpFile(RpcPerforceFile resultTmpFile)
    • getResultTmpFileStream

      protected RpcOutputStream getResultTmpFileStream()
    • setResultTmpFileStream

      protected void setResultTmpFileStream(RpcOutputStream resultTmpFileStream)
    • 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

      protected String getBaseDigest()
    • setBaseDigest

      protected void setBaseDigest(String baseDigest)