Пример #1
0
        /// <summary>
        /// this adds in the parents as part of the branch's standard history list.
        /// </summary>
        /// <param name="history"></param>
        /// <param name="visitor"></param>
        internal void fixHistory()
        {
            Revision prev = null;

            foreach (Changeset cs in _history)
            {
                string id = TFSDB.MakeID(cs.ChangesetId);

                if (prev != null)
                {
                    /* fix up the parent.
                     * this will only add the parent if they're not already in the list.
                     */
                    prev.addParent(id);
                }

                /* lookup the item for the next round.
                 * everything we're looking for should already be in the visitor
                 * if it's not, there's a problem with the algorithm.
                 */
                Revision rev = _visitor.rev(id);

                /* sanity check. */
                if (rev == null)
                {
                    logger.ErrorFormat("didn't find {0}!", id);
                }

                prev = rev;
            }
        }
Пример #2
0
        public override Snapshot getBranch(string branch, long limit)
        {
            Snapshot sn = null;

            /* get the last x changesets from tfs. */
            TFSDB db = TFSDB.QueryHistory(_vcs, branch, (ulong)limit, null, _cache);

            {
                string[] bs = branches();
                db.visitor.primeBranches(bs);
            }

            /* copy stuff we've already seen from the db cache into the visitor cache.
             * this only does the top-level stuff
             * any further queries we get will be passed to the cache.
             */
            foreach (Changeset cs in db.history)
            {
                Revision rev = _cache.rev(TFSDB.MakeID(cs.ChangesetId));
                if (rev != null)
                {
                    db.visitor.addRevision(rev);
                }
            }

            /* prime the merge history querying.
             * this will take out all top-level queries which have already been done.
             * already been done = exists in cache.
             *
             * this will also query tfs for the merge info.
             */
            db.queryMerges();

            /* at this point, ALL the changesets in 'history' MUST be in the visitor.
             * if not, then there's a problem with:
             *  insertQueries or the QueryProcessor.
             */

            /* this adds in the branch's history to the parent lists of the
             * appropriate changesets.
             * this will also update the cache
             */
            db.fixHistory();

            /* now dump everything in the visitor to the cache. */
            db.visitor.save(_cache);

            db = null;

            /* the full list should be in the cache now. */
            sn = _cache.getBranch(branch, (ulong)limit);

            return(sn);
        }
Пример #3
0
        public bool visited(string branch, int csID)
        {
            Revision rev = null;

            if (_csMux.WaitOne())
            {
                string id = TFSDB.MakeID(csID);
                rev = this.rev(id);
            }
            _csMux.ReleaseMutex();

            return(rev != null);
        }
Пример #4
0
        // public void addRevision(Revision rev, bool replace)
        // {
        //  if (replace)
        //      {
        //          /* overwrite the existing one.
        //           * since this is a reference type and not a value type,
        //           * changing the one in the index should alter the rest
        //           * (they should all point to the same object)
        //           */
        //          RevisionIdx.iterator it = this._changesetIdx.find(rev.ID);
        //          if (it != _changesetIdx.end())
        //              {
        //                  /* so, we already have the changeset.
        //                   * let's change some stuff about it.
        //                   */
        //                  it.value().Branch = rev.Branch;
        //                  it.value().Author = rev.Author;
        //                  it.value().Date = new System.DateTime(rev.Date.Ticks, rev.Date.Kind);
        //                  it.value().Log = rev.Log;
        //                  foreach(string p in rev.Parents) { it.value().addParent(p); }
        //              }
        //          else { addRevision(rev); }
        //      }
        //  else { addRevision(rev); }
        // }

        public Revision visit(string branch, Changeset cs)
        {
            Revision rev = null;

            if (_csMux.WaitOne())
            {
                string id = TFSDB.MakeID(cs.ChangesetId);

                rev = base.rev(id);

                if (rev == null)
                {
                    System.DateTime t;

                    if (cs.CreationDate.Kind == System.DateTimeKind.Unspecified)
                    {
                        t = System.DateTime.SpecifyKind(cs.CreationDate, System.DateTimeKind.Local);
                    }
                    else
                    {
                        t = cs.CreationDate;
                    }

                    rev = new Revision(id, branch,
                                       cs.Owner, cs.CreationDate,
                                       cs.Comment);

                    rev.Branch = megahistory.Utils.GetEGSBranch(branch) + "/EGS/";
                    rev.Branch = cleanseBranch(rev.Branch);
                    //logger.DebugFormat("{0}=>{1}", rev.Branch, cs.ChangesetId);

                    _addRevision(rev);
                }
            }
            _csMux.ReleaseMutex();

            return(rev);
        }
Пример #5
0
 public void addParent(Revision rev, int parentID)
 {
     rev.addParent(TFSDB.MakeID(parentID));
 }