Esempio n. 1
0
        /// <summary>Create a new RefUpdate copying the batch settings.</summary>
        /// <remarks>Create a new RefUpdate copying the batch settings.</remarks>
        /// <param name="cmd">specific command the update should be created to copy.</param>
        /// <returns>a single reference update command.</returns>
        /// <exception cref="System.IO.IOException">
        /// the reference database cannot make a new update object for
        /// the given reference.
        /// </exception>
        protected internal virtual RefUpdate NewUpdate(ReceiveCommand cmd)
        {
            RefUpdate ru = refdb.NewUpdate(cmd.GetRefName(), false);

            if (IsRefLogDisabled())
            {
                ru.DisableRefLog();
            }
            else
            {
                ru.SetRefLogIdent(refLogIdent);
                ru.SetRefLogMessage(refLogMessage, refLogIncludeResult);
            }
            switch (cmd.GetType())
            {
            case ReceiveCommand.Type.DELETE:
            {
                if (!ObjectId.ZeroId.Equals(cmd.GetOldId()))
                {
                    ru.SetExpectedOldObjectId(cmd.GetOldId());
                }
                ru.SetForceUpdate(true);
                return(ru);
            }

            case ReceiveCommand.Type.CREATE:
            case ReceiveCommand.Type.UPDATE:
            case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:
            default:
            {
                ru.SetForceUpdate(IsAllowNonFastForwards());
                ru.SetExpectedOldObjectId(cmd.GetOldId());
                ru.SetNewObjectId(cmd.GetNewId());
                return(ru);

                break;
            }
            }
        }