Exemplo n.º 1
0
 private void SendSVNErrorEvent(CommandLineOutput output)
 {
     if (output.failed)
     {
         OnDatabaseHandlerEvent(new SVNDatabaseErrorArgs(output));
     }
 }
Exemplo n.º 2
0
        public void ConstructorWithTextWriterParameter()
        {
            CommandLineOutput output = new CommandLineOutput(_writer);

            Console.WriteLine(output.Output.GetType());
            Assert.AreEqual(typeof(StringWriter), output.Output.GetType());
        }
Exemplo n.º 3
0
        private void HandleSVNStatusUpdate(CommandLineOutput output, bool async)
        {
            var xmlResult = new XmlDocument();

            xmlResult.LoadXml(output.outputStr);
            ParseStatusResult(xmlResult);
            if (async)
            {
                var syncOp = new SyncedToUpdateOperation(() =>
                {
                    if (output.failed)
                    {
                        SendSVNErrorEvent(output);
                    }
                    AssetDatabase.Refresh();
                    OnDatabaseHandlerEvent(new SVNDatabaseUpdatedArgs(output, new SVNStatusDatabase(svnStatusDatabase)));
                });
                syncOp.Queue();
            }
            else
            {
                if (output.failed)
                {
                    SendSVNErrorEvent(output);
                }
                var syncOp = new SyncedToUpdateOperation(AssetDatabase.Refresh);
                syncOp.Queue();
                OnDatabaseHandlerEvent(new SVNDatabaseUpdatedArgs(output, new SVNStatusDatabase(svnStatusDatabase)));
            }
        }
Exemplo n.º 4
0
 private static bool ImportantSVNError(CommandLineOutput output)
 {
     if (output.errorStr.Contains("svn: warning:"))
     {
         return(false);
     }
     if (output.errorStr.Contains("is not locked in this working copy"))
     {
         return(false);
     }
     if (output.errorStr.Contains("is not under version control"))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 5
0
        public CommandLineOutput ExecuteOperation(CommandLine commandLine, bool useOperationLock = true)
        {
            CommandLineOutput commandLineOutput;

            if (useOperationLock)
            {
                lock (operationActiveLockToken)
                {
                    commandLineOutput = ExecuteCommandLine(commandLine);
                }
            }
            else
            {
                commandLineOutput = ExecuteCommandLine(commandLine);
            }

            //D.Log(commandLineOutput + " " + commandLine.ToString());
            if (commandLineOutput != null)
            {
                if (!String.IsNullOrEmpty(commandLineOutput.ErrorStr))
                {
                    var errStr = commandLineOutput.ErrorStr;
                    if (errStr.Contains(" - no file(s) to reconcile."))
                    {
                        // this is not an error - put this text in the OutputStr and clear ErrorStr
                        commandLineOutput = new CommandLineOutput(commandLine.ToString(), "", errStr, "", 0);
                    }
                    else if (errStr.Contains(" - no such file(s)."))
                    {
                        // this is not an error - put this text in the OutputStr and clear ErrorStr
                        commandLineOutput = new CommandLineOutput(commandLine.ToString(), "", errStr, "", 0);
                    }
                    else
                    {
                        D.Log("ERROR: " + errStr + " " + commandLine.ToString());
                    }

                    //					D.Log(commandLineOutput.OutputStr);
                }
                //D.Log(commandLineOutput.OutputStr);
            }
            return(commandLineOutput);
        }
Exemplo n.º 6
0
    void RefreshGUI(object source, SVNDatabaseArgs e)
    {
        if (e is SVNDatabaseUpdatedArgs)
        {
            var args = e as SVNDatabaseUpdatedArgs;
            mSVNBusy           = false;
            mSVNStatusDatabase = args.statusDatabase;
            UpdateKeysOfInterrest(args.statusDatabase);
            svnCommandHistory.Add(args.output);
            Repaint();
            mCheckForConflicts = true;
            SaveState();
            mCurrentSVNOperation = null;
        }
        if (e is SVNDatabaseBusyArgs)
        {
            var args = e as SVNDatabaseBusyArgs;
            mCurrentSVNOperation = args.commandlineOperation.command;
            mSVNBusy             = true;
            Repaint();
        }
        if (e is SVNDatabaseErrorArgs)
        {
            var args = e as SVNDatabaseErrorArgs;

            CommandLineOutput output      = args.output;
            string            userMessage = output.command + " " + output.arguments + "\n\n" + output.errorStr + "\nExitCode:" + output.exitcode;
            if (output.exception != null)
            {
                userMessage += "\nException: \n" + output.exception.Message;
            }
            if (ImportantSVNError(output))
            {
                Debug.LogWarning(userMessage);
                EditorUtility.DisplayDialog("SVN Warning", userMessage, "OK");
            }
            else
            {
                Debug.Log("Verbose SVN message:\n" + userMessage);
            }
        }
    }
Exemplo n.º 7
0
        private void ShowRegisteredComponents <T>(string heading, ICollection <T> handles, GallioFunc <T, string> getName, GallioFunc <T, string> getDescription)
        {
            Console.WriteLine(heading);
            Console.WriteLine();
            T[] sortedHandles = GenericCollectionUtils.ToArray(handles);
            Array.Sort(sortedHandles, (x, y) => getName(x).CompareTo(getName(y)));

            if (sortedHandles.Length == 0)
            {
                CommandLineOutput.PrintArgumentHelp("", "<none>", null, null, null, null);
            }
            else
            {
                foreach (T handle in sortedHandles)
                {
                    CommandLineOutput.PrintArgumentHelp("", getName(handle), null, getDescription(handle), null, null);
                    Console.WriteLine();
                }
            }
        }
Exemplo n.º 8
0
        private CommandLineOutput ExecuteOperation(CommandLine commandLine, bool useOperationLock = true)
        {
            CommandLineOutput commandLineOutput;

            if (useOperationLock)
            {
                lock (operationActiveLockToken)
                {
                    commandLineOutput = ExecuteCommandLine(commandLine);
                }
            }
            else
            {
                commandLineOutput = ExecuteCommandLine(commandLine);
            }

            //if (commandLineOutput.Arguments.Contains("ExceptionTest.txt"))
            //{
            //    throw new VCCriticalException("Test Exception cast due to ExceptionTest.txt being a part of arguments", commandLine.ToString());
            //}
            if (!string.IsNullOrEmpty(commandLineOutput.ErrorStr))
            {
                var errStr = commandLineOutput.ErrorStr;
                if (errStr.Contains("E170001") || errStr.Contains("get username or password"))
                {
                    throw new VCMissingCredentialsException(errStr, commandLine.ToString());
                }
                else if (errStr.Contains("W160042") || errStr.Contains("Newer Version"))
                {
                    throw new VCNewerVersionException(errStr, commandLine.ToString());
                }
                else if (errStr.Contains("W155007") || errStr.Contains("'" + workingDirectory + "'" + " is not a working copy"))
                {
                    throw new VCCriticalException(errStr, commandLine.ToString());
                }
                else if (errStr.Contains("E720005") || errStr.Contains("Access is denied"))
                {
                    throw new VCCriticalException(errStr, commandLine.ToString());
                }
                else if (errStr.Contains("E160028") || errStr.Contains("is out of date"))
                {
                    throw new VCOutOfDate(errStr, commandLine.ToString());
                }
                else if (errStr.Contains("E155037") || errStr.Contains("E155004") || errStr.Contains("run 'svn cleanup'") || errStr.Contains("run 'cleanup'"))
                {
                    throw new VCLocalCopyLockedException(errStr, commandLine.ToString());
                }
                else if (errStr.Contains("W160035") || errStr.Contains("is already locked by user"))
                {
                    throw new VCLockedByOther(errStr, commandLine.ToString());
                }
                else if (errStr.Contains("E730060") || errStr.Contains("Unable to connect") || errStr.Contains("is unreachable") || errStr.Contains("Operation timed out") || errStr.Contains("Can't connect to"))
                {
                    throw new VCConnectionTimeoutException(errStr, commandLine.ToString());
                }
                else if (errStr.Contains("W200017"))  // Ignore warning relating to use of propget on non-existing property in SVN 1.9+
                {
                    commandLineOutput = new CommandLineOutput(commandLineOutput.Command, commandLineOutput.Arguments, commandLineOutput.OutputStr, "", 0);
                }
                else
                {
                    throw new VCException(errStr, commandLine.ToString());
                }
            }
            return(commandLineOutput);
        }
Exemplo n.º 9
0
        public void ConstructorWithConsoleTest()
        {
            CommandLineOutput output = new CommandLineOutput(NativeConsole.Instance);

            Assert.AreEqual(NativeConsole.Instance.Out.GetType(), output.Output.GetType());
        }
Exemplo n.º 10
0
 public void TestStart()
 {
     _sbOutput = new StringBuilder();
     _writer   = new StringWriter(_sbOutput);
     _output   = new CommandLineOutput(_writer, 80);
 }
Exemplo n.º 11
0
        public bool GetStatus(StatusLevel statusLevel, string fstatArgs, string path)
        {
            //D.Log( "Processing " + path );

            string arguments = "status -aedf \"" + path + "\"";

            CommandLineOutput statusCommandLineOutput = null;

            if (statusLevel == StatusLevel.Local)
            {
                using (var p4StatusTask = P4Util.Instance.CreateP4CommandLine(arguments))
                {
                    statusCommandLineOutput = P4Util.Instance.ExecuteOperation(p4StatusTask);
                }
            }

            arguments = fstatArgs + " \"" + path + "\"";
            CommandLineOutput fstatCommandLineOutput = null;

            using (var p4FstatTask = P4Util.Instance.CreateP4CommandLine(arguments))
            {
                fstatCommandLineOutput = P4Util.Instance.ExecuteOperation(p4FstatTask);
            }

            if (statusCommandLineOutput == null || statusCommandLineOutput.Failed || string.IsNullOrEmpty(statusCommandLineOutput.OutputStr) || !active)
            {
                return(false);
            }
            if (fstatCommandLineOutput == null || fstatCommandLineOutput.Failed || string.IsNullOrEmpty(fstatCommandLineOutput.OutputStr) || !active)
            {
                return(false);
            }
            try
            {
                var statusDB = statusCommandLineOutput != null?P4StatusParser.P4ParseStatus(statusCommandLineOutput.OutputStr, P4Util.Instance.Vars.userName) : null;

                var fstatDB = P4StatusParser.P4ParseFstat(fstatCommandLineOutput.OutputStr, P4Util.Instance.Vars.workingDirectory);
                lock (statusDatabaseLockToken)
                {
                    if (statusDB != null)
                    {
                        foreach (var statusIt in statusDB)
                        {
                            var status = statusIt.Value;
                            status.reflectionLevel = statusLevel == StatusLevel.Remote ? VCReflectionLevel.Repository : VCReflectionLevel.Local;
                            statusDatabase[new ComposedString(statusIt.Key.Compose().Replace(P4Util.Instance.Vars.workingDirectory + "/", ""))] = status;
                        }
                    }

                    foreach (var statusIt in fstatDB)
                    {
                        VersionControlStatus status = null;
                        ComposedString       aPath  = new ComposedString(statusIt.Key.Compose().Replace(P4Util.Instance.Vars.workingDirectory + "/", ""));
                        statusDatabase.TryGetValue(aPath, out status);
                        if (status == null || status.reflectionLevel == VCReflectionLevel.Pending)
                        {
                            // no previous status or previous status is pending, so set it here
                            status = statusIt.Value;
                        }
                        else
                        {
                            // probably got this status from the "status -a -e -d" command, merge it with whatever we got back from fstat
                            if (status.fileStatus == VCFileStatus.Modified && statusIt.Value.remoteStatus == VCRemoteFileStatus.Modified)
                            {
                                // we have modified locally and file is out of date with server - mark as a conflict (might not be, but at
                                // least this will raise a flag with the user to make sure they get up to date before going any further)
                                status.fileStatus         = VCFileStatus.Conflicted;
                                status.treeConflictStatus = VCTreeConflictStatus.TreeConflict;
                            }
                        }
                        status.reflectionLevel = statusLevel == StatusLevel.Remote ? VCReflectionLevel.Repository : VCReflectionLevel.Local;
                        statusDatabase[aPath]  = status;
                    }
                }
                lock (requestQueueLockToken)
                {
                    if (statusDB != null)
                    {
                        foreach (var assetIt in statusDB.Keys)
                        {
                            if (statusLevel == StatusLevel.Remote)
                            {
                                remoteRequestQueue.Remove(assetIt.Compose());
                            }
                            localRequestQueue.Remove(assetIt.Compose());
                        }
                    }
                    foreach (var assetIt in fstatDB.Keys)
                    {
                        if (statusLevel == StatusLevel.Remote)
                        {
                            remoteRequestQueue.Remove(assetIt.Compose());
                        }
                        localRequestQueue.Remove(assetIt.Compose());
                    }
                }
                OnStatusCompleted();
            }
            catch (Exception e)
            {
                DebugLog.ThrowException(e);
                return(false);
            }

            return(true);
        }
Exemplo n.º 12
0
 public SVNDatabaseErrorArgs(CommandLineOutput output)
 {
     this.output = output;
 }
Exemplo n.º 13
0
 public SVNDatabaseUpdatedArgs(CommandLineOutput output, SVNStatusDatabase statusDatabase)
 {
     this.statusDatabase = statusDatabase;
     this.output         = output;
 }