Ejemplo n.º 1
0
        internal virtual void AddChild(NGit.Revplot.PlotCommit c)
        {
            int cnt = children.Length;

            if (cnt == 0)
            {
                children = new NGit.Revplot.PlotCommit[] { c };
            }
            else
            {
                if (cnt == 1)
                {
                    if (!c.Id.Equals(children[0].Id))
                    {
                        children = new NGit.Revplot.PlotCommit[] { children[0], c };
                    }
                }
                else
                {
                    foreach (NGit.Revplot.PlotCommit pc in children)
                    {
                        if (c.Id.Equals(pc.Id))
                        {
                            return;
                        }
                    }
                    NGit.Revplot.PlotCommit[] n = new NGit.Revplot.PlotCommit[cnt + 1];
                    System.Array.Copy(children, 0, n, 0, cnt);
                    n[cnt]   = c;
                    children = n;
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>Find the set of lanes passing through a commit's row.</summary>
 /// <remarks>
 /// Find the set of lanes passing through a commit's row.
 /// <p>
 /// Lanes passing through a commit are lanes that the commit is not directly
 /// on, but that need to travel through this commit to connect a descendant
 /// (child) commit to an ancestor (parent) commit. Typically these lanes will
 /// be drawn as lines in the passed commit's box, and the passed commit won't
 /// appear to be connected to those lines.
 /// <p>
 /// This method modifies the passed collection by adding the lanes in any
 /// order.
 /// </remarks>
 /// <param name="currCommit">the commit the caller needs to get the lanes from.</param>
 /// <param name="result">collection to add the passing lanes into.</param>
 public virtual void FindPassingThrough(PlotCommit <L> currCommit, ICollection <L> result
                                        )
 {
     foreach (PlotLane p in currCommit.passingLanes)
     {
         result.AddItem((L)p);
     }
 }
Ejemplo n.º 3
0
        private void SetupChildren(PlotCommit <L> currCommit)
        {
            int nParents = currCommit.ParentCount;

            for (int i = 0; i < nParents; i++)
            {
                ((PlotCommit)currCommit.GetParent(i)).AddChild(currCommit);
            }
        }
 public virtual PlotCommitListTest.CommitListAssert Commit(RevCommit id)
 {
     NUnit.Framework.Assert.IsTrue(this.pcl.Count > this.nextIndex, "Unexpected end of list at pos#"
                                   + this.nextIndex);
     this.current = this.pcl[this.nextIndex++];
     NUnit.Framework.Assert.AreEqual(id.Id, this.current.Id, "Expected commit not found at pos#"
                                     + (this.nextIndex - 1));
     return(this);
 }
Ejemplo n.º 5
0
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        public override RevCommit Next()
        {
            RevCommit  pc     = base.Next();
            PlotCommit commit = (PlotCommit)pc;

            if (pc != null)
            {
                commit.refs = GetRefs(pc);
            }
            return(pc);
        }
Ejemplo n.º 6
0
 /// <summary>Determine if the given commit is a child (descendant) of this commit.</summary>
 /// <remarks>Determine if the given commit is a child (descendant) of this commit.</remarks>
 /// <param name="c">the commit to test.</param>
 /// <returns>true if the given commit built on top of this commit.</returns>
 public bool IsChild(NGit.Revplot.PlotCommit c)
 {
     foreach (NGit.Revplot.PlotCommit a in children)
     {
         if (a == c)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// when connecting a plotcommit to the child make sure that you will not be
        /// located on a lane on which a passed commit is located on.
        /// </summary>
        /// <remarks>
        /// when connecting a plotcommit to the child make sure that you will not be
        /// located on a lane on which a passed commit is located on. Otherwise we
        /// would have to draw a line through a commit.
        /// </remarks>
        /// <param name="index"></param>
        /// <param name="commit"></param>
        /// <param name="nChildren"></param>
        private void HandleBlockedLanes(int index, PlotCommit <L> commit, int nChildren)
        {
            // take care:
            int    remaining        = nChildren;
            BitSet blockedPositions = new BitSet();

            for (int r = index - 1; r >= 0; r--)
            {
                PlotCommit rObj = this[r];
                if (commit.IsChild(rObj))
                {
                    if (--remaining == 0)
                    {
                        break;
                    }
                }
                if (rObj != null)
                {
                    PlotLane lane = rObj.GetLane();
                    if (lane != null)
                    {
                        blockedPositions.Set(lane.GetPosition());
                    }
                    rObj.AddPassingLane(commit.lane);
                }
            }
            // Now let's check whether we have to reposition the lane
            if (blockedPositions.Get(commit.lane.GetPosition()))
            {
                int newPos = -1;
                foreach (int pos in freePositions)
                {
                    if (!blockedPositions.Get(pos))
                    {
                        newPos = pos;
                        break;
                    }
                }
                if (newPos == -1)
                {
                    newPos = positionsAllocated++;
                }
                freePositions.AddItem(Sharpen.Extensions.ValueOf(commit.lane.GetPosition()));
                activeLanes.Remove(commit.lane);
                commit.lane.position = newPos;
                activeLanes.AddItem(commit.lane);
            }
        }
Ejemplo n.º 8
0
        internal virtual void AddChild(NGit.Revplot.PlotCommit c)
        {
            int cnt = children.Length;

            if (cnt == 0)
            {
                children = new NGit.Revplot.PlotCommit[] { c };
            }
            else
            {
                if (cnt == 1)
                {
                    children = new NGit.Revplot.PlotCommit[] { children[0], c };
                }
                else
                {
                    NGit.Revplot.PlotCommit[] n = new NGit.Revplot.PlotCommit[cnt + 1];
                    System.Array.Copy(children, 0, n, 0, cnt);
                    n[cnt]   = c;
                    children = n;
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>Paint one commit using the underlying graphics library.</summary>
        /// <remarks>Paint one commit using the underlying graphics library.</remarks>
        /// <param name="commit">the commit to render in this cell. Must not be null.</param>
        /// <param name="h">total height (in pixels) of this cell.</param>
        protected internal virtual void PaintCommit(PlotCommit <TLane> commit, int h)
        {
            int    dotSize   = ComputeDotSize(h);
            TLane  myLane    = commit.GetLane();
            int    myLaneX   = LaneC(myLane);
            TColor myColor   = LaneColor(myLane);
            int    maxCenter = 0;

            foreach (TLane passingLane in (TLane[])commit.passingLanes)
            {
                int    cx = LaneC(passingLane);
                TColor c  = LaneColor(passingLane);
                DrawLine(c, cx, 0, cx, h, LINE_WIDTH);
                maxCenter = Math.Max(maxCenter, cx);
            }
            int nParent = commit.ParentCount;

            for (int i = 0; i < nParent; i++)
            {
                PlotCommit <TLane> p;
                TLane  pLane;
                TColor pColor;
                int    cx;
                p     = (PlotCommit <TLane>)commit.GetParent(i);
                pLane = p.GetLane();
                if (pLane == null)
                {
                    continue;
                }
                pColor = LaneColor(pLane);
                cx     = LaneC(pLane);
                if (Math.Abs(myLaneX - cx) > LANE_WIDTH)
                {
                    if (myLaneX < cx)
                    {
                        int ix = cx - LANE_WIDTH / 2;
                        DrawLine(pColor, myLaneX, h / 2, ix, h / 2, LINE_WIDTH);
                        DrawLine(pColor, ix, h / 2, cx, h, LINE_WIDTH);
                    }
                    else
                    {
                        int ix = cx + LANE_WIDTH / 2;
                        DrawLine(pColor, myLaneX, h / 2, ix, h / 2, LINE_WIDTH);
                        DrawLine(pColor, ix, h / 2, cx, h, LINE_WIDTH);
                    }
                }
                else
                {
                    DrawLine(pColor, myLaneX, h / 2, cx, h, LINE_WIDTH);
                }
                maxCenter = Math.Max(maxCenter, cx);
            }
            int dotX = myLaneX - dotSize / 2 - 1;
            int dotY = (h - dotSize) / 2;

            if (commit.GetChildCount() > 0)
            {
                DrawLine(myColor, myLaneX, 0, myLaneX, dotY, LINE_WIDTH);
            }
            if (commit.Has(RevFlag.UNINTERESTING))
            {
                DrawBoundaryDot(dotX, dotY, dotSize, dotSize);
            }
            else
            {
                DrawCommitDot(dotX, dotY, dotSize, dotSize);
            }
            int textx = Math.Max(maxCenter + LANE_WIDTH / 2, dotX + dotSize) + 8;
            int n     = commit.refs.Length;

            for (int i_1 = 0; i_1 < n; ++i_1)
            {
                textx += DrawLabel(textx + dotSize, h / 2, commit.refs[i_1]);
            }
            string msg = commit.GetShortMessage();

            DrawText(msg, textx + dotSize + n * 2, h / 2);
        }
Ejemplo n.º 10
0
        protected internal override void Enter(int index, PlotCommit <L> currCommit)
        {
            SetupChildren(currCommit);
            int nChildren = currCommit.GetChildCount();

            if (nChildren == 0)
            {
                return;
            }
            if (nChildren == 1 && currCommit.children[0].ParentCount < 2)
            {
                // Only one child, child has only us as their parent.
                // Stay in the same lane as the child.
                //
                PlotCommit c = currCommit.children[0];
                if (c.lane == null)
                {
                    // Hmmph. This child must be the first along this lane.
                    //
                    c.lane = NextFreeLane();
                    activeLanes.AddItem(c.lane);
                }
                for (int r = index - 1; r >= 0; r--)
                {
                    PlotCommit rObj = this[r];
                    if (rObj == c)
                    {
                        break;
                    }
                    rObj.AddPassingLane(c.lane);
                }
                currCommit.lane = c.lane;
            }
            else
            {
                // More than one child, or our child is a merge.
                // Use a different lane.
                //
                // Process all our children. Especially important when there is more
                // than one child (e.g. a commit is processed where other branches
                // fork out). For each child the following is done
                // 1. If no lane was assigned to the child a new lane is created and
                // assigned
                // 2. The lane of the child is closed. If this frees a position,
                // this position will be added freePositions list.
                // If we have multiple children which where previously not on a lane
                // each such child will get his own new lane but all those new lanes
                // will be on the same position. We have to take care that not
                // multiple newly created (in step 1) lanes occupy that position on
                // which the
                // parent's lane will be on. Therefore we delay closing the lane
                // with the parents position until all children are processed.
                // The lane on that position the current commit will be on
                PlotLane reservedLane = null;
                for (int i = 0; i < nChildren; i++)
                {
                    PlotCommit c = currCommit.children[i];
                    // don't forget to position all of your children if they are
                    // not already positioned.
                    if (c.lane == null)
                    {
                        c.lane = NextFreeLane();
                        activeLanes.AddItem(c.lane);
                        if (reservedLane != null)
                        {
                            CloseLane(c.lane);
                        }
                        else
                        {
                            reservedLane = c.lane;
                        }
                    }
                    else
                    {
                        if (reservedLane == null && activeLanes.Contains(c.lane))
                        {
                            reservedLane = c.lane;
                        }
                        else
                        {
                            CloseLane(c.lane);
                        }
                    }
                }
                // finally all children are processed. We can close the lane on that
                // position our current commit will be on.
                if (reservedLane != null)
                {
                    CloseLane(reservedLane);
                }
                currCommit.lane = NextFreeLane();
                activeLanes.AddItem(currCommit.lane);
                // take care: when connecting yourself to your child make sure that
                // you will not be located on a lane on which a passed commit is
                // located on. Otherwise we would have to draw a line through a
                // commit.
                int    remaining        = nChildren;
                BitSet blockedPositions = new BitSet();
                for (int r = index - 1; r >= 0; r--)
                {
                    PlotCommit rObj = this[r];
                    if (currCommit.IsChild(rObj))
                    {
                        if (--remaining == 0)
                        {
                            break;
                        }
                    }
                    if (rObj != null)
                    {
                        PlotLane lane = rObj.GetLane();
                        if (lane != null)
                        {
                            blockedPositions.Set(lane.GetPosition());
                        }
                        rObj.AddPassingLane(currCommit.lane);
                    }
                }
                // Now let's check whether we have to reposition the lane
                if (blockedPositions.Get(currCommit.lane.GetPosition()))
                {
                    int newPos = -1;
                    foreach (int pos in freePositions)
                    {
                        if (!blockedPositions.Get(pos))
                        {
                            newPos = pos;
                            break;
                        }
                    }
                    if (newPos == -1)
                    {
                        newPos = positionsAllocated++;
                    }
                    freePositions.AddItem(currCommit.lane.GetPosition());
                    currCommit.lane.position = newPos;
                }
            }
        }
Ejemplo n.º 11
0
        protected internal override void Enter(int index, PlotCommit <L> currCommit)
        {
            SetupChildren(currCommit);
            int nChildren = currCommit.GetChildCount();

            if (nChildren == 0)
            {
                return;
            }
            if (nChildren == 1 && currCommit.children[0].ParentCount < 2)
            {
                // Only one child, child has only us as their parent.
                // Stay in the same lane as the child.
                //
                PlotCommit c = currCommit.children[0];
                if (c.lane == null)
                {
                    // Hmmph. This child must be the first along this lane.
                    //
                    c.lane = NextFreeLane();
                    activeLanes.AddItem(c.lane);
                }
                for (int r = index - 1; r >= 0; r--)
                {
                    PlotCommit rObj = this[r];
                    if (rObj == c)
                    {
                        break;
                    }
                    rObj.AddPassingLane(c.lane);
                }
                currCommit.lane = c.lane;
                HandleBlockedLanes(index, currCommit, nChildren);
            }
            else
            {
                // More than one child, or our child is a merge.
                // Use a different lane.
                //
                // Process all our children. Especially important when there is more
                // than one child (e.g. a commit is processed where other branches
                // fork out). For each child the following is done
                // 1. If no lane was assigned to the child a new lane is created and
                // assigned
                // 2. The lane of the child is closed. If this frees a position,
                // this position will be added freePositions list.
                // If we have multiple children which where previously not on a lane
                // each such child will get his own new lane but all those new lanes
                // will be on the same position. We have to take care that not
                // multiple newly created (in step 1) lanes occupy that position on
                // which the
                // parent's lane will be on. Therefore we delay closing the lane
                // with the parents position until all children are processed.
                // The lane on that position the current commit will be on
                PlotLane reservedLane = null;
                for (int i = 0; i < nChildren; i++)
                {
                    PlotCommit c = currCommit.children[i];
                    // don't forget to position all of your children if they are
                    // not already positioned.
                    if (c.lane == null)
                    {
                        c.lane = NextFreeLane();
                        activeLanes.AddItem(c.lane);
                        if (reservedLane != null)
                        {
                            CloseLane(c.lane);
                        }
                        else
                        {
                            reservedLane = c.lane;
                        }
                    }
                    else
                    {
                        if (reservedLane == null && activeLanes.Contains(c.lane))
                        {
                            reservedLane = c.lane;
                        }
                        else
                        {
                            CloseLane(c.lane);
                        }
                    }
                }
                // finally all children are processed. We can close the lane on that
                // position our current commit will be on.
                if (reservedLane != null)
                {
                    CloseLane(reservedLane);
                }
                currCommit.lane = NextFreeLane();
                activeLanes.AddItem(currCommit.lane);
                HandleBlockedLanes(index, currCommit, nChildren);
            }
        }
Ejemplo n.º 12
0
 void PlotCommit.AddChild(PlotCommit c)
 {
     this.AddChild(c);
 }