Beispiel #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;
            }
        }
Beispiel #2
0
        /// <summary>
        /// run VersionControlServer.QueryHistory
        /// </summary>
        internal static TFSDB QueryHistory(VersionControlServer vcs, string branch,
                                           ulong limit, string startID, SQLiteStorage.SQLiteCache cache)
        {
            TFSDB tfsdb = new TFSDB(vcs, branch, cache);

            tfsdb._history = new ChangesetsDesc();

            VersionSpec fromVer = null;
            VersionSpec toVer   = null;

            if (startID != null)
            {
                toVer = new ChangesetVersionSpec(startID);
            }

            logger.DebugFormat("qh[{0},{1}]", branch, limit);
            IEnumerable foo =
                vcs.QueryHistory(branch, VersionSpec.Latest, 0, RecursionType.Full,
                                 null, fromVer, toVer,                                                                 /* user, from ver, to ver */
                                 (int)limit,
                                 true, false, false);

            /* inc changes, slot mode, inc download info. */

            /* sort the changesets in Descending order */
            foreach (object o in foo)
            {
                tfsdb._history.insert(o as Changeset);
            }

            return(tfsdb);
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
0
        public override Snapshot queryMerges(Revision rev)
        {
            Snapshot sn = null;
            TFSDB    db = new TFSDB(_vcs, rev.Branch, _cache);

            /* add this revision to the visitor */
            db.visitor.addRevision(rev);

            /* generate a bunch of queries given this revision's parents.
             * then run the queries.
             */
            db.queueParents(rev);

            /* now dump the result back to the cache. */
            db.visitor.save(_cache);

            /* now run the query against the cache. */
            sn = _cache.queryMerges(rev);

            return(sn);
        }
Beispiel #6
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);
        }
Beispiel #7
0
 public void addParent(Revision rev, int parentID)
 {
     rev.addParent(TFSDB.MakeID(parentID));
 }
Beispiel #8
0
        public override string[] branches()
        {
            string[]   bs          = null;
            BranchCont brs         = new BranchCont();
            ItemDict   branchItems =
                megahistory.SCMUtils.GetBranches(_vcs,
                                                 "$/IGT_0803/main/EGS/", VersionSpec.Latest);

            /* throw the tfs branches into the branch container. */
            for (ItemDict.iterator it = branchItems.begin();
                 it != branchItems.end();
                 ++it)
            {
                string full_branch      = it.value().ServerItem + "/";
                BranchCont.iterator bit = brs.find(full_branch);
                if (bit == brs.end())
                {
                    brs.insert(full_branch);
                }
            }

            if (_cache.BranchNames.Any())
            {
                bs = _cache.BranchNames.ToArray();

                foreach (string str in bs)
                {
                    BranchCont.iterator bit = brs.find(str);
                    if (bit == brs.end())
                    {
                        brs.insert(str);
                    }
                    else
                    {
                        if (bit.item() != str)
                        {
                            /* well shit. tfs screwed up.
                             * correct tfs.
                             */
                            string tmp = bit.item();

                            bit = null;
                            /* this call will invalidate the iterator. */
                            brs.remove(tmp);
                            brs.insert(str);
                        }
                    }
                }
            }

            if (brs.size() > 0)
            {
                bs = new string[brs.size()];
                int i = 0;
                foreach (string str in brs)
                {
                    bs[i] = str;
                    ++i;
                }
            }
            else
            {
                /* this code should never run. */
                bs = TFSDB.DefaultBranches();
            }

            return(bs);
        }