reset() public method

public reset ( Repository repo, AnyObjectId id, WindowCursor curs ) : void
repo Repository
id AnyObjectId
curs WindowCursor
return void
Beispiel #1
0
        /**
         * Back door to quickly Create a subtree iterator for any subtree.
         * <para />
         * Don't use this unless you are ObjectWalk. The method is meant to be
         * called only once the current entry has been identified as a tree and its
         * identity has been converted into an ObjectId.
         *
         * @param repo
         *            repository to load the tree data from.
         * @param id
         *            ObjectId of the tree to open.
         * @param curs
         *            window cursor to use during repository access.
         * @return a new parser that walks over the current subtree.
         * @throws IOException
         *             a loose object or pack file could not be Read.
         */
        public CanonicalTreeParser createSubtreeIterator0(Repository repo, AnyObjectId id, WindowCursor curs)         // [henon] createSubtreeIterator0 <--- not a typo!
        {
            var p = new CanonicalTreeParser(this);

            p.reset(repo, id, curs);
            return(p);
        }
Beispiel #2
0
        private CanonicalTreeParser ParserFor(AnyObjectId id)
        {
            var p = new CanonicalTreeParser();

            p.reset(_db, id, _cursor);
            return(p);
        }
Beispiel #3
0
        /**
         * Reset this walker to run over a single existing tree.
         *
         * @param id
         *            the tree we need to parse. The walker will execute over this
         *            single tree if the reset is successful.
         * @throws MissingObjectException
         *             the given tree object does not exist in this repository.
         * @throws IncorrectObjectTypeException
         *             the given object id does not denote a tree, but instead names
         *             some other non-tree type of object. Note that commits are not
         *             trees, even if they are sometimes called a "tree-ish".
         * @throws CorruptObjectException
         *             the object claimed to be a tree, but its contents did not
         *             appear to be a tree. The repository may have data corruption.
         * @throws IOException
         *             a loose object or pack file could not be Read.
         */
        public void reset(AnyObjectId id)
        {
            if (_trees.Length == 1)
            {
                AbstractTreeIterator iterator = _trees[0];
                while (iterator.Parent != null)
                {
                    iterator = iterator.Parent;
                }

                CanonicalTreeParser oParse = (iterator as CanonicalTreeParser);
                if (oParse != null)
                {
                    iterator.Matches    = null;
                    iterator.MatchShift = 0;

                    oParse.reset(_db, id, _cursor);
                    _trees[0] = iterator;
                }
                else
                {
                    _trees[0] = ParserFor(id);
                }
            }
            else
            {
                _trees = new AbstractTreeIterator[] { ParserFor(id) };
            }

            _advance = false;
            _depth   = 0;
        }
Beispiel #4
0
        /**
         * Reset this parser to walk through the given tree.
         *
         * @param repo
         *            repository to load the tree data from.
         * @param id
         *            identity of the tree being parsed; used only in exception
         *            messages if data corruption is found.
         * @param curs
         *            window cursor to use during repository access.
         * @return the root level parser.
         * @throws MissingObjectException
         *             the object supplied is not available from the repository.
         * @throws IncorrectObjectTypeException
         *             the object supplied as an argument is not actually a tree and
         *             cannot be parsed as though it were a tree.
         * @throws IOException
         *             a loose object or pack file could not be Read.
         */
        public CanonicalTreeParser resetRoot(Repository repo, AnyObjectId id, WindowCursor curs)
        {
            CanonicalTreeParser p = this;

            while (p.Parent != null)
            {
                p = (CanonicalTreeParser)p.Parent;
            }
            p.reset(repo, id, curs);
            return(p);
        }
Beispiel #5
0
        /**
         * Reset this walker to run over a set of existing trees.
         *
         * @param ids
         *            the trees we need to parse. The walker will execute over this
         *            many parallel trees if the reset is successful.
         * @throws MissingObjectException
         *             the given tree object does not exist in this repository.
         * @throws IncorrectObjectTypeException
         *             the given object id does not denote a tree, but instead names
         *             some other non-tree type of object. Note that commits are not
         *             trees, even if they are sometimes called a "tree-ish".
         * @throws CorruptObjectException
         *             the object claimed to be a tree, but its contents did not
         *             appear to be a tree. The repository may have data corruption.
         * @throws IOException
         *             a loose object or pack file could not be Read.
         */
        public void reset(AnyObjectId[] ids)
        {
            if (ids == null)
            {
                throw new ArgumentNullException("ids");
            }
            int oldLen = _trees.Length;
            int newLen = ids.Length;

            AbstractTreeIterator[] r = newLen == oldLen ? _trees : new AbstractTreeIterator[newLen];
            for (int i = 0; i < newLen; i++)
            {
                AbstractTreeIterator iterator;

                if (i < oldLen)
                {
                    iterator = _trees[i];
                    while (iterator.Parent != null)
                    {
                        iterator = iterator.Parent;
                    }

                    CanonicalTreeParser oParse = (iterator as CanonicalTreeParser);
                    if (oParse != null && iterator.PathOffset == 0)
                    {
                        iterator.Matches    = null;
                        iterator.MatchShift = 0;
                        oParse.reset(_db, ids[i], _cursor);
                        r[i] = iterator;
                        continue;
                    }
                }

                iterator = ParserFor(ids[i]);
                r[i]     = iterator;
            }

            _trees   = r;
            _advance = false;
            _depth   = 0;
        }
 // [henon] createSubtreeIterator0 <--- not a typo!
 /**
  * Back door to quickly Create a subtree iterator for any subtree.
  * <para />
  * Don't use this unless you are ObjectWalk. The method is meant to be
  * called only once the current entry has been identified as a tree and its
  * identity has been converted into an ObjectId.
  *
  * @param repo
  *            repository to load the tree data from.
  * @param id
  *            ObjectId of the tree to open.
  * @param curs
  *            window cursor to use during repository access.
  * @return a new parser that walks over the current subtree.
  * @throws IOException
  *             a loose object or pack file could not be Read.
  */
 public CanonicalTreeParser createSubtreeIterator0(Repository repo, AnyObjectId id, WindowCursor curs)
 {
     var p = new CanonicalTreeParser(this);
     p.reset(repo, id, curs);
     return p;
 }