Пример #1
0
    public MergeWorker(IBranch baseBranch, IBranch featureBranch, TriggerManager trigger, MergeUIController mergeUI)
    {
        if (baseBranch == null || featureBranch == null)
        {
            throw new Exception("Branch can not be null");
        }
        this.baseBranch    = baseBranch;
        this.featureBranch = featureBranch;
        this.isMergable    = false;
        this.mergeType     = LineageAnalyser.Compare(this.baseBranch.GetTip(), this.featureBranch.GetTip());

        stagingArea = new Dictionary <VersionController, IVersion>();

        pickTrigger = trigger;
        this.ui     = mergeUI;

        Initialise();

        UpdateStatus();
        RenderDiff();

        if (this.ui != null)
        {
            this.ui.gameObject.SetActive(true);
            Camera.main.GetComponent <MergeInterfaceCamera>().enabled = true;
            this.ui.SetMergeWorker(this);
            this.ui.PopulateConflictObjects(conflictControllers);

            oldStatusUI = GameObject.Find("Status");
            oldStatusUI.SetActive(false);
        }
    }
Пример #2
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()));
    }
Пример #3
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()));
    }
Пример #4
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);
        }
    }