public static void ShowHistoryWindow(string fileName) { var root = HgPath.FindRepositoryRoot(fileName); if (!String.IsNullOrEmpty(root)) { fileName = fileName.Substring(root.Length + 1); Start(String.Format("history \"{0}\"", fileName), root); } }
protected void UpdateRootStatusProtected(string path) { var root = HgPath.FindRepositoryRoot(path); if (String.IsNullOrEmpty(root)) { return; } AddRoot(root); Cache(Hg.GetRootStatus(root)); }
private static void StartForEachRoot(string command, string[] files) { var commandWithOptions = String.Concat("--nofork ", command); foreach (var group in files.GroupBy(x => HgPath.FindRepositoryRoot(x))) { if (String.IsNullOrEmpty(group.Key)) { continue; } Start(commandWithOptions, group.Key, group); } }
protected virtual bool FileChangeIsOfInterest(string fileName) { if (HgPath.IsDirectory(fileName)) { return(false); } if (fileName.IndexOf(@"\.hg") != -1) { return(false); } return(HasChanged(fileName)); }
public static string CreateParentRevisionTempFile(string fileName, string root) { var tempFileName = HgPath.GetRandomTemporaryFileName(); tempFileName = Path.ChangeExtension(tempFileName, Path.GetExtension(fileName)); var command = String.Format("cat \"{0}\" -o \"{1}\"", HgPath.StripRoot(fileName, root), tempFileName); Run(command, root); Debug.Assert(File.Exists(tempFileName)); return(tempFileName); }
public static HgFileInfo[] RenameFiles(string[] fileNames, string[] newFileNames) { for (int i = 0; i < Math.Min(fileNames.Length, newFileNames.Length); i++) { var root = HgPath.FindRepositoryRoot(fileNames[i]); var oldName = HgPath.StripRoot(fileNames[i], root); var newName = HgPath.StripRoot(newFileNames[i], root); var option = StringComparer.InvariantCultureIgnoreCase.Equals(oldName, newName) ? null : " -A"; Run(String.Format("rename {0} \"{1}\" \"{2}\"", option, oldName, newName), root); } return(GetFileInfo(fileNames.Concat(newFileNames).ToArray())); }
private static void Start(string command, string root, IEnumerable <string> files) { var listFile = HgPath.GetRandomTemporaryFileName(); var listCommand = String.Format("{0} --listfile \"{1}\"", command, listFile); CreateListFile(listFile, files); var process = Start(listCommand, root); try { process.WaitForExit(); } catch (InvalidOperationException) { } DeleteListFile(listFile); }
private static string[] GetFileArguments(string root, IEnumerable <string> fileNames) { var args = new List <string>(); var sb = new StringBuilder(); foreach (var fileName in fileNames.Where(x => !HgPath.IsDirectory(x)).Select(x => HgPath.StripRoot(x, root))) { if (sb.Length > ArgumentsLengthLimit - fileName.Length - 3) { args.Add(sb.ToString()); sb.Length = 0; } sb.Append(' ').Append('"').Append(fileName).Append('"'); } args.Add(sb.ToString()); return(args.ToArray()); }
private static Dictionary <string, string[]> ProcessFiles(string command, string[] fileNames) { var rootOutput = new Dictionary <string, string[]>(); foreach (var rootGroup in fileNames.GroupBy(x => HgPath.FindRepositoryRoot(x))) { var root = rootGroup.Key; var output = new List <string>(); foreach (var fileArgs in GetFileArguments(root, rootGroup)) { var commandOutput = Run(String.Concat(command, fileArgs), root); output.AddRange(commandOutput); } rootOutput[root] = output.ToArray(); } return(rootOutput); }