private static void Main(string[] args) { if (args.Length >= 1) { string reportPath = args[0]; string selectedIssueNumber = null; if (args.Length > 1) { selectedIssueNumber = args[1]; } PvcsCompleteSystemArchiveDetail pvcsCompleteSystemArchiveDetail = new PvcsCompleteSystemArchiveDetail( reportPath, PvcsCompleteSystemArchiveDetail.PvcsArchiveDetailLevel.ChangesOnly); pvcsCompleteSystemArchiveDetail.Display(); if (selectedIssueNumber != null) { // An Issue Number has been supplied SortedSet <string> additionalIssueNumberCollection = new SortedSet <string>(); pvcsCompleteSystemArchiveDetail.CheckDescendents(selectedIssueNumber, "System_Test", additionalIssueNumberCollection); if (additionalIssueNumberCollection.Count == 0) { Console.WriteLine(); Console.WriteLine("*** No Issue Numbers in addtion to {0} were found", selectedIssueNumber); } else { string heading = String.Format("Issue Numbers Found in Addition to {0}", selectedIssueNumber); Console.WriteLine(); Console.WriteLine(heading); Console.WriteLine(new string('~', heading.Length)); foreach (string issueNumber in additionalIssueNumberCollection) { Console.WriteLine("{0}{1}", PvcsCompleteSystemArchiveDetail.Indent(1), issueNumber); } } string promotionGroup = "System_Test"; Console.WriteLine(); string promotionHeading = String.Format("Promotion List for Issue Number {0} at {1}", selectedIssueNumber, promotionGroup); Console.WriteLine(promotionHeading); Console.WriteLine(new string('~', promotionHeading.Length)); pvcsCompleteSystemArchiveDetail.GeneratePromotionList(selectedIssueNumber, promotionGroup); pvcsCompleteSystemArchiveDetail.CheckBuriedPromotionGroup("System_Test"); } // An Issue Number has been supplied GitAdd(pvcsCompleteSystemArchiveDetail, "Production", "\\\\ADEBS02\\SysPR00\\", "d:\\Repos\\HeritageTest"); GitAdd(pvcsCompleteSystemArchiveDetail, "Pre_Production", "\\\\ADEBS02\\SysPR00\\", "d:\\Repos\\HeritageTest"); // GitAdd(pvcsCompleteSystemArchiveDetail, "User_Test", "\\\\ADEBS02\\SysUT00\\", "d:\\Repos\\Heritage"); } // Main }
} // CheckDescendents public void CheckBuriedPromotionGroup(int indent, string promotionGroup) { PvcsArchiveRevisionDetail highestRevisionWithPromotionGroup = PvcsArchiveRevisionDetailCollection.HighestRevisionWithPromotionGroup(promotionGroup); if (highestRevisionWithPromotionGroup != null) { // A revision with this Promotion Group exists // Check all other higher Promotion Groups // check up to but not including the specified Promotion Group int maximumHierarchyIndex = PvcsCompleteSystemArchiveDetail.PromotionGroupDetailCollection.HierarchyIndex(promotionGroup) - 1; for (int hierarchyIndex = PvcsPromotionGroupDetailCollection.DevelopmentHierarchyBaseIndex; hierarchyIndex < maximumHierarchyIndex; ++hierarchyIndex) { string higherPromotionGroup = PvcsCompleteSystemArchiveDetail.PromotionGroupDetailCollection.PromotionGroup(hierarchyIndex); PvcsArchiveRevisionDetail higherRevisionWithPromotionGroup = PvcsArchiveRevisionDetailCollection.HighestRevisionWithPromotionGroup(higherPromotionGroup); if (higherRevisionWithPromotionGroup != null) { bool specifiedPromotionGroupOnSameBranch = PvcsArchiveRevisionDetailCollection.RevisionsOnTheSameBranch( highestRevisionWithPromotionGroup.RevisionNumber, higherRevisionWithPromotionGroup.RevisionNumber); if (!specifiedPromotionGroupOnSameBranch) { Console.WriteLine("\"{0}\" has both {1} at r{2} and {3} at r{4}", highestRevisionWithPromotionGroup.ArchiveName, highestRevisionWithPromotionGroup.PromotionGroup, highestRevisionWithPromotionGroup.RevisionNumber, higherRevisionWithPromotionGroup.PromotionGroup, higherRevisionWithPromotionGroup.RevisionNumber); Console.WriteLine("{0}Is not on the same branch", PvcsCompleteSystemArchiveDetail.Indent(indent)); } else { bool specifiedPromotionGroupAtHigherRevision = PvcsArchiveRevisionDetailCollection.RevisionNumberIsGreater( highestRevisionWithPromotionGroup.RevisionNumber, higherRevisionWithPromotionGroup.RevisionNumber); if (!specifiedPromotionGroupAtHigherRevision) { Console.WriteLine("\"{0}\" has both {1} at r{2} and {3} at r{4}", highestRevisionWithPromotionGroup.ArchiveName, highestRevisionWithPromotionGroup.PromotionGroup, highestRevisionWithPromotionGroup.RevisionNumber, higherRevisionWithPromotionGroup.PromotionGroup, higherRevisionWithPromotionGroup.RevisionNumber); Console.WriteLine("{0}Is not at a higher revision", PvcsCompleteSystemArchiveDetail.Indent(indent)); } } } } } // A revision with this Promotion Group exists }
public void Display(int indent) { Console.WriteLine(); Console.WriteLine("{0}{1}", PvcsCompleteSystemArchiveDetail.Indent(indent), Name); foreach (PvcsArchiveRevisionDetail pvcsArchiveRevisionDetail in PvcsArchiveRevisionDetailCollection) { pvcsArchiveRevisionDetail.Display(indent + 1, false); } }
public void Display(int indent, bool displayArchiveName) { if (!displayArchiveName) { Console.WriteLine("{0}{1} {2} {3} {4:6} {5}", PvcsCompleteSystemArchiveDetail.Indent(indent), RevisionNumber, PromotionGroup, DeveloperId, (String.IsNullOrEmpty(IssueNumber) ? "\"\"" : IssueNumber), Description); } else { Console.WriteLine("{0}{1} {2} {3} {4} {5:6} {6}", PvcsCompleteSystemArchiveDetail.Indent(indent), ArchiveName, RevisionNumber, PromotionGroup, DeveloperId, (String.IsNullOrEmpty(IssueNumber) ? "\"\"" : IssueNumber), Description); } }
private static void GitAdd(PvcsCompleteSystemArchiveDetail pvcsCompleteSystemArchiveDetail, string promotionGroup, string sourcePath, string destinationPath) { Console.WriteLine(); Console.WriteLine("Add Source Revisions for \"{0}\"", promotionGroup); if (!pvcsCompleteSystemArchiveDetail.GitAdd(promotionGroup, 0, sourcePath, destinationPath)) { Console.WriteLine("*** Not all \"{0}\" Source Revisions were added", promotionGroup); } }
} // GeneratePromotionEntry public bool GitAdd(bool debugProgress, int indent, string sourceRootDirectory, string rootWorkingDirectory) { bool success = false; int firstSlashIndex = Name.IndexOf('\\'); if (firstSlashIndex >= 0) { // Found start of path string sourceFileFullPath = Path.Combine(sourceRootDirectory, Name.Substring(firstSlashIndex + 1)); if (!File.Exists(sourceFileFullPath)) { Console.WriteLine("{0}*** Source File \"{1}\" does not exist", PvcsCompleteSystemArchiveDetail.Indent(indent), sourceFileFullPath); } else { // Source File exists string workfileFullPath = Path.Combine(rootWorkingDirectory, Name.Substring(firstSlashIndex + 1)); if (debugProgress) { Console.WriteLine("{0}Archive Path \"{1}\" working path resolves to \"{2}\"", PvcsCompleteSystemArchiveDetail.Indent(indent), Name, workfileFullPath); } // Find the last slash to pass to xcopy so that it works with a destination directory int lastSlashIndex = workfileFullPath.LastIndexOf('\\'); string workfileDirectory = workfileFullPath.Substring(0, lastSlashIndex + 1); string fullWorkfilePathAndFilename = Path.Combine(workfileDirectory, this.FileName); // Determine the length of the filename without the drive specifier firstSlashIndex = fullWorkfilePathAndFilename.IndexOf('\\'); string fullRootRelativeWorkfilePathAndFilename = fullWorkfilePathAndFilename.Substring(firstSlashIndex + 1); const int longPathAndFilenameLength = 240; if (fullRootRelativeWorkfilePathAndFilename.Length > longPathAndFilenameLength) { Console.WriteLine("{0}+++ Warning: \"{1}\" workfile name is {2} characters long which is longer than {3} characters", PvcsCompleteSystemArchiveDetail.Indent(indent), fullWorkfilePathAndFilename, fullWorkfilePathAndFilename.Length, longPathAndFilenameLength); } string command = String.Format("xcopy \"{0}\" \"{1}\" /v/f/y", sourceFileFullPath, workfileDirectory); // Copy the file into the working directorBy which will cause the file to be "Staged" if (RunCommand(debugProgress, rootWorkingDirectory, command, false)) { DateTime dateTimeNow = DateTime.Now; Console.WriteLine("{0}{1} \"{2}\" -> \"{3}\"", PvcsCompleteSystemArchiveDetail.Indent(indent), dateTimeNow.ToString("yyyy-MM-dd-HH:mm:ss"), sourceFileFullPath, workfileDirectory); success = true; // Add the file to the Repo command = "git add \"" + WorkfileRelativePath + "\""; if (RunCommand(debugProgress, rootWorkingDirectory, command, false)) { Console.WriteLine("{0}Succeeded \"{1}\"", PvcsCompleteSystemArchiveDetail.Indent(indent + 1), command); } else { success = false; Console.WriteLine("{0}*** Failed \"{1}\"", PvcsCompleteSystemArchiveDetail.Indent(indent + 1), command); } } else { DateTime dateTimeNow = DateTime.Now; Console.WriteLine("{0} *** {1} Failed \"{2}\" -> \"{3}\"", PvcsCompleteSystemArchiveDetail.Indent(indent), dateTimeNow.ToString("yyyy-MM-dd-HH:mm:ss"), sourceFileFullPath, workfileDirectory); } } // Source File exists } // Found start of path return(success); } // GitAdd
public void CheckDescendents(int indent, string issueNumber, string promotionGroup, SortedSet <string> additionalIssueNumberCollection) { if (PvcsArchiveRevisionDetailCollection.HasIssueNumber(issueNumber)) { // This Archive has this Issue Number Collection <string> displayOutput = new Collection <string>(); foreach (PvcsArchiveRevisionDetail pvcsArchiveRevisionDetail in PvcsArchiveRevisionDetailCollection) { if (String.Compare(promotionGroup, "System_Test", true) == 0) { if ((String.Compare(pvcsArchiveRevisionDetail.PromotionGroup, "User_Test", true) == 0) && (String.Compare(pvcsArchiveRevisionDetail.IssueNumber, issueNumber, true) != 0)) { // Display the User_Test details displayOutput.Add(pvcsArchiveRevisionDetail.ToString(indent + 1)); if (String.IsNullOrEmpty(pvcsArchiveRevisionDetail.IssueNumber)) { additionalIssueNumberCollection.Add(pvcsArchiveRevisionDetail.NonEmptyIssueNumber + " : " + pvcsArchiveRevisionDetail.PromotionGroup + " - \"" + pvcsArchiveRevisionDetail.ArchiveName + "\""); } else { additionalIssueNumberCollection.Add(pvcsArchiveRevisionDetail.NonEmptyIssueNumber + " : " + pvcsArchiveRevisionDetail.PromotionGroup); } } else if ((String.Compare(pvcsArchiveRevisionDetail.PromotionGroup, "Pre_Production", true) == 0) && (String.Compare(pvcsArchiveRevisionDetail.IssueNumber, issueNumber, true) != 0)) { // Display the Pre_Production details displayOutput.Add(pvcsArchiveRevisionDetail.ToString(indent + 1)); if (String.IsNullOrEmpty(pvcsArchiveRevisionDetail.IssueNumber)) { additionalIssueNumberCollection.Add(pvcsArchiveRevisionDetail.NonEmptyIssueNumber + " : " + pvcsArchiveRevisionDetail.PromotionGroup + " - \"" + pvcsArchiveRevisionDetail.ArchiveName + "\""); } else { additionalIssueNumberCollection.Add(pvcsArchiveRevisionDetail.NonEmptyIssueNumber + " : " + pvcsArchiveRevisionDetail.PromotionGroup); } } } } if (displayOutput.Count > 0) { Console.WriteLine(); Console.WriteLine("{0}{1} : Has Issue Number {2}", PvcsCompleteSystemArchiveDetail.Indent(indent), Name, issueNumber); foreach (string displayLine in displayOutput) { Console.WriteLine(displayLine); } } if (!PvcsArchiveRevisionDetailCollection.IsOnlyIssueNumber(issueNumber)) { // Other Issue Numbers are present in the Archive displayOutput.Clear(); foreach (PvcsArchiveRevisionDetail pvcsArchiveRevisionDetail in PvcsArchiveRevisionDetailCollection) { if (String.Compare(promotionGroup, "System_Test", true) == 0) { if (String.Compare(pvcsArchiveRevisionDetail.PromotionGroup, "User_Test", true) == 0) { // Display the User_Test details if another Issue Number is present if (String.Compare(pvcsArchiveRevisionDetail.IssueNumber, issueNumber, true) != 0) { displayOutput.Add(pvcsArchiveRevisionDetail.ToString(indent + 1)); if (String.IsNullOrEmpty(pvcsArchiveRevisionDetail.IssueNumber)) { additionalIssueNumberCollection.Add(pvcsArchiveRevisionDetail.NonEmptyIssueNumber + " : " + pvcsArchiveRevisionDetail.PromotionGroup + " - \"" + pvcsArchiveRevisionDetail.ArchiveName + "\""); } else { additionalIssueNumberCollection.Add(pvcsArchiveRevisionDetail.NonEmptyIssueNumber + " : " + pvcsArchiveRevisionDetail.PromotionGroup); } } } else if (String.Compare(pvcsArchiveRevisionDetail.PromotionGroup, "Pre_Production", true) == 0) { // Display the Pre_Production details if another Issue Number is present if (String.Compare(pvcsArchiveRevisionDetail.IssueNumber, issueNumber, true) != 0) { displayOutput.Add(pvcsArchiveRevisionDetail.ToString(indent + 1)); if (String.IsNullOrEmpty(pvcsArchiveRevisionDetail.IssueNumber)) { additionalIssueNumberCollection.Add(pvcsArchiveRevisionDetail.NonEmptyIssueNumber + " : " + pvcsArchiveRevisionDetail.PromotionGroup + " - \"" + pvcsArchiveRevisionDetail.ArchiveName + "\""); } else { additionalIssueNumberCollection.Add(pvcsArchiveRevisionDetail.NonEmptyIssueNumber + " : " + pvcsArchiveRevisionDetail.PromotionGroup); } } } } } if (displayOutput.Count > 0) { Console.WriteLine(); Console.WriteLine("{0}{1} : Has Issue Numbers different from {2}", PvcsCompleteSystemArchiveDetail.Indent(indent), Name, issueNumber); foreach (string displayLine in displayOutput) { Console.WriteLine(displayLine); } } } // Other Issue Numbers are present in the Archive } // This Archive has this Issue Number } // CheckDescendents
public string ToString(int indent) { return(String.Format("{0}{1} {2} {3} {4:6} \"{5}\"", PvcsCompleteSystemArchiveDetail.Indent(indent), RevisionNumber, PromotionGroup, DeveloperId, (String.IsNullOrEmpty(IssueNumber) ? "\"\"" : IssueNumber), Description)); }