コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cs"></param>
        /// <param name="op"></param>
        /// <returns></returns>
        public static List <string> FindChangesetBranches(Changeset cs,
                                                          ChangeTypeToConsiderDelegate op)
        {
            saastdlib.Timer timer        = new saastdlib.Timer();
            List <string>   itemBranches = new List <string>();

            ++FindChangesetBranchesCalls;

            Logger.LoadLogger();

            timer.start();
            if (cs.Changes.Length > NonThreadedFindLimit)
            {
                itemBranches = _Get_egs_branches_threaded(cs, op);
            }
            else
            {
                itemBranches = _Get_egs_branches_nonthreaded(cs, op);
            }
            timer.stop();

            Logger.logger.DebugFormat("branches for {0} took: {1}", cs.ChangesetId, timer.Delta);

            return(itemBranches);
        }
コード例 #2
0
        /** this starts the worker threads and then waits for their results.
         */
        private static List <string> _Get_egs_branches_threaded(Changeset cs,
                                                                ChangeTypeToConsiderDelegate op)
        {
            System.Threading.Thread[] threads;
            _args args = new _args();

            {
                int cnt = FIND_THREAD_COUNT;
                if (cnt < 1)
                {
                    cnt = Environment.ProcessorCount;
                    if (cnt < 1)
                    {
                        cnt = 2;
                    }
                }
                threads = new System.Threading.Thread[cnt];
            }

            args.itemBranches = new List <string>();
            args.rwlock       = new System.Threading.ReaderWriterLock();
            args.changesLen   = cs.Changes.Length;
            args.changes      = cs.Changes;
            args.op           = op;

            for (int i = 0; i < threads.Length; ++i)
            {
                threads[i]          = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(_egsbranches_worker));
                threads[i].Priority = System.Threading.ThreadPriority.Lowest;
                threads[i].Start(args);
            }

            for (int i = 0; i < threads.Length; ++i)
            {
                threads[i].Join();
            }

            return(args.itemBranches);
        }
コード例 #3
0
        private static List <string> _Get_egs_branches_nonthreaded(Changeset cs,
                                                                   ChangeTypeToConsiderDelegate op)
        {
            List <string> itemBranches = new List <string>();

            int changesLen = cs.Changes.Length;

            for (int i = 0; i < changesLen; ++i)
            {
                Change cng = cs.Changes[i];
                if (op(cng))
                {
                    string itemPath = cng.Item.ServerItem;
                    bool   found    = false;
                    int    idx      = 0;

                    /* this probably looks bad,
                     * but since there won't be more than a few branches in a given
                     * changeset, this is efficient enough, and simple.
                     * this should hold true:
                     *   itemBranches.Count < 4
                     */
                    for (int j = 0; j < itemBranches.Count; ++j)
                    {
                        /* the stupid branches are not case sensitive. */
                        idx = itemPath.IndexOf(itemBranches[j], StringComparison.InvariantCultureIgnoreCase);
                        if (idx == 0)
                        {
                            found = true; break;
                        }
                    }

                    if (!found)
                    {
                        /* yeah steve, '/EGS8.2' sucks now doesn't it... */
                        string str = "/EGS/";

                        /* the stupid branches are not case sensitive. */
                        idx = itemPath.IndexOf(str, StringComparison.InvariantCultureIgnoreCase);

                        if (idx > 0)
                        {
                            itemPath = itemPath.Substring(0, idx + str.Length);
#if DEBUG
                            if (itemPath.IndexOf("$/IGT_0803/") == 0)
                            {
#endif
                            Logger.logger.DebugFormat("branch={0}", itemPath);
                            itemBranches.Add(itemPath);
#if DEBUG
                        }
                        else
                        {
                            Console.Error.WriteLine("'{0}' turned into '{1}'!",
                                                    cs.Changes[i].Item.ServerItem,
                                                    itemPath);
                        }
#endif
                        }
                    }
                }
            }

            return(itemBranches);
        }