/// <summary> /// Do a no-op merge. (See: http://mercurial.selenic.com/wiki/PruningDeadBranches#No-Op_Merges) /// </summary> private void NoopMerge(HgRepository repo, Revision keeperRevision, Revision gonerRevision) { string optionalComment = null; using (var optionalCommentDlg = new OptionalCommentDlg()) { if (optionalCommentDlg.ShowDialog(this) == DialogResult.OK && !string.IsNullOrWhiteSpace(optionalCommentDlg.OptionalComment)) { optionalComment = optionalCommentDlg.OptionalComment.Trim(); } } // Merge goner into keeper. repo.Merge(_repoFolder, gonerRevision.Number.LocalRevisionNumber); // Revert the merge. repo.Execute(repo.SecondsBeforeTimeoutOnMergeOperation, "revert", "-a", "-r", keeperRevision.Number.LocalRevisionNumber); // Commit var comment = string.Format(@"No-Op Merge: Revert repository to revision '{0}'", keeperRevision.Number.LocalRevisionNumber); if (!string.IsNullOrWhiteSpace(optionalComment)) { comment = string.Format(@"{0}. {1}", comment, optionalComment); } repo.Commit(true, comment); }
/// <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); }
private void SetLongHash(HgRepository repository) { if (repository == null) { return; } if (string.IsNullOrWhiteSpace(repository.Identifier)) { // No commits yet. return; } var result = repository.Execute(repository.SecondsBeforeTimeoutOnLocalOperation, string.Format("log -r{0} --template {1}", LocalRevisionNumber, HgRepository.SurroundWithQuotes("{node}"))).StandardOutput.Trim(); var strArray = result.Split(new[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries); LongHash = strArray[checked (strArray.Length - 1)]; }
/// <summary> /// Do a no-op merge. (See: http://mercurial.selenic.com/wiki/PruningDeadBranches#No-Op_Merges) /// </summary> private void NoopMerge(HgRepository repo, Revision keeperRevision, Revision gonerRevision) { string optionalComment = null; using (var optionalCommentDlg = new OptionalCommentDlg()) { if (optionalCommentDlg.ShowDialog(this) == DialogResult.OK && !string.IsNullOrWhiteSpace(optionalCommentDlg.OptionalComment)) { optionalComment = optionalCommentDlg.OptionalComment.Trim(); } } // Merge goner into keeper. repo.Merge(_repoFolder, gonerRevision.Number.LocalRevisionNumber); // Revert the merge. repo.Execute(repo.SecondsBeforeTimeoutOnMergeOperation, "revert", "-a", "-r", keeperRevision.Number.LocalRevisionNumber); // Commit var comment = string.Format(@"No-Op Merge: Revert repository to revision '{0}'", keeperRevision.Number.LocalRevisionNumber); if (!string.IsNullOrWhiteSpace(optionalComment)) comment = string.Format(@"{0}. {1}", comment, optionalComment); repo.Commit(true, comment); }
/// <summary> /// For use when updating a model version for the repository, /// sets the current branch on the repo and the ClientVersion property to the given branch name /// </summary> /// <param name="progress"></param> /// <param name="branchName"></param> public void Branch(IProgress progress, string branchName) { progress.WriteVerbose("{0} changing working dir to branch: {1}", UserId, branchName); _repo.Execute(_repo.SecondsBeforeTimeoutOnLocalOperation, "branch -f ", HgRepository.SurroundWithQuotes(branchName)); ClientVersion = branchName; }
/// <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; }