private List <ReceiveCommand> FilterCommands(ReceiveCommand.Result want) { var r = new List <ReceiveCommand>(commands.Count); foreach (ReceiveCommand cmd in commands) { if (cmd.getResult() == want) { r.Add(cmd); } } return(r); }
/// <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> public ReceiveCommand(ObjectId oldId, ObjectId newId, string name) { this.oldId = oldId; this.newId = newId; this.name = name; type = ReceiveCommand.Type.UPDATE; if (ObjectId.ZeroId.Equals(oldId)) { type = ReceiveCommand.Type.CREATE; } if (ObjectId.ZeroId.Equals(newId)) { type = ReceiveCommand.Type.DELETE; } status = ReceiveCommand.Result.NOT_ATTEMPTED; }
/// <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>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); }
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); }