Esempio n. 1
0
        /// <summary>
        /// Looks at the results of a sync operation to see if the sync was entirely successful or not.
        /// <para></para>If it was entirely successful, this method does nothing.
        /// <para></para>If there was indication that at least one file might be out of date or not synced, it throws the exception that should be handled by returning problem code to the parent caller.
        /// </summary>
        /// <param name="syncResults">Results of a sync operation to be analysed to see whether the sync operation was entirely successful or not.</param>
        /// <param name="language">Language of the sync.</param>
        /// <exception cref="IncorrectSDStateException">Thrown when <paramref name="syncResults"></paramref> indicate the sync operation was not entirely successful.</exception>
        protected void AnalyseSdSyncResults(SourceDepotCommandResult syncResults, string language)
        {
            if (syncResults.ResultType == SourceDepotCommandResultType.Warnings)
            {
                switch (ResultsAreActuallySuccess(syncResults))
                {
                case SourceDepotResult.Success:
                    SuccessfulSync = true;
                    Console.WriteLine("Succeeded.");
                    break;

                case SourceDepotResult.NoSuchFiles:
                    SuccessfulSync = false;
                    Console.WriteLine("No such files. Have you specified the correct language? {0}", language);
                    throw new IncorrectSDStateException {
                              ProblemCode = ExecutionResult.WrongLanguage
                    };

                case SourceDepotResult.Error:
                    Console.WriteLine("Error while syncing. Retrying.");
                    break;

                default:
                    Console.WriteLine("Unspecified problem while syncing.");
                    break;
                }
            }
            else
            {
                //Break the while loop, because everthing else seems successful.
                SuccessfulSync = true;
                Console.WriteLine("File(s) updated.");
                Console.WriteLine("Succeeded.");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Uses normal sync or forced sync (depending on retry attempt) to the appropriate depot.
        /// </summary>
        /// <param name="depot">Depot to synchronize</param>
        /// <param name="retryNumber">Number of the current retry. If it is 1, normal sync is used. If it is greater than 1, uses forced sync.</param>
        /// <param name="filePattern">Pattern of files to sync.</param>
        /// <param name="branchName">Branch on which to synchronize the files.</param>
        /// <returns>Command results.</returns>
        protected static SourceDepotCommandResult SyncDepotToBranch(SourceDepot depot, string branchName, int retryNumber, string filePattern)
        {
            Console.WriteLine("Attempt {0}...", retryNumber);

            SourceDepotCommandResult results = null;

            if (retryNumber == 1)
            {
                results = depot.Sync(filePattern, branchName);
            }
            else
            {
                results = depot.ForceSync(filePattern, branchName);
            }
            return(results);
        }
Esempio n. 3
0
 /// <summary>
 /// Parses the output of the command line to determine if this is actually a successful sync or a reason to try to sync again.
 /// </summary>
 /// <param name="results">Results from the last sync operation.</param>
 /// <remarks>Doesn't seem to catch editable files. Something wrong with sdapi.dll.</remarks>
 /// <returns>True if there is nothing wrong with the operation, False if the sync should be retried with -f flag (forced sync).</returns>
 protected SourceDepotResult ResultsAreActuallySuccess(SourceDepotCommandResult results)
 {
     switch (results.Outputs.Count)
     {
     case 1:
         var x = results.Outputs[0];
         if (Regex.IsMatch(x.Message, @"up-to-date.$"))
         {
             return(SourceDepotResult.Success);
         }
         if (Regex.IsMatch(x.Message, @"no such file\(s\).$"))
         {
             return(SourceDepotResult.NoSuchFiles);
         }
         break;
     }
     return(SourceDepotResult.UnspecifiedError);
 }