Exemplo n.º 1
0
        static int Main(string[] args)
        {
            int error = WindowsErrorDefinition.Success;

            if (args.Length < 3)
            {
                ShowUsage();
                error = WindowsErrorDefinition.NotSupported;
            }
            else
            {
                string pvcsUserId            = args[0];
                string buildSetSpecification = args[1];
                string gitLogReportFilename  = args[2];

                string gitLogReportPathAndFilename = Path.GetFullPath(gitLogReportFilename);

                Console.WriteLine("PVCS User Id is \"{0}\"", pvcsUserId);
                Console.WriteLine("Build Set Specification is \"{0}\"", buildSetSpecification);
                Console.WriteLine("Supplied git log filename is \"{0}\" resolving to \"{1}\"", gitLogReportFilename, gitLogReportPathAndFilename);

                BuildSetDetails buildSetDetails = new BuildSetDetails(buildSetSpecification);

                if (!buildSetDetails.AreValid)
                {
                    Console.WriteLine("eisGitToPvcsUpdate : Unable to identify the Build Set with specification \"{0}\"", buildSetSpecification);
                    error = WindowsErrorDefinition.BadEnvironment;
                }
                else
                {
                    buildSetDetails.Display("Selected Build Set");
                    Console.WriteLine(
                        "Managing PVCS update from Build Set \"{0}\" to PVCS Promotion Group \"{1}\"",
                        buildSetDetails.Identifier,
                        buildSetDetails.SecondaryIdentifier);
                    Console.WriteLine("Git Log report filename is \"{0}\"", gitLogReportPathAndFilename);

                    // Do not meddle with the sources if there is no associated git source change control
                    if (String.Compare(buildSetDetails.SourceChangeControlType, "git", true /* ignore case */) != 0)
                    {
                        Console.WriteLine("Build Set \"{0}\" is not Git Source Change Control Type", buildSetDetails.Identifier);
                        error = WindowsErrorDefinition.InvalidFunction;
                    }
                    else
                    {
                        PvcsPromotionGroupDataSortedSet pvcsPromotionGroupDataSortedSet = new PvcsPromotionGroupDataSortedSet();
                        error = pvcsPromotionGroupDataSortedSet.UpdatePvcsForPromotionGroup(pvcsUserId, buildSetDetails, gitLogReportPathAndFilename);
                    }
                }
            }
            return(error);
        }
Exemplo n.º 2
0
        public int Commit(string pvcsUserId,
                          BuildSetDetails buildsetDetails,
                          PvcsPromotionGroupData pvcsPromotionGroupData,
                          PvcsPromotionGroupDataSortedSet pvcsPromotionGroupDataSortedSet)
        {
            int error = WindowsErrorDefinition.Success;

            // Make sure there is something to commit
            if ((String.IsNullOrEmpty(PvcsCommitUserId)) ||
                (String.IsNullOrEmpty(Hash)) ||
                (String.IsNullOrEmpty(emailAddress)) ||
                ((DateTime == DateTime.MinValue)) ||
                (String.IsNullOrEmpty(Description))
                )
            {
                Console.WriteLine("PvcsCommitData.Commit : Insufficient data to perform a Commit");
            }
            else
            {
                // There is Commit information

                if (!Committed)
                {
                    // This Commit has not been committed already

                    if (PvcsCommitFileDataCollection.Count < 1)
                    {
                        Console.WriteLine("PvcsCommitData.Commit : No files to commit");
                        error = WindowsErrorDefinition.InvalidFunction;
                    }
                    else
                    {
                        // There are files to commit

                        error = PvcsConfiguration.SetPvcsEnvironment(pvcsUserId);
                        if (error == WindowsErrorDefinition.Success)
                        {
                            // Successfully set the PVCS Environment

                            for (int fileIndex = 0;
                                 (fileIndex < PvcsCommitFileDataCollection.Count) &&
                                 (error == WindowsErrorDefinition.Success);
                                 ++fileIndex)
                            {
                                error = PvcsCommitFileDataCollection.ElementAt(fileIndex).Commit(
                                    pvcsUserId,
                                    FullChangeDescription,
                                    buildsetDetails,
                                    pvcsPromotionGroupData,
                                    pvcsPromotionGroupDataSortedSet);
                                if (error != WindowsErrorDefinition.Success)
                                {
                                    Console.WriteLine("PvcsCommitData.Commit : File with index {0} = \"{1}\" failed to commit into PVCS",
                                                      fileIndex, PvcsCommitFileDataCollection.ElementAt(fileIndex).Name);
                                }
                            } // for fileIndex
                        }     // Successfully set the PVCS Environment
                    }         // There are files to commit

                    Committed = true;
                } // This Commit has not been committed already
            }     // There is Commit information

            return(error);
        } // Commit
Exemplo n.º 3
0
        public int Commit(string pvcsUserId,
                          string changeDescription,
                          BuildSetDetails buildSetDetails,
                          PvcsPromotionGroupData pvcsPromotionGroupData,
                          PvcsPromotionGroupDataSortedSet pvcsPromotionGroupDataSortedSet)
        {
            int error = WindowsErrorDefinition.Success;

            // Check whether the PVCS Archive exists
            if (!File.Exists(PvcsArchiveNameAndPath))
            {
                Console.WriteLine("PvcsCommitFileData.Commit : PVCS Archive \"{0}\" does not exist", PvcsArchiveNameAndPath);
                error = WindowsErrorDefinition.FileNotFound;
            }
            else
            {
                // PVCS Archive exists

                Console.WriteLine("PvcsCommitFileData.Commit : Committing \"{0}\"", Name);

                // Identify all the Promotion Groups in the PVCS Archive
                SortedSet <string> promotionGroupSortedSet = new SortedSet <string>();
                error = PvcsCommandOperation.GetArchivePromotionGroupNames(PvcsArchiveNameAndPath, ref promotionGroupSortedSet);
                if (error != WindowsErrorDefinition.Success)
                {
                    Console.WriteLine("PvcsCommitFileData.Commit({0}) : Failed to locate any Promotion Groups within the PVCS Archive", PvcsArchiveNameAndPath);
                }
                else
                {
                    // Got the Promotion Groups within the Archive or there aren't any

                    if ((promotionGroupSortedSet.Count > 0) &&
                        (promotionGroupSortedSet.Contains(pvcsPromotionGroupData.LowerSourcePromotionGroupName))
                        )
                    {
                        // There are Promotion Groups and the lower Promotion Group exists

                        error = PvcsCommandOperation.Promote(PvcsArchiveNameAndPath,
                                                             pvcsPromotionGroupData.LowerSourcePromotionGroupName);
                    } // There are Promotion Groups and the lower Promotion Group exists
                    else
                    {
                        // Try to Check In the new source via the Direct Checkin Promotion Group

                        // The mechanism of CheckIn is slightly different for an empty Archive

                        bool archiveIsEmpty = false;
                        error = PvcsCommandOperation.ArchiveIsEmpty(PvcsArchiveNameAndPath, out archiveIsEmpty);
                        if ((error == WindowsErrorDefinition.Success) &&
                            (!archiveIsEmpty)
                            )
                        {
                            // Lock the Archive at the Direct CheckIn Promotion Group

                            if (pvcsPromotionGroupData.DirectCheckInPromotionGroupName == null)
                            {
                                Console.WriteLine("PvcsCommitFileData.Commit : Promotion Group \"{0}\" has no Direct CheckIn Promotion Group",
                                                  pvcsPromotionGroupData.Name);
                                error = WindowsErrorDefinition.PathNotFound;
                            }
                            else
                            {
                                error = PvcsCommandOperation.Lock(PvcsArchiveNameAndPath,
                                                                  pvcsPromotionGroupData.DirectCheckInPromotionGroupName);
                            }
                        } // Lock the Archive at the Direct CheckIn Promotion Group

                        if (error == WindowsErrorDefinition.Success)
                        {
                            // Archive is ready for CheckIn

                            // Build the full path and filename to the source that has changed
                            string sourcePathAndFilename = Path.Combine(buildSetDetails.BuildSetRootPath, Name);

                            if (archiveIsEmpty)
                            {
                                // Checking In to an empty Archive requires assigning the correct Promotion Group
                                error = PvcsCommandOperation.CheckIntoEmptyArchive(pvcsUserId,
                                                                                   changeDescription,
                                                                                   pvcsPromotionGroupData.
                                                                                   DirectCheckInPromotionGroupName,
                                                                                   PvcsArchiveNameAndPath,
                                                                                   sourcePathAndFilename);
                            }
                            else
                            {
                                // A non-empty Archive will have had a revision locked at the necessary Promotion Group
                                error = PvcsCommandOperation.CheckIntoNonEmptyArchive(pvcsUserId,
                                                                                      changeDescription,
                                                                                      PvcsArchiveNameAndPath,
                                                                                      sourcePathAndFilename);
                            }

                            if (error == WindowsErrorDefinition.Success)
                            {
                                // Source has been CheckedIn

                                // Promote to end up at the required Promotion Group

                                // "DevelopmentN" Promotion Groups have IsCandidate "Pre_System_TestN"
                                // Promotion Groups above them so there would need to be two Promotions
                                // to get to the necessary Promotion Group
                                if (pvcsPromotionGroupData.DirectCheckInPromotionGroupName.StartsWith("Development"))
                                {
                                    // There will need to be two Promotions

                                    // Promote from the Direct CheckIn Promotion Group
                                    error = PvcsCommandOperation.Promote(PvcsArchiveNameAndPath,
                                                                         pvcsPromotionGroupData.
                                                                         DirectCheckInPromotionGroupName);
                                    if (error == WindowsErrorDefinition.Success)
                                    {
                                        // Now Promote from the Group above the Direct CheckIn Promotion Group

                                        // Get the data for the Direct CheckIn Promotion Group
                                        PvcsPromotionGroupData pvcsPromotionGroupDataDirectCheckIn =
                                            pvcsPromotionGroupDataSortedSet.GetPromotionGroupData(
                                                pvcsPromotionGroupData.DirectCheckInPromotionGroupName);

                                        if (pvcsPromotionGroupDataDirectCheckIn == null)
                                        {
                                            Console.WriteLine(
                                                "PvcsCommitFileData.Commit : Unable to find the details for the"
                                                + " Promotion Group that is higher than \"{0}\"",
                                                pvcsPromotionGroupData.DirectCheckInPromotionGroupName);
                                            error = WindowsErrorDefinition.PathNotFound;
                                        }
                                        else
                                        {
                                            // Promote from the Group above the Direct CheckIn Promotion Group
                                            error = PvcsCommandOperation.Promote(PvcsArchiveNameAndPath,
                                                                                 pvcsPromotionGroupDataDirectCheckIn.NextHigherPromotionGroupName);
                                        }
                                    } // Now Promote from the Group above the Direct CheckIn Promotion Group
                                }     // There will need to be two Promotions
                                else
                                {
                                    // There will need to be one Promotion only

                                    // Promote from the Direct CheckIn Promotion Group
                                    error = PvcsCommandOperation.Promote(PvcsArchiveNameAndPath,
                                                                         pvcsPromotionGroupData.
                                                                         DirectCheckInPromotionGroupName);
                                } // There will need to be one Promotion only
                            }     // Source has been CheckedIn
                        }         // Archive is ready for CheckIn
                    }             // Try to Check In the new source via the Direct Checkin Promotion Group
                }                 // Got the Promotion Groups within the Archive or there aren't any
            }                     // PVCS Archive exists

            return(error);
        } // Commit