/// <summary> /// Scans the Project Item for deleted files and removes their local /// copies from the local image of the project. Obeys the recursive setting /// (and thus optionally calls itself recursively). /// </summary> /// <param name="item">The VSS Item (project) to check for deletions</param> /// <param name="localPathPrefix">The path to the folder of the item being processed</param> public void RemoveDeletedFromLocalImage(IVSSItem item, string localPathPrefix) { IVSSItems items = item.get_Items(true); Hashtable deletedTable = BuildDeletedTable(items); IEnumerator ie = items.GetEnumerator(); while (ie.MoveNext()) { IVSSItem i = (IVSSItem)ie.Current; string localPath = System.IO.Path.Combine(localPathPrefix, i.Name); if (IsTrulyDeleted(deletedTable, i) && Exists(localPath)) { SetToWriteable(localPath); Delete(localPath); } else { if (IsProject(i) && Recursive) { RemoveDeletedFromLocalImage(i, System.IO.Path.Combine(localPathPrefix, i.Name)); } } } }
private static void BuildFileList(IVSSItem fromVssProject) { string spec = fromVssProject.Spec; if (vssFolderExclusionRegex != null && vssFolderExclusionRegex.IsMatch(spec)) { searchLog.DebugFormat("Skipping project [Matched folder exclusion regex] {0}", spec); return; } if (vssFolderInclusionRegex != null && !vssFolderInclusionRegex.IsMatch(spec)) { searchLog.DebugFormat("Skipping file [Failed folder inclusion regex] {0}", spec); return; } //still used to generate the project/directories at the beginning of the migration /*if (!projList.Exists(proj => string.Compare(proj.Spec, spec, true) == 0)) * { * projList.Add(fromVssProject); * }*/ IVSSItems childItems = fromVssProject.get_Items(true); IEnumerator enumerator = childItems.GetEnumerator(); while (enumerator.MoveNext()) { var childItem = (IVSSItem)enumerator.Current; if (childItem != null) { if (childItem.Type == (int)VSSItemType.VSSITEM_PROJECT) { searchLog.InfoFormat("Scanning Project {0}", childItem.Spec); BuildRevisionList(childItem); BuildFileList(childItem); } else { // skip VSS metadata files. if (!Path.GetExtension(childItem.Name).Contains("scc")) { string fileSpec = childItem.Spec; if (vssFileExclusionRegex != null && vssFileExclusionRegex.IsMatch(fileSpec)) { searchLog.DebugFormat("Skipping file [Matched file exclusion regex] {0}", fileSpec); continue; } if (vssFileInclusionRegex != null && !vssFileInclusionRegex.IsMatch(fileSpec)) { searchLog.DebugFormat("Skipping file [Failed file inclusion regex] {0}", fileSpec); continue; } //fileList still used for internal checks fileList.Add(childItem); BuildRevisionList(childItem); } } } } }
/// <summary> /// /// </summary> /// <param name="vssFolder"></param> private static void DisplayFolderContent(IVSSItem vssFolder) { Console.Write("\n{0} contains:", vssFolder.Spec); foreach (VSSItem vssItem in vssFolder.get_Items(false)) { Console.Write(" {0}", vssItem.Name); } }
/// <summary> /// /// </summary> /// <param name="vssFolder"></param> private static void DisplayFolder(IVSSItem vssFolder) { Console.Write("{0} folder contains:", vssFolder.Spec); foreach (IVSSItem vssItem in vssFolder.get_Items(false)) { Console.Write(" {0}", vssItem.Name); } Console.WriteLine(); }
private void Checkout(IVSSItem checkoutItem, FileInfo localPath, int flags, string pattern) { //TODO: timestamp stuff switch (checkoutItem.Type) { case (int)VSSItemType.VSSITEM_PROJECT: // Item is a project. if (string.IsNullOrEmpty(pattern)) { // In the absence of a pattern, we'll checkout the entire project. checkoutItem.Checkout("", localPath.FullName, flags); } else { // If a pattern is provided, we process all subitems in the project. foreach (IVSSItem subItem in checkoutItem.get_Items(false)) { switch (subItem.Type) { case (int)VSSItemType.VSSITEM_PROJECT: // Subitem is a project. if (Recursive) { // We'll recursively checkout matching files in this project. Checkout(subItem, new FileInfo(System.IO.Path.Combine(localPath.FullName, subItem.Name)), flags, pattern); } break; case (int)VSSItemType.VSSITEM_FILE: // Subitem is a file. if (Regex.IsMatch(subItem.Name, pattern)) { // We'll checkout this file since it matches the search pattern. Checkout(subItem, localPath, flags, ""); } break; } } } break; case (int)VSSItemType.VSSITEM_FILE: // Item is a file. string filePath = System.IO.Path.Combine(localPath.FullName, checkoutItem.Name); checkoutItem.Checkout("", filePath, flags); break; } }
public static int GetItems(IVSSItem originalItem) { int total = 0; foreach (IVSSItem subItem in originalItem.get_Items(false)) { if (subItem.Type == VSSITEM_FILE && subItem.IsCheckedOut == VSSFILE_CHECKEDOUT_ME) { Console.WriteLine(subItem.Spec); total++; } else if (subItem.Type == VSSITEM_PROJECT) { total += GetItems(subItem); } } return total; }
private void ProjectDiff(string project) { // Recursively loop through our vss projects Log.LogMessage(MessageImportance.Low, "Processing project " + project); IVSSItem ssProj = this.Database.get_VSSItem(project, false); IVSSItems ssSubItems = ssProj.get_Items(false); foreach (IVSSItem subItem in ssSubItems) { if (subItem.Type == 0) { //Type=0 is a Project ProjectDiff(project + "/" + subItem.Name); } else { ItemDiff(subItem); } } }
protected void ProjectDiff(string Project) { // Recursively loop through our vss projects if (this.Verbose) { Log(Level.Info, "Processing project " + Project); } IVSSItem ssProj = this.Database.get_VSSItem(Project, false); IVSSItems ssSubItems = ssProj.get_Items(false); foreach (IVSSItem subItem in ssSubItems) { if (subItem.Type == 0) { //Type=0 is a Project ProjectDiff(Project + "/" + subItem.Name); } else { ItemDiff(subItem); } } }
/// <summary> /// Scans the Project Item for deleted files and removes their local /// copies from the local image of the project. Obeys the recursive setting /// (and thus optionally calls itself recursively). /// </summary> /// <param name="item">The VSS Item (project) to check for deletions</param> /// <param name="localPathPrefix">The path to the folder of the item being processed</param> public void RemoveDeletedFromLocalImage(IVSSItem item, string localPathPrefix) { IVSSItems items = item.get_Items(true); Hashtable deletedTable = BuildDeletedTable(items); IEnumerator ie = items.GetEnumerator(); while (ie.MoveNext()) { IVSSItem i = (IVSSItem) ie.Current; string localPath = System.IO.Path.Combine(localPathPrefix, i.Name); if (IsTrulyDeleted(deletedTable, i) && Exists(localPath)) { SetToWriteable(localPath); Delete(localPath); } else { if (IsProject(i) && Recursive) { RemoveDeletedFromLocalImage(i, System.IO.Path.Combine(localPathPrefix, i.Name)); } } } }