internal virtual void SetType(ReceiveCommand.Type t) { type = t; }
/// <summary>Filter a list of commands according to result.</summary> /// <remarks>Filter a list of commands according to result.</remarks> /// <param name="commands">commands to filter.</param> /// <param name="want">desired status to filter by.</param> /// <returns> /// a copy of the command list containing only those commands with /// the desired status. /// </returns> /// <since>2.0</since> public static IList<NGit.Transport.ReceiveCommand> Filter(IList<NGit.Transport.ReceiveCommand > commands, ReceiveCommand.Result want) { IList<NGit.Transport.ReceiveCommand> r = new AList<NGit.Transport.ReceiveCommand> (commands.Count); foreach (NGit.Transport.ReceiveCommand cmd in commands) { if (cmd.GetResult() == want) { r.AddItem(cmd); } } return r; }
/// <summary>Set the status of this command.</summary> /// <remarks>Set the status of this command.</remarks> /// <param name="s">the new status code for this command.</param> public virtual void SetResult(ReceiveCommand.Result s) { SetResult(s, null); }
/// <summary>Set the status of this command.</summary> /// <remarks>Set the status of this command.</remarks> /// <param name="s">new status code for this command.</param> /// <param name="m">optional message explaining the new status.</param> public virtual void SetResult(ReceiveCommand.Result s, string m) { status = s; message = m; }
/// <summary> /// Create a new command for /// <see cref="BaseReceivePack">BaseReceivePack</see> /// . /// </summary> /// <param name="oldId"> /// the old object id; must not be null. Use /// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see> /// to indicate a ref creation. /// </param> /// <param name="newId"> /// the new object id; must not be null. Use /// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see> /// to indicate a ref deletion. /// </param> /// <param name="name">name of the ref being affected.</param> /// <param name="type">type of the command.</param> /// <since>2.0</since> public ReceiveCommand(ObjectId oldId, ObjectId newId, string name, ReceiveCommand.Type type) { this.oldId = oldId; this.newId = newId; this.name = name; this.type = type; }
private RefUpdate.Result Decode(ReceiveCommand.Result status) { switch (status) { case ReceiveCommand.Result.OK: { if (AnyObjectId.Equals(this._enclosing.oldObjectId, this._enclosing.newObjectId)) { return RefUpdate.Result.NO_CHANGE; } switch (this.GetType()) { case ReceiveCommand.Type.CREATE: { return RefUpdate.Result.NEW; } case ReceiveCommand.Type.UPDATE: { return RefUpdate.Result.FAST_FORWARD; } case ReceiveCommand.Type.DELETE: case ReceiveCommand.Type.UPDATE_NONFASTFORWARD: default: { return RefUpdate.Result.FORCED; break; } } goto case ReceiveCommand.Result.REJECTED_NOCREATE; } case ReceiveCommand.Result.REJECTED_NOCREATE: case ReceiveCommand.Result.REJECTED_NODELETE: case ReceiveCommand.Result.REJECTED_NONFASTFORWARD: { return RefUpdate.Result.REJECTED; } case ReceiveCommand.Result.REJECTED_CURRENT_BRANCH: { return RefUpdate.Result.REJECTED_CURRENT_BRANCH; } case ReceiveCommand.Result.REJECTED_MISSING_OBJECT: { return RefUpdate.Result.IO_FAILURE; } case ReceiveCommand.Result.LOCK_FAILURE: case ReceiveCommand.Result.NOT_ATTEMPTED: case ReceiveCommand.Result.REJECTED_OTHER_REASON: default: { return RefUpdate.Result.LOCK_FAILURE; break; } } }
public override void SetResult(ReceiveCommand.Result status, string msg) { this._enclosing.result = this.Decode(status); base.SetResult(status, msg); }
/// <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; } } }
/// <summary>Add a single command to this batch update.</summary> /// <remarks>Add a single command to this batch update.</remarks> /// <param name="cmd">the command to add, must not be null.</param> /// <returns> /// /// <code>this</code> /// . /// </returns> public virtual NGit.BatchRefUpdate AddCommand(ReceiveCommand cmd) { commands.AddItem(cmd); return this; }