Ejemplo n.º 1
0
        public static bool CommitChanges(SourceControlBase SourceControl, ICollection <string> pathsToCommit, string Comments, bool includeLocks, ref bool conflictHandled)
        {
            string        error          = string.Empty;
            bool          result         = true;
            bool          conflict       = conflictHandled;
            List <string> conflictsPaths = new List <string>();

            if (!SourceControl.CommitChanges(pathsToCommit, Comments, ref error, ref conflictsPaths, includeLocks))
            {
                App.MainWindow.Dispatcher.Invoke(() => {
                    foreach (string cPath in conflictsPaths)
                    {
                        ResolveConflictPage resConfPage = new ResolveConflictPage(cPath);
                        if (WorkSpace.RunningInExecutionMode == true)
                        {
                            SourceControlIntegration.ResolveConflicts(WorkSpace.UserProfile.Solution.SourceControl, cPath, eResolveConflictsSide.Server);
                        }
                        else
                        {
                            resConfPage.ShowAsWindow();
                        }
                        result       = resConfPage.IsResolved;
                        conflict     = true;
                        conflictFlag = conflict;
                    }
                    if (SourceControl.GetSourceControlmConflict != null)
                    {
                        SourceControl.GetSourceControlmConflict.Clear();
                    }
                });
                if (!conflict)
                {
                    if (error.Contains("too many redirects or authentication replays"))
                    {
                        error = "Commit failed because of wrong credentials error, please enter valid Username and Password and try again";
                    }
                    if (error.Contains("is locked in another working copy"))
                    {
                        error = "This file has been locked by other user. Please remove lock and then try to Check in.";
                    }
                    App.MainWindow.Dispatcher.Invoke(() => {
                        Reporter.ToUser(eUserMsgKey.GeneralErrorOccured, error);
                    });
                    return(false);
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static bool GetLatest(string path, SourceControlBase SourceControl)
        {
            string        error           = string.Empty;
            List <string> conflictsPaths  = new List <string>();
            bool          result          = true;
            bool          conflictHandled = false;

            if (!SourceControl.GetLatest(path, ref error, ref conflictsPaths))
            {
                foreach (string cPath in conflictsPaths)
                {
                    ResolveConflictPage resConfPage = new ResolveConflictPage(cPath);
                    if (WorkSpace.RunningInExecutionMode == true)
                    {
                        SourceControlIntegration.ResolveConflicts(SourceControl, cPath, eResolveConflictsSide.Server);
                    }
                    else
                    {
                        resConfPage.ShowAsWindow();
                    }
                    result = resConfPage.IsResolved;

                    if (!result)
                    {
                        Reporter.ToUser(eUserMsgKey.SourceControlGetLatestConflictHandledFailed);
                        return(false);
                    }
                    conflictHandled = true;
                }
                if (!conflictHandled)
                {
                    Reporter.ToUser(eUserMsgKey.SourceControlUpdateFailed, error);
                    return(false);
                }
            }
            return(true);
        }