示例#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
        /// <summary>
        /// decompose just one changeset.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="pathVer"></param>
        public void query(string path, VersionSpec pathVer)
        {
            if (pathVer == null)
            {
                pathVer = VersionSpec.Latest;
            }

            Item item = _getItem(path, pathVer, 0, false);

            saastdlib.Timer t = new saastdlib.Timer();

            t.start();
            {
                ChangesetVersionSpec csVer = pathVer as ChangesetVersionSpec;

                /* sanity check... */
                if (csVer == null)
                {
                    throw new System.ArgumentException("pathVer must be a ChangesetVersionSpec.");
                }

                QueryProcessor qp     = new QueryProcessor(this, THREAD_COUNT);
                string         branch = tfsinterface.Utils.GetEGSBranch(item.ServerItem);

                Logger.logger.DebugFormat("queuing work.");
                Logger.logger.DebugFormat("q[{0}]", csVer.ChangesetId);

                Revision rev = _results.getRevision(csVer.ChangesetId);

                if (rev == null)
                {
                    Changeset cs = getCS(csVer.ChangesetId);

                    _queueOrVisit(qp, cs, this._baseDistance, null);
                }
                else
                {
                    _queueParents(qp, rev);
                }
                qp.runThreads();

                _results.setFirstID(csVer.ChangesetId);
            }
            t.stop();

            Logger.logger.DebugFormat("mh_q[{0} queries took {1}]", this.QueryCount, this.QueryTime);
            Logger.logger.DebugFormat("mh_q[{0} get items took {1}]", this.GetItemCount, this.GetItemTime);
            Logger.logger.DebugFormat("mh_q[{0} get changesets took {1}]",
                                      this.GetChangesetCount, this.GetChangesetTime);
            Logger.logger.DebugFormat("mh_q[max query time {0}", this.QueryTimeMax);
            Logger.logger.DebugFormat("mh_q[total time {0}]", t.Total);
        }
示例#3
0
        /// <summary>
        /// get a changeset.
        /// </summary>
        /// <param name="csID"></param>
        /// <returns></returns>
        public Changeset getCS(int csID)
        {
            saastdlib.Timer t = new saastdlib.Timer();
            t.start();
            Changeset cs = _vcs.GetChangeset(csID);

            t.stop();

            lock (_gct)
            {
                ++_gcc;
                _gct.TotalT += t.DeltaT;
            }

            return(cs);
        }
示例#4
0
        private Item _getItem(string targetPath, VersionSpec targetVer, int deletionID, bool downloadInfo)
        {
            saastdlib.Timer t = new saastdlib.Timer();

            t.start();
            Item itm = _vcs.GetItem(targetPath, targetVer, deletionID, downloadInfo);

            t.stop();

            lock (_git)
            {
                ++_gic;
                _git.TotalT += t.DeltaT;
            }

            return(itm);
        }
示例#5
0
        /// <summary>
        /// this function acts as a proxy for the function below it.
        /// </summary>
        public IList <QueryRec> queryMerge(Changeset cs, string targetPath, int distance)
        {
            saastdlib.Timer t = new saastdlib.Timer();
            t.start();

            /* pull down the item type.
             * i need this to determine params for the querymergedetails call.
             */
            Item itm = _getItem(targetPath, cs.ChangesetId, 0, false);

            IList <QueryRec> queries = queryMerge(cs, itm, distance);

            t.stop();
            Logger.logger.DebugFormat("qm[{0} queries took {1}]", this.QueryCount, this.QueryTime);
            Logger.logger.DebugFormat("qm[{0} get items took {1}]", this.GetItemCount, this.GetItemTime);
            Logger.logger.DebugFormat("qm[{0} get changesets took {1}]", this.GetChangesetCount, this.GetChangesetTime);
            Logger.logger.DebugFormat("qm[total time {1}]", t.Total);

            return(queries);
        }
示例#6
0
        /// <summary>
        /// run the threaded querymerges workers
        /// </summary>
        internal void runThreads()
        {
            Thread[]        threads = new Thread[_threadCount];
            saastdlib.Timer t       = new saastdlib.Timer();

            Logger.logger.DebugFormat("qp[using {0} threads]", _threadCount);

            t.start();
            for (int i = 0; i < threads.Length; ++i)
            {
                threads[i] = new Thread(new ParameterizedThreadStart(_qm_worker));

                threads[i].Priority = ThreadPriority.Lowest;
                threads[i].Start(null);
            }

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

            /* sanity check. */
            if (_queries.Count > 0)
            {
                throw new System.Exception("queue not empty!");
            }

            /* report some statistics. */
            Logger.logger.DebugFormat("qp<mh>[{0} queries took {1}]",
                                      _megahist.QueryCount, _megahist.QueryTime);
            Logger.logger.DebugFormat("qp<mh>[{0} get items took {1}]",
                                      _megahist.GetItemCount, _megahist.GetItemTime);
            Logger.logger.DebugFormat("qp<mh>[{0} get changesets took {1}]",
                                      _megahist.GetChangesetCount, _megahist.GetChangesetTime);
            Logger.logger.DebugFormat("qp<mh>[clock time={0}]", t.Delta);
        }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="pathVer"></param>
        /// <param name="limit"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="user"></param>
        public void query(string path, VersionSpec pathVer,
                          int limit, VersionSpec from, VersionSpec to,
                          string user)
        {
            if (pathVer == null)
            {
                pathVer = VersionSpec.Latest;
            }

            Item item = _getItem(path, pathVer, 0, false);

            saastdlib.Timer t = new saastdlib.Timer();

            t.start();
            query(item, limit, from, to, user);
            t.stop();

            Logger.logger.DebugFormat("mh_q[{0} queries took {1}]", this.QueryCount, this.QueryTime);
            Logger.logger.DebugFormat("mh_q[{0} get items took {1}]", this.GetItemCount, this.GetItemTime);
            Logger.logger.DebugFormat("mh_q[{0} get changesets took {1}]",
                                      this.GetChangesetCount, this.GetChangesetTime);
            Logger.logger.DebugFormat("mh_q[max query time {0}", this.QueryTimeMax);
            Logger.logger.DebugFormat("mh_q[total time {0}]", t.Total);
        }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cs"></param>
        /// <param name="targetItem"></param>
        /// <param name="distance"></param>
        /// <returns></returns>
        public IList <QueryRec> queryMerge(Changeset cs, Item targetItem, int distance)
        {
            string                srcPath   = null;
            VersionSpec           srcVer    = null;
            int                   srcDelID  = 0;
            VersionSpec           targetVer = new ChangesetVersionSpec(cs.ChangesetId);
            VersionSpec           fromVer   = targetVer;
            VersionSpec           toVer     = targetVer;
            RecursionType         recurType = RecursionType.None;     /* assume these are all files */
            ChangesetMergeDetails mergedetails;
            Revision              revision;

            ChangesetDict_T visitedItems;

            /* map a changeset id to a list of items in that changeset which were merged.
             * (that we happen to care about.
             */

            /* don't do queries when we've reached the distance limit. */
            if (distance == 0)
            {
                return(new List <QueryRec>());
            }

            if (targetItem.ItemType != ItemType.File)
            {
                recurType = RecursionType.Full;
            }

            Logger.logger.DebugFormat("qm[{0},{1},{2},{3},{4},{5},{6},{7},{8}]",
                                      (srcPath == null ? "(null)" : srcPath),
                                      (srcVer == null ? "(null)"  : srcVer.DisplayString), srcDelID,
                                      targetItem.ServerItem, targetVer.DisplayString, targetItem.DeletionId,
                                      fromVer.DisplayString, toVer.DisplayString, recurType);


            saastdlib.Timer t = new saastdlib.Timer();
            t.start();
            mergedetails =
                _vcs.QueryMergesWithDetails(srcPath, srcVer, srcDelID,
                                            targetItem.ServerItem, targetVer,
                                            targetItem.DeletionId,
                                            fromVer, toVer, recurType);
            t.stop();

            lock (_qt)
            {
                ++_qc;
                _qt.TotalT += t.DeltaT;

                if (t.DeltaT > _qtm)
                {
                    _qtm = t.DeltaT;
                }
            }
            t = null;

            visitedItems = _processDetails(cs.ChangesetId, mergedetails);

            {
                string itemPath = targetItem.ServerItem;
                if (targetItem.ItemType != ItemType.File)
                {
                    itemPath += '/';
                }

                Logger.logger.DebugFormat("v[{0}{1}]", itemPath, cs.ChangesetId);
                revision = _results.construct(itemPath, cs);
            }

            /* now walk the list of compiled changesetid + itempath and
             * construct a versioned item for each that we can actually go and query.
             */
            List <QueryRec> items = new List <QueryRec>();

            for (ChangesetDict_T.iterator it = visitedItems.begin();
                 it != visitedItems.end();
                 ++it)
            {
                Item itm = null;
                SortedPaths_T.iterator pathsIt = it.value().begin();

                revision.addParent(it.item());

                if ((distance - 1) > 0)
                {
                    /* only query the item info if we're going to do a query on it. */

                    if (it.value().size() > 1)
                    {
                        /* so, find out what this branch is and use the changeset id. */
                        string thisBranch = tfsinterface.Utils.GetEGSBranch(pathsIt.item());
                        string pathPart   = tfsinterface.Utils.GetPathPart(targetItem.ServerItem);

                        //Console.WriteLine("---- {0} => {1} + {2}", pair.Value.Values[0], thisBranch, pathPart);
                        if (!string.IsNullOrEmpty(thisBranch))
                        {
                            Logger.logger.DebugFormat("iqm[{0},{1}]",
                                                      thisBranch + "/EGS/" + pathPart,
                                                      it.item());

                            itm = _getItem(thisBranch + "/EGS/" + pathPart,
                                           it.item(), 0, false);
                        }
                        else
                        {
                            System.Console.WriteLine("---[e] {0}", pathsIt.item());
                        }
                    }
                    else
                    {
                        /* so, this is the only file we noticed for this changeset,
                         * spawn a new query for just this file (folder?)
                         */

                        Logger.logger.DebugFormat("iq1[{0},{1}]", pathsIt.item(), it.item());

                        try {
                            itm = _getItem(pathsIt.item(), it.item(), 0, false);
                        } catch (System.Exception ex)
                        {
                            Logger.logger.Fatal("fatal item query:", ex);

                            try {
                                /* try just the path, i doubt this will work either, but *shrug* */
                                itm = _getItem(pathsIt.item());
                            } catch (System.Exception) { itm = null; }
                        }
                    }

                    /* queue it. */
                    if (itm != null)
                    {
                        if (!_results.visited(it.item()))
                        {
                            QueryRec rec = new QueryRec
                            {
                                id       = it.item(),
                                item     = itm,
                                distance = (distance - 1),
                            };

                            items.Add(rec);
                        }
                    }
                }
            }

            return(items);
        }