Class ClientMerge


  • public class ClientMerge
    extends java.lang.Object
    Support methods for the RPC merge protocols. Will grow as we implement more types of merge; current version is very bare bones and oriented solely at non-interactive three-way merges of text files.
    • 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
      • SYSTEM_TMPDIR_PROPS_KEY

        public static final java.lang.String SYSTEM_TMPDIR_PROPS_KEY
        See Also:
        Constant Field Values
      • SYSTEM_TMPDIR_DEFAULT

        public static final java.lang.String SYSTEM_TMPDIR_DEFAULT
        See Also:
        Constant Field Values
      • MERGE_STATE_KEY

        protected static final java.lang.String MERGE_STATE_KEY
        See Also:
        Constant Field Values
      • MERGE_BASE_TMP_FILE_KEY

        protected static final java.lang.String MERGE_BASE_TMP_FILE_KEY
        See Also:
        Constant Field Values
      • MERGE_BASE_TMP_STREAM_KEY

        protected static final java.lang.String MERGE_BASE_TMP_STREAM_KEY
        See Also:
        Constant Field Values
      • MERGE_THEIRS_TMP_FILE_KEY

        protected static final java.lang.String MERGE_THEIRS_TMP_FILE_KEY
        See Also:
        Constant Field Values
      • MERGE_THEIRS_TMP_STREAM_KEY

        protected static final java.lang.String MERGE_THEIRS_TMP_STREAM_KEY
        See Also:
        Constant Field Values
      • MERGE_YOURS_TMP_FILE_KEY

        protected static final java.lang.String MERGE_YOURS_TMP_FILE_KEY
        See Also:
        Constant Field Values
      • MERGE_YOURS_TMP_STREAM_KEY

        protected static final java.lang.String MERGE_YOURS_TMP_STREAM_KEY
        See Also:
        Constant Field Values
    • Constructor Detail

      • ClientMerge

        public ClientMerge​(java.util.Properties props)
    • Method Detail

      • clientWriteMerge

        protected RpcPacketDispatcher.RpcPacketDispatcherResult clientWriteMerge​(RpcConnection rpcConnection,
                                                                                 CommandEnv cmdEnv,
                                                                                 java.util.Map<java.lang.String,​java.lang.Object> resultsMap)
                                                                          throws ConnectionException
        Write merge data to the client if necessary.

        For the external stream merge case, this is a no op, but for the normal three-way merge case, we not only need to write the relevant files, but we also need to keep track of the differences so we can determine whether an automatic and / or safe merge is even possible. This determination is done in clientCloseMerge using chunk difference counts as supplied by the server in the bits parameter.

        For the two-way merge, all we really need to do is write the "their" file and keep digesting under the covers...

        Parameters:
        rpcConnection - rpcConnection
        cmdEnv - cmdEnv
        resultsMap - resultsMap
        Returns:
        RpcPacketDispatcherResult
        Throws:
        ConnectionException - on error
      • clientCloseMerge

        protected RpcPacketDispatcher.RpcPacketDispatcherResult clientCloseMerge​(RpcConnection rpcConnection,
                                                                                 CommandEnv cmdEnv,
                                                                                 java.util.Map<java.lang.String,​java.lang.Object> resultsMap)
                                                                          throws ConnectionException
        Close the merge write (above) and act on the results. The actions needed here depend on whether we're doing a merge from external stream or a safe auto merge.
        Parameters:
        rpcConnection - rpcConnection
        cmdEnv - cmdEnv
        resultsMap - resultsMap
        Returns:
        RpcPacketDispatcherResult
        Throws:
        ConnectionException - on error