Пример #1
0
        public Change[] GetRemainingChanges(SDOperations sd)
        {
            List <Change> changes = new List <Change>();
            List <string> lines   = new List <string>(sd.GetAllOpenedFiles(_clients[0].Path));
            Dictionary <string, Change> defaultChangeByClient = new Dictionary <string, Change>();

            foreach (string line in lines)
            {
                // Parse a line something like:
                // //depot/ChangeLister/ProcessHelper.cs#1 - edit default change (text) by REDMOND\geevens@GEEVENS-DEV-HP-D-TH2-HOLOLENS
                if (line.IndexOf(" default change ") != -1)
                {
                    string clientName = line.Split(new char[] { '@' })[1];  // everything after an '@'
                    clientName = clientName.Split(new char[] { ' ' })[0];   // everything before a ' '
                    if (!defaultChangeByClient.ContainsKey(clientName))
                    {
                        Change change = new Change();
                        change.Client           = GetClient(clientName);
                        change.Number           = "default";
                        change.ShortDescription = "default changelist for " + change.Client.Name;
                        change.LongDescription  = new List <string>();
                        change.LongDescription.Add(change.ShortDescription);
                        change.FileList = new List <string>();
                        defaultChangeByClient.Add(clientName, change);
                    }
                    defaultChangeByClient[clientName].FileList.Add(line.Split(new char[] { '#' })[0]);
                }
            }

            foreach (Change change in defaultChangeByClient.Values)
            {
                changes.Add(change);
            }

            return(changes.ToArray());
        }
Пример #2
0
        static void Main(string[] args)
        {
            string path         = @"...";
            bool   ignoreCase   = true;
            string search       = string.Empty;
            bool   relativePath = false;

            for (int ii = 0; ii < args.Length; ii++)
            {
                // handle other command line args
                string arg = args[ii];
                if (arg.StartsWith("/") || arg.StartsWith("-"))
                {
                    switch (arg.Substring(1).ToLower())
                    {
                    case "path":
                        path = args[++ii];
                        break;

                    case "ic":
                    case "ignorecase":
                        ignoreCase = true;
                        break;

                    case "c":
                    case "case":
                    case "casesensitive":
                        ignoreCase = false;
                        break;

                    case "rel":
                    case "relative":
                    case "relativepath":
                        relativePath = true;
                        break;

                    default:
                        Console.WriteLine("Unknown argument: " + arg);
                        PrintUsage();
                        return;
                    }
                }
                else
                {
                    search = arg;
                }
            }

            string currentDir = System.IO.Directory.GetCurrentDirectory() + @"\";

            Console.WriteLine("path: " + path);
            Console.WriteLine("ignoreCase: " + ignoreCase);
            Console.WriteLine("search: " + search);
            Console.WriteLine("relativePath: " + relativePath);
            Console.WriteLine("currentDir: " + currentDir);

            StringComparison comparison = ignoreCase ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture;

            SDOperations sd = new SDOperations(@"redmond\geevens");

            Console.WriteLine("SDRoot: " + sd.SDRoot);

            Console.WriteLine();
            OldLogger.AnnounceStartStopActions = false;

            SDOperations.File[] files = sd.GetFiles(currentDir, path);
            foreach (SDOperations.File file in files)
            {
                var localPath = file.LocalPath;
                Debug.Assert(localPath.ToLower().StartsWith(currentDir.ToLower()));
                if (relativePath)
                {
                    localPath = localPath.Substring(currentDir.Length);
                }
                if (localPath.IndexOf(search, comparison) != -1)
                {
                    Console.WriteLine(localPath);
                }
            }
        }