/// <summary> /// Gets the status for the files marked as 'modified', 'added', and 'unknown/untracked' (-mau option) /// </summary> /// <returns>A dictionary of hg status codes --> (a dictionary of file extensions --> a list of files)</returns> internal static Dictionary <string, Dictionary <string, List <string> > > GetStatusOfFilesOfInterest(HgRepository repository, ProjectFolderConfiguration configuration) { var statusOfFilesByExtension = new Dictionary <string, Dictionary <string, List <string> > >(StringComparer.InvariantCultureIgnoreCase); repository.CheckAndUpdateHgrc(); var args = new StringBuilder(); args.Append(" -mau "); // Only modified, added, and unknown (not tracked). // Don't use these, as they may mask some large files that are outside the included space, but that are too large, and already tracked. //foreach (var pattern in configuration.IncludePatterns) //.Select(pattern => Path.Combine(_pathToRepository, pattern))) //{ // args.Append(" -I " + SurroundWithQuotes(pattern)); //} foreach (var pattern in configuration.ExcludePatterns) //.Select(pattern => Path.Combine(_pathToRepository, pattern))) { args.Append(" -X " + HgRepository.SurroundWithQuotes(pattern)); } var result = repository.Execute(repository.SecondsBeforeTimeoutOnLocalOperation, "status", args.ToString()); var lines = result.StandardOutput.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { if (line.Trim() == string.Empty) { continue; } var status = line.Substring(0, 1); Dictionary <string, List <string> > statusToFilesMap; if (!statusOfFilesByExtension.TryGetValue(status, out statusToFilesMap)) { statusToFilesMap = new Dictionary <string, List <string> >(StringComparer.InvariantCultureIgnoreCase); statusOfFilesByExtension.Add(status, statusToFilesMap); } var filename = line.Substring(2); // ! data.txt var extension = Path.GetExtension(filename); if (string.IsNullOrEmpty(extension)) { extension = "noextensionforfile"; } extension = extension.Replace(".", null).ToLowerInvariant(); List <string> fileList; if (!statusToFilesMap.TryGetValue(extension, out fileList)) { fileList = new List <string>(); statusToFilesMap.Add(extension, fileList); } fileList.Add(filename); } return(statusOfFilesByExtension); }
public void RepositoryRecoversFromIncompleteMerge() { using (var tempRepo = new TemporaryFolder("ChorusIncompleteMerge")) { var baseDir = PathHelper.NormalizePath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase)); baseDir = PathHelper.StripFilePrefix(baseDir); string zipPath = Path.Combine(baseDir, Path.Combine("VcsDrivers", Path.Combine("TestData", "incompletemergerepo.zip"))); FastZip zipFile = new FastZip(); zipFile.ExtractZip(zipPath, tempRepo.Path, null); var hgRepo = new HgRepository(tempRepo.Path, new NullProgress()); hgRepo.CheckAndUpdateHgrc(); var parentFile = tempRepo.GetNewTempFile(true); File.WriteAllText(parentFile.Path, "New Content"); var exception = Assert.Throws <ApplicationException>(() => hgRepo.AddAndCheckinFile(parentFile.Path)); Assert.That(exception.Message.Contains("Unable to recover") && !exception.Message.Contains("unresolved merge"), String.Format("Repository should have conflict in retrying the merge, but not have an incomplete merge: {0}", exception.Message)); } }
public void RepositoryRecoversFromIncompleteMerge() { using (var tempRepo = new TemporaryFolder("ChorusIncompleteMerge")) { var baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase); #if MONO baseDir = baseDir.Replace(@"file:", null); #else baseDir = baseDir.Replace(@"file:\", null); #endif var zipFile = new ZipFile(Path.Combine(baseDir, Path.Combine("VcsDrivers", Path.Combine("TestData", "incompletemergerepo.zip")))); zipFile.ExtractAll(tempRepo.Path); var hgRepo = new HgRepository(tempRepo.Path, new NullProgress()); hgRepo.CheckAndUpdateHgrc(); var parentFile = tempRepo.GetNewTempFile(true); File.WriteAllText(parentFile.Path, "New Content"); var exception = Assert.Throws <ApplicationException>(() => hgRepo.AddAndCheckinFile(parentFile.Path)); Assert.That(exception.Message.Contains("Unable to recover") && !exception.Message.Contains("unresolved merge"), "Repository should have conflict in retrying the merge, but not have an incomplete merge"); } }
/// <summary> /// Gets the status for the files marked as 'modified', 'added', and 'unknown/untracked' (-mau option) /// </summary> /// <returns>A dictionary of hg status codes --> (a dictionary of file extensions --> a list of files)</returns> internal static Dictionary<string, Dictionary<string, List<string>>> GetStatusOfFilesOfInterest(HgRepository repository, ProjectFolderConfiguration configuration) { var statusOfFilesByExtension = new Dictionary<string, Dictionary<string, List<string>>>(StringComparer.InvariantCultureIgnoreCase); repository.CheckAndUpdateHgrc(); var args = new StringBuilder(); args.Append(" -mau "); // Only modified, added, and unknown (not tracked). // Don't use these, as they may mask some large files that are outside the included space, but that are too large, and already tracked. //foreach (var pattern in configuration.IncludePatterns) //.Select(pattern => Path.Combine(_pathToRepository, pattern))) //{ // args.Append(" -I " + SurroundWithQuotes(pattern)); //} foreach (var pattern in configuration.ExcludePatterns) //.Select(pattern => Path.Combine(_pathToRepository, pattern))) { args.Append(" -X " + HgRepository.SurroundWithQuotes(pattern)); } var result = repository.Execute(repository.SecondsBeforeTimeoutOnLocalOperation, "status", args.ToString()); var lines = result.StandardOutput.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { if (line.Trim() == string.Empty) continue; var status = line.Substring(0, 1); Dictionary<string, List<string>> statusToFilesMap; if (!statusOfFilesByExtension.TryGetValue(status, out statusToFilesMap)) { statusToFilesMap = new Dictionary<string, List<string>>(StringComparer.InvariantCultureIgnoreCase); statusOfFilesByExtension.Add(status, statusToFilesMap); } var filename = line.Substring(2); // ! data.txt var extension = Path.GetExtension(filename); if (string.IsNullOrEmpty(extension)) extension = "noextensionforfile"; extension = extension.Replace(".", null).ToLowerInvariant(); List<string> fileList; if (!statusToFilesMap.TryGetValue(extension, out fileList)) { fileList = new List<string>(); statusToFilesMap.Add(extension, fileList); } fileList.Add(filename); } return statusOfFilesByExtension; }
public void RepositoryRecoversFromIncompleteMerge() { using (var tempRepo = new TemporaryFolder("ChorusIncompleteMerge")) { var baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase); #if MONO baseDir = baseDir.Replace(@"file:", null); #else baseDir = baseDir.Replace(@"file:\", null); #endif var zipFile = new ZipFile(Path.Combine(baseDir, Path.Combine("VcsDrivers", Path.Combine("TestData", "incompletemergerepo.zip")))); zipFile.ExtractAll(tempRepo.Path); var hgRepo = new HgRepository(tempRepo.Path, new NullProgress()); hgRepo.CheckAndUpdateHgrc(); var parentFile = tempRepo.GetNewTempFile(true); File.WriteAllText(parentFile.Path, "New Content"); var exception = Assert.Throws<ApplicationException>(() => hgRepo.AddAndCheckinFile(parentFile.Path)); Assert.That(exception.Message.Contains("Unable to recover") && !exception.Message.Contains("unresolved merge"), "Repository should have conflict in retrying the merge, but not have an incomplete merge"); } }