Ejemplo n.º 1
0
        /// <exception cref="System.InvalidOperationException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        protected internal virtual void CheckoutBranch(string branchName)
        {
            RevWalk          walk   = new RevWalk(db);
            RevCommit        head   = walk.ParseCommit(db.Resolve(Constants.HEAD));
            RevCommit        branch = walk.ParseCommit(db.Resolve(branchName));
            DirCacheCheckout dco    = new DirCacheCheckout(db, head.Tree.Id, db.LockDirCache(),
                                                           branch.Tree.Id);

            dco.SetFailOnConflict(true);
            dco.Checkout();
            walk.Release();
            // update the HEAD
            RefUpdate refUpdate = db.UpdateRef(Constants.HEAD);

            refUpdate.Link(branchName);
        }
Ejemplo n.º 2
0
        /// <exception cref="System.InvalidOperationException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        private void CheckoutBranch(string branchName)
        {
            RevWalk          walk   = new RevWalk(db);
            RevCommit        head   = walk.ParseCommit(db.Resolve(Constants.HEAD));
            RevCommit        branch = walk.ParseCommit(db.Resolve(branchName));
            DirCacheCheckout dco    = new DirCacheCheckout(db, head.Tree, db.LockDirCache(), branch
                                                           .Tree);

            dco.SetFailOnConflict(true);
            NUnit.Framework.Assert.IsTrue(dco.Checkout());
            walk.Release();
            // update the HEAD
            RefUpdate refUpdate = db.UpdateRef(Constants.HEAD);

            NUnit.Framework.Assert.AreEqual(RefUpdate.Result.FORCED, refUpdate.Link(branchName
                                                                                    ));
        }
Ejemplo n.º 3
0
        /// <exception cref="System.IO.IOException"></exception>
        private void WriteSymref(string src, string dst)
        {
            RefUpdate u = db.UpdateRef(src);

            switch (u.Link(dst))
            {
            case RefUpdate.Result.NEW:
            case RefUpdate.Result.FORCED:
            case RefUpdate.Result.NO_CHANGE:
            {
                break;
            }

            default:
            {
                NUnit.Framework.Assert.Fail("link " + src + " to " + dst);
                break;
            }
            }
        }