Пример #1
0
        // ------------------------------------------------------------------------
        // run a HG root status query and get the resulting status informations to a fileStatusDictionary
        // ------------------------------------------------------------------------
        public static bool QueryRootStatus(string rootDirectory, out Dictionary <string, char> fileStatusDictionary)
        {
            Trace.WriteLine("Start QueryRootStatus");

            fileStatusDictionary = null;

            if (rootDirectory != string.Empty)
            {
                fileStatusDictionary = new Dictionary <string, char>();

                // Start a new process for the cmd
                Process process = HG.InvokeCommand(rootDirectory, "status -m -a -r -d -c -C ");

                List <string> lines = new List <string>();

                string str = "";
                while (!process.HasExited)
                {
                    while ((str = process.StandardOutput.ReadLine()) != null)
                    {
                        lines.Add(str);
                    }
                    Thread.Sleep(0);
                }

                while ((str = process.StandardOutput.ReadLine()) != null)
                {
                    lines.Add(str);
                }

                Dictionary <string, string> renamedToOrgFileDictionary = new Dictionary <string, string>();
                UpdateStatusDictionary(lines, rootDirectory, fileStatusDictionary, renamedToOrgFileDictionary);
            }
            return(fileStatusDictionary != null);
        }
Пример #2
0
        // ------------------------------------------------------------------------
        // build the argument sting from the given files and call invoke the hg command
        // ------------------------------------------------------------------------
        static void InvokeCommand(string command, string[] fileList, bool directoriesAllowed)
        {
            string        workingDirectory = fileList[0].Substring(0, fileList[0].LastIndexOf('\\'));
            string        rootDirectory    = HG.FindRootDirectory(workingDirectory);
            List <string> list;
            string        commandString = command;
            int           counter       = 0;

            foreach (var file in fileList)
            {
                ++counter;

                if (!directoriesAllowed && file.EndsWith("\\"))
                {
                    continue;
                }

                commandString += " \"" + file.Substring(rootDirectory.Length + 1) + "\" ";

                if (counter > 20 || commandString.Length > 1024)
                {
                    HG.InvokeCommand(rootDirectory, commandString, out list);
                    commandString = command;
                }
            }


            HG.InvokeCommand(rootDirectory, commandString, out list);
        }
Пример #3
0
        // ------------------------------------------------------------------------
        // get current used brunchname of repository
        // ------------------------------------------------------------------------
        public static string GetCurrentBranchName(string rootDirectory)
        {
            string branchName = "";

            List <string> resultList;

            HG.InvokeCommand(rootDirectory, "branch", out resultList);

            if (resultList.Count > 0)
            {
                branchName = resultList[0];
            }

            return(branchName);
        }
Пример #4
0
        // ------------------------------------------------------------------------
        // invoke the given command and get the new status of dependend files
        // to the dictionary
        // ------------------------------------------------------------------------
        static bool InvokeCommandGetStatus(string cmd, string[] fileList, out Dictionary <string, char> fileStatusDictionary)
        {
            fileStatusDictionary = null;
            try
            {
                HG.InvokeCommand(cmd, fileList, false);

                if (!QueryFileStatus(fileList, out fileStatusDictionary))
                {
                    fileStatusDictionary = null;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("cmd- " + ex.Message);
                return(false);
            }
            return(fileStatusDictionary != null);
        }
Пример #5
0
        // ------------------------------------------------------------------------
        // enter file renamed to hg repository
        // ------------------------------------------------------------------------
        static public bool EnterFileRenamed(string[] orgFileName, string[] newFileName)
        {
            try
            {
                for (int pos = 0; pos < orgFileName.Length; ++pos)
                {
                    string workingDirectory = orgFileName[pos].Substring(0, orgFileName[pos].LastIndexOf('\\'));
                    string rootDirectory    = HG.FindRootDirectory(workingDirectory);

                    string        ofile = orgFileName[pos].Substring(rootDirectory.Length + 1);
                    string        nfile = newFileName[pos].Substring(rootDirectory.Length + 1);
                    List <string> list;
                    HG.InvokeCommand(rootDirectory,
                                     "rename  -A \"" + ofile + "\" \"" + nfile + "\"", out list);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("HG.EnterFileRenamed exception- " + ex.Message);
                return(false);
            }

            return(true);
        }