Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        protected void UpdateRootStatusProtected(string path)
        {
            var root = HgPath.FindRepositoryRoot(path);

            if (String.IsNullOrEmpty(root))
            {
                return;
            }

            AddRoot(root);

            Cache(Hg.GetRootStatus(root));
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        protected virtual bool FileChangeIsOfInterest(string fileName)
        {
            if (HgPath.IsDirectory(fileName))
            {
                return(false);
            }

            if (fileName.IndexOf(@"\.hg") != -1)
            {
                return(false);
            }

            return(HasChanged(fileName));
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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()));
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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());
        }
Ejemplo n.º 9
0
        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);
        }