private static void FilterFiles(HgRepository repository, ProjectFolderConfiguration configuration, IDictionary <string, uint> extensionToMaximumSize, StringBuilder messageBuilder, string repositoryBasePath, Dictionary <string, List <string> > extensionToFilesMap, string userNotificationMessageBase, bool forgetItIfTooLarge) { foreach (var filesOfOneExtension in extensionToFilesMap) { var maxForExtension = GetMaxSizeForExtension(extensionToMaximumSize, filesOfOneExtension.Key); foreach (var partialPathname in filesOfOneExtension.Value) { var fullPathname = Path.Combine(repositoryBasePath, partialPathname); var fileInfo = new FileInfo(fullPathname); var fileSize = fileInfo.Length; if (fileSize <= maxForExtension) { continue; } var fileSizeString = (fileSize / (float)Megabyte).ToString("0.00") + " Megabytes"; var maxSizeString = (maxForExtension / (float)Megabyte).ToString("0.0") + " Megabytes"; messageBuilder.AppendLine(String.Format(userNotificationMessageBase, Path.GetFileName(fullPathname), fileSizeString, maxSizeString, fullPathname)); var shortPathname = fullPathname.Replace(repositoryBasePath, null); configuration.ExcludePatterns.Add(shortPathname); if (forgetItIfTooLarge) { repository.ForgetFile(shortPathname); } } } }
private static void FilterFiles(HgRepository repository, ProjectFolderConfiguration configuration, IDictionary<string, uint> extensionToMaximumSize, StringBuilder messageBuilder, string repositoryBasePath, Dictionary<string, List<string>> extensionToFilesMap, string userNotificationMessageBase, bool forgetItIfTooLarge) { foreach (var filesOfOneExtension in extensionToFilesMap) { var maxForExtension = GetMaxSizeForExtension(extensionToMaximumSize, filesOfOneExtension.Key); foreach (var partialPathname in filesOfOneExtension.Value) { var fullPathname = Path.Combine(repositoryBasePath, partialPathname); var fileInfo = new FileInfo(fullPathname); var fileSize = fileInfo.Length; if (fileSize <= maxForExtension) continue; var fileSizeString = (fileSize / (float)Megabyte).ToString("0.00") + " Megabytes"; var maxSizeString = (maxForExtension / (float)Megabyte).ToString("0.0") + " Megabytes"; messageBuilder.AppendLine(String.Format(userNotificationMessageBase, Path.GetFileName(fullPathname), fileSizeString, maxSizeString, fullPathname)); var shortPathname = fullPathname.Replace(repositoryBasePath, null); configuration.ExcludePatterns.Add(shortPathname); if (forgetItIfTooLarge) repository.ForgetFile(shortPathname); } } }