示例#1
0
    public IEnumerator TestMergeFF()
    {
        testObject1.transform.position = new Vector2(0.0f, 0.0f);
        testObject2.transform.position = new Vector2(3.0f, 3.0f);

        VersionManager.Instance().Add(testController1);
        VersionManager.Instance().Add(testController2);

        ICommit commit = VersionManager.Instance().Commit("Add two objects");

        yield return(null);

        IBranch testBranch = VersionManager.Instance().CreateBranch("testBranch");

        VersionManager.Instance().Checkout("testBranch");

        testObject1.transform.position = new Vector2(1.0f, 0.0f);
        VersionManager.Instance().Add(testController1);
        ICommit secondCommit = VersionManager.Instance().Commit("Move testObject1");

        VersionManager.Instance().Checkout("master");

        Assert.AreEqual("master", master.GetName());
        Assert.AreSame(commit, master.GetTip());
        Assert.AreEqual("testBranch", testBranch.GetName());
        Assert.AreSame(secondCommit, testBranch.GetTip());

        Relationship mergeType = VersionManager.Instance().Merge(testBranch);

        Assert.AreEqual(Relationship.FastForward, mergeType);

        Assert.AreSame(secondCommit, master.GetTip());
        Assert.AreSame(secondCommit, VersionManager.Instance().GetActiveCommit());
    }
示例#2
0
    /// <summary>
    /// Checks out the given commit on the given branch
    /// </summary>
    public void Checkout(IBranch branch, ICommit commit)
    {
        // Need to allow them to checkout the last created branch because that's how "create branch" works
        if (!EnabledVersionControls.Instance().CanCheckout&& !lastCreatedBranch.Equals(branch))
        {
            Debug.Log("Can't Checkout branch; not enabled yet");
            return;
        }
        LoadStateOfCommit(commit);
        activeCommit = commit;
        activeBranch = branch;
        if (!activeCommit.Equals(activeBranch.GetTip()))
        {
            this.isDetached = true;
        }
        else
        {
            this.isDetached = false;
        }

        if (checkoutTrigger != null)
        {
            checkoutTrigger.Trigger();
        }

        UIController.Instance().UpdateOverlay();
    }
示例#3
0
    public IEnumerator TestMergeWorkerSmoke()
    {
        testObject1.transform.position = new Vector2(0.0f, 0.0f);
        testObject2.transform.position = new Vector2(3.0f, 3.0f);

        VersionManager.Instance().Add(testController1);
        VersionManager.Instance().Add(testController2);

        ICommit commit = VersionManager.Instance().Commit("Add two objects");

        yield return(null);

        IBranch testBranch = VersionManager.Instance().CreateBranch("testBranch");

        VersionManager.Instance().Checkout("testBranch");

        testObject1.transform.position = new Vector2(1.0f, 0.0f);
        VersionManager.Instance().Add(testController1);
        ICommit secondCommit = VersionManager.Instance().Commit("Move testObject1");

        VersionManager.Instance().Checkout("master");

        Assert.AreEqual("master", master.GetName());
        Assert.AreSame(commit, master.GetTip());
        Assert.AreEqual("testBranch", testBranch.GetName());
        Assert.AreSame(secondCommit, testBranch.GetTip());

        IMergeWorker mw = new MergeWorker(master, testBranch, null, null);

        Assert.AreEqual(Relationship.FastForward, mw.GetMergeType());
        Assert.AreEqual(MergeStatus.FastForward, mw.GetStatus(testController1));
        Assert.AreEqual(MergeStatus.FastForward, mw.GetStatus(testController2));
        Assert.AreEqual(true, mw.IsResolved());
    }
示例#4
0
    public IEnumerator TestSame()
    {
        VersionManager.Instance().Commit("Initial Commit");
        IBranch master  = VersionManager.Instance().GetActiveBranch();
        IBranch feature = VersionManager.Instance().CreateBranch("feature");

        yield return(null);

        Assert.AreEqual(Relationship.Same, LineageAnalyser.Compare(master.GetTip(), feature.GetTip()));
    }
示例#5
0
    /// <summary>
    /// Checks out the commit specified by the given commit ID on the specified branch
    /// </summary>
    public void Checkout(IBranch branch, Guid commitId)
    {
        ICommit commit = branch.GetTip();

        while (!commit.GetId().Equals(commitId))
        {
            commit = commit.GetParent();
        }
        Checkout(branch, commit);
    }
示例#6
0
    public IEnumerator TestMergeDivergent()
    {
        testObject1.transform.position = new Vector2(0.0f, 0.0f);
        testObject2.transform.position = new Vector2(3.0f, 3.0f);

        VersionManager.Instance().Add(testController1);
        VersionManager.Instance().Add(testController2);

        VersionManager.Instance().Commit("Add two objects");

        yield return(null);

        IBranch testBranch = VersionManager.Instance().CreateBranch("testBranch");

        VersionManager.Instance().Checkout("testBranch");

        testObject1.transform.position = new Vector2(1.0f, 0.0f);
        testObject2.transform.position = new Vector2(0.0f, 0.0f);
        VersionManager.Instance().Add(testController1);
        VersionManager.Instance().Add(testController2);
        ICommit secondCommit = VersionManager.Instance().Commit("Move testObject1 and testObject2");

        VersionManager.Instance().Checkout("master");

        testObject2.transform.position = new Vector2(6.0f, 6.0f);
        VersionManager.Instance().Add(testController2);
        ICommit thirdCommit = VersionManager.Instance().Commit("Move testObject2");

        Assert.AreEqual("master", master.GetName());
        Assert.AreSame(thirdCommit, master.GetTip());
        Assert.AreEqual("testBranch", testBranch.GetName());
        Assert.AreSame(secondCommit, testBranch.GetTip());

        Relationship mergeType = VersionManager.Instance().Merge(testBranch);

        Assert.AreEqual(Relationship.Divergent, mergeType);
        Assert.AreEqual(MergeStatus.FastForward, VersionManager.Instance().GetMergeWorker().GetStatus(testController1));
        Assert.AreEqual(MergeStatus.Conflict, VersionManager.Instance().GetMergeWorker().GetStatus(testController2));
        Assert.AreEqual(true, VersionManager.Instance().IsInMergeConflict());

        VersionManager.Instance().GetMergeWorker().PickVersion(testController2, master.GetTip().getObjectVersion(testController2));

        Assert.AreEqual(MergeStatus.Resolved, VersionManager.Instance().GetMergeWorker().GetStatus(testController2));
        Assert.AreEqual(false, VersionManager.Instance().IsInMergeConflict());

        ICommit mergeCommit = VersionManager.Instance().ResolveMerge();

        Assert.NotNull(mergeCommit);

        Assert.AreSame(mergeCommit, master.GetTip());
        Assert.AreSame(mergeCommit, VersionManager.Instance().GetActiveCommit());
    }
示例#7
0
    public IEnumerator TestDivergent()
    {
        VersionManager.Instance().Commit("Initial Commit");
        IBranch master  = VersionManager.Instance().GetActiveBranch();
        IBranch feature = VersionManager.Instance().CreateBranch("feature");

        VersionManager.Instance().Commit("Commit on master branch");
        VersionManager.Instance().Checkout(feature.GetName());
        VersionManager.Instance().Commit("Commit on feature branch");
        yield return(null);

        Assert.AreEqual(Relationship.Divergent, LineageAnalyser.Compare(master.GetTip(), feature.GetTip()));
    }
示例#8
0
    public Relationship Merge(IBranch featureBranch)
    {
        if (!EnabledVersionControls.Instance().CanMerge)
        {
            Debug.Log("Merging not enabled yet");
        }
        if (isDetached)
        {
            throw new Exception("Can't merge if detached");
        }

        if (this.mw != null)
        {
            throw new Exception("Already doing a merge, resolve this first");
        }

        IMergeWorker mw        = new MergeWorker(activeBranch, featureBranch, pickTrigger, mergeUI);
        Relationship mergeType = mw.GetMergeType();

        if (mw.GetMergeType() == Relationship.FastForward)
        {
            mw.End();
            activeBranch.UpdateTip(featureBranch.GetTip());
            activeCommit = activeBranch.GetTip();
            LoadStateOfCommit(activeCommit);

            if (mergeTrigger != null)
            {
                mergeTrigger.Trigger();
            }

            return(mergeType);
        }

        this.mw = mw;

        return(mergeType);
    }
示例#9
0
    /// <summary>
    /// Initialise the MergeWorker, determine the state
    /// </summary>
    private void Initialise()
    {
        switch (this.mergeType)
        {
        case Relationship.Rewind:
            throw new Exception("Base branch is ahead of feature branch, merge redundant");

        case Relationship.Same:
            throw new Exception("Branches are the same");

        case Relationship.Unknown:
            throw new Exception("Can not determine branch relativity");

        case Relationship.FastForward:
            break;

        case Relationship.Divergent:
            break;

        default:
            break;
        }

        ffControllers       = new HashSet <VersionController>();
        resolvedControllers = new HashSet <VersionController>();
        conflictControllers = new HashSet <VersionController>();

        hiddenSprites = new HashSet <Renderer>();

        IEnumerable <VersionController> intersection = baseBranch.GetTip().GetTrackedObjects().Intersect(featureBranch.GetTip().GetTrackedObjects());

        foreach (VersionController trackedObject in intersection)
        {
            IVersion baseVersion    = baseBranch.GetTip().getObjectVersion(trackedObject);
            IVersion featureVersion = featureBranch.GetTip().getObjectVersion(trackedObject);
            switch (LineageAnalyser.Compare <IVersion>(baseVersion, featureVersion))
            {
            case Relationship.Unknown:
                throw new Exception("Can not determine version relativity");

            case Relationship.Rewind:
                ffControllers.Add(trackedObject);
                stagingArea.Add(trackedObject, baseVersion);
                break;

            case Relationship.Same:
            case Relationship.FastForward:
                ffControllers.Add(trackedObject);
                stagingArea.Add(trackedObject, featureVersion);
                break;

            case Relationship.Divergent:
                conflictControllers.Add(trackedObject);
                break;

            default:
                break;
            }
        }

        foreach (VersionController trackedObject in baseBranch.GetTip().GetTrackedObjects().Except(intersection))
        {
            IVersion version = baseBranch.GetTip().getObjectVersion(trackedObject);
            ffControllers.Add(trackedObject);
            stagingArea.Add(trackedObject, version);
        }

        foreach (VersionController trackedObject in featureBranch.GetTip().GetTrackedObjects().Except(intersection))
        {
            IVersion version = featureBranch.GetTip().getObjectVersion(trackedObject);
            ffControllers.Add(trackedObject);
            stagingArea.Add(trackedObject, version);
        }
    }
示例#10
0
 // Helper function for checking out a branch
 public void Checkout(IBranch branch)
 {
     Checkout(branch, branch.GetTip());
 }