StripRoot() public static method

public static StripRoot ( string fileName, string root ) : string
fileName string
root string
return string
Example #1
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);
        }
Example #2
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()));
        }
Example #3
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());
        }