Example #1
0
        /// <summary>
        /// Find the next commit that has the given flag set.
        /// </summary>
        /// <param name="flag">the flag to test commits against.</param>
        /// <param name="begin">
        /// First commit index to test at. Applications may wish to begin
        /// at 0, to test the first commit in the list.
        /// </param>
        /// <returns>
        /// Index of the first commit at or After index <code>begin</code>
        /// that has the specified flag set on it; -1 if no match is found.
        /// </returns>
        public int indexOf(RevFlag flag, int begin)
        {
            while (begin < Size)
            {
                int   index = begin;
                Block s     = Contents;
                while (s.Shift > 0)
                {
                    int i = index >> s.Shift;
                    index -= i << s.Shift;
                    s      = (Block)s.Contents[i];
                }

                while (begin++ < Size && index < BLOCK_SIZE)
                {
                    var c = (RevCommit)s.Contents[index++];
                    if (c.has(flag))
                    {
                        return(begin);
                    }
                }
            }

            return(-1);
        }
Example #2
0
        /// <summary>
        /// Apply a flag to all commits matching the specified filter.
        ///
        /// This version allows incremental testing and application, such as from a
        /// background thread that needs to periodically halt processing and send
        /// updates to the UI.
        /// </summary>
        /// <param name="matching">
        /// the filter to test commits with. If the filter includes a
        /// commit it will have the flag set; if the filter does not
        /// include the commit the flag will be unset.
        /// </param>
        /// <param name="flag">
        /// the flag to Apply (or remove). Applications are responsible
        /// for allocating this flag from the source RevWalk.
        /// </param>
        /// <param name="rangeBegin">
        /// first commit within the list to begin testing at, inclusive.
        /// Must not be negative, but may be beyond the end of the list.
        /// </param>
        /// <param name="rangeEnd">
        /// last commit within the list to end testing at, exclusive. If
        /// smaller than or equal to <code>rangeBegin</code> then no
        /// commits will be tested.
        /// </param>
        /// <remarks>
        /// Revision filter needed to Read additional objects, but an
        /// error occurred while reading the pack files or loose objects
        /// of the repository.
        /// </remarks>
        public void applyFlag(RevFilter matching, RevFlag flag, int rangeBegin, int rangeEnd)
        {
            RevWalk w = flag.Walker;

            rangeEnd = Math.Min(rangeEnd, Size);
            while (rangeBegin < rangeEnd)
            {
                int   index = rangeBegin;
                Block s     = Contents;

                while (s.Shift > 0)
                {
                    int i = index >> s.Shift;
                    index -= i << s.Shift;
                    s      = (Block)s.Contents[i];
                }

                while (rangeBegin++ < rangeEnd && index < BLOCK_SIZE)
                {
                    var c = (RevCommit)s.Contents[index++];

                    if (matching.include(w, c))
                    {
                        c.add(flag);
                    }
                    else
                    {
                        c.remove(flag);
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Find the next commit that has the given flag set.
        /// </summary>
        /// <param name="flag">the flag to test commits against.</param>
        /// <param name="begin">
        /// First commit index to test at. Applications may wish to begin
        /// at <code>size()-1</code>, to test the last commit in the
        /// list.</param>
        /// <returns>
        /// Index of the first commit at or before index <code>begin</code>
        /// that has the specified flag set on it; -1 if no match is found.
        /// </returns>
        public int LastIndexOf(RevFlag flag, int begin)
        {
            begin = Math.Min(begin, Size - 1);
            while (begin >= 0)
            {
                int   index = begin;
                Block s     = Contents;
                while (s.Shift > 0)
                {
                    int i = index >> s.Shift;
                    index -= i << s.Shift;
                    s      = (Block)s.Contents[i];
                }

                while (begin-- >= 0 && index >= 0)
                {
                    var c = (RevCommit)s.Contents[index--];
                    if (c.has(flag))
                    {
                        return(begin);
                    }
                }
            }

            return(-1);
        }
Example #4
0
 /**
  * Add a commit if it does not have a flag set yet, then set the flag.
  * <para />
  * This method permits the application to test if the commit has the given
  * flag; if it does not already have the flag than the commit is added to
  * the queue and the flag is set. This later will prevent the commit from
  * being added twice.
  *
  * @param c
  *            commit to add.
  * @param queueControl
  *            flag that controls admission to the queue.
  */
 public void add(RevCommit c, RevFlag queueControl)
 {
     if (!c.has(queueControl))
     {
         c.add(queueControl);
         add(c);
     }
 }
Example #5
0
 /**
  * Add a commit if it does not have a flag set yet, then set the flag.
  * <para />
  * This method permits the application to test if the commit has the given
  * flag; if it does not already have the flag than the commit is added to
  * the queue and the flag is set. This later will prevent the commit from
  * being added twice.
  * 
  * @param c
  *            commit to add.
  * @param queueControl
  *            flag that controls admission to the queue.
  */
 public void add(RevCommit c, RevFlag queueControl)
 {
     if (!c.has(queueControl))
     {
         c.add(queueControl);
         add(c);
     }
 }
Example #6
0
        /// <summary>
        /// Carry a RevFlag set on this commit to its parents.
        /// <para />
        /// If this commit is parsed, has parents, and has the supplied flag set on
        /// it we automatically add it to the parents, grand-parents, and so on until
        /// an unparsed commit or a commit with no parents is discovered. This
        /// permits applications to force a flag through the history chain when
        /// necessary.
        /// </summary>
        /// <param name="flag">
        /// The single flag value to carry back onto parents.
        /// </param>
        public void carry(RevFlag flag)
        {
            int carry = Flags & flag.Mask;

            if (carry != 0)
            {
                carryFlags(this, carry);
            }
        }
Example #7
0
        public RefAdvertiser(PacketLineOut o, RevWalk.RevWalk protoWalk, RevFlag advertisedFlag)
        {
            _tmpLine = new StringBuilder(100);
            _tmpId = new char[2 * Constants.OBJECT_ID_LENGTH];
            _capabilities = new List<string>();
            _first = true;

            _pckOut = o;
            _walk = protoWalk;
            ADVERTISED = advertisedFlag;
        }
Example #8
0
 /// <summary>
 /// Remove the given flag from all commits.
 ///
 /// This method is actually implemented in terms of:
 /// <code>applyFlag(RevFilter.NONE, flag, rangeBegin, rangeEnd)</code>.
 /// </summary>
 /// <param name="flag">
 /// The flag to remove. Applications are responsible for
 /// allocating this flag from the source <see cref="RevWalk"/>.
 /// </param>
 /// <param name="rangeBegin">
 /// First commit within the list to begin testing at, inclusive.
 /// Must not be negative, but may be beyond the end of the list.
 /// </param>
 /// <param name="rangeEnd">
 /// Last commit within the list to end testing at, exclusive. If
 /// smaller than or equal to <code>rangeBegin</code> then no
 /// commits will be tested.
 /// </param>
 public void clearFlag(RevFlag flag, int rangeBegin, int rangeEnd)
 {
     try
     {
         applyFlag(RevFilter.NONE, flag, rangeBegin, rangeEnd);
     }
     catch (IOException)
     {
         // Never happen. The filter we use does not throw any
         // exceptions, for any reason.
     }
 }
Example #9
0
 /// <summary>
 /// Add a commit's parents if one does not have a flag set yet.
 /// <para />
 /// This method permits the application to test if the commit has the given
 /// flag; if it does not already have the flag than the commit is added to
 /// the queue and the flag is set. This later will prevent the commit from
 /// being added twice.
 /// </summary>
 /// <param name="c">
 /// commit whose parents should be added.
 /// </param>
 /// <param name="queueControl">
 /// flag that controls admission to the queue.
 /// </param>
 public void addParents(RevCommit c, RevFlag queueControl)
 {
     RevCommit[] pList = c.Parents;
     if (pList == null)
     {
         return;
     }
     foreach (RevCommit p in pList)
     {
         add(p, queueControl);
     }
 }
Example #10
0
 /// <summary>
 /// Test to see if the flag has been set on this object.
 /// </summary>
 /// <param name="flag">the flag to test.</param>
 /// <returns>
 /// true if the flag has been added to this object; false if not.
 /// </returns>
 public bool has(RevFlag flag)
 {
     return((Flags & flag.Mask) != 0);
 }
Example #11
0
        ///	<summary>
        /// Create a new pack upload for an open repository.
        /// </summary>
        /// <param name="copyFrom">the source repository.</param>
        public UploadPack(Repository copyFrom)
        {
            _db = copyFrom;
            _walk = new RevWalk.RevWalk(_db);
            _walk.setRetainBody(false);

            ADVERTISED = _walk.newFlag("ADVERTISED");
            WANT = _walk.newFlag("WANT");
            PEER_HAS = _walk.newFlag("PEER_HAS");
            COMMON = _walk.newFlag("COMMON");
            _walk.carry(PEER_HAS);

            SAVE = new RevFlagSet { ADVERTISED, WANT, PEER_HAS };
            _refFilter = RefFilterContants.DEFAULT;
        }
        public BasePackFetchConnection(IPackTransport packTransport)
            : base(packTransport)
        {
            RepositoryConfig cfg = local.Config;
            _includeTags = transport.TagOpt != TagOpt.NO_TAGS;
            _thinPack = transport.FetchThin;
            _allowOfsDelta = cfg.getBoolean("repack", "usedeltabaseoffset", true);

            _walk = new RevWalk.RevWalk(local);
            _reachableCommits = new RevCommitList<RevCommit>();
            REACHABLE = _walk.newFlag("REACHABLE");
            COMMON = _walk.newFlag("COMMON");
            ADVERTISED = _walk.newFlag("ADVERTISED");

            _walk.carry(COMMON);
            _walk.carry(REACHABLE);
            _walk.carry(ADVERTISED);
        }
 public NegotiateBeginRevFilter(RevFlag c, RevFlag a)
 {
     _common = c;
     _advertised = a;
 }
Example #14
0
        public WalkFetchConnection(IWalkTransport t, WalkRemoteObjectDatabase w)
        {
            _idBuffer = new MutableObjectId();
            _objectDigest = Constants.newMessageDigest();

            var wt = (Transport)t;
            _local = wt.Local;
            _objCheck = wt.CheckFetchedObjects ? new ObjectChecker() : null;

            _remotes = new List<WalkRemoteObjectDatabase> { w };

            _unfetchedPacks = new LinkedList<RemotePack>();
            _packsConsidered = new List<string>();

            _noPacksYet = new LinkedList<WalkRemoteObjectDatabase>();
            _noPacksYet.AddFirst(w);

            _noAlternatesYet = new LinkedList<WalkRemoteObjectDatabase>();
            _noAlternatesYet.AddFirst(w);

            _fetchErrors = new Dictionary<ObjectId, List<Exception>>();
            _packLocks = new List<PackLock>(4);

            _revWalk = new RevWalk.RevWalk(_local);
            _treeWalk = new TreeWalk.TreeWalk(_local);

            COMPLETE = _revWalk.newFlag("COMPLETE");
            IN_WORK_QUEUE = _revWalk.newFlag("IN_WORK_QUEUE");
            LOCALLY_SEEN = _revWalk.newFlag("LOCALLY_SEEN");

            _localCommitQueue = new DateRevQueue();
            _workQueue = new LinkedList<ObjectId>();
        }
Example #15
0
 /// <summary>
 /// Carry a RevFlag set on this commit to its parents.
 /// <para />
 /// If this commit is parsed, has parents, and has the supplied flag set on
 /// it we automatically add it to the parents, grand-parents, and so on until
 /// an unparsed commit or a commit with no parents is discovered. This
 /// permits applications to force a flag through the history chain when
 /// necessary.
 /// </summary>
 /// <param name="flag">
 /// The single flag value to carry back onto parents.
 /// </param>
 public void carry(RevFlag flag)
 {
     int carry = Flags & flag.Mask;
     if (carry != 0)
     {
         carryFlags(this, carry);
     }
 }
Example #16
0
        ///	<summary>
        /// Create a new pack upload for an open repository.
        /// </summary>
        /// <param name="copyFrom">the source repository.</param>
        public UploadPack(Repository copyFrom)
        {
            _options = new List<string>();
            _wantAll = new List<RevObject>();
            _wantCommits = new List<RevCommit>();
            _commonBase = new List<RevObject>();

            _db = copyFrom;
            _walk = new RevWalk.RevWalk(_db);
            _walk.setRetainBody(false);

            ADVERTISED = _walk.newFlag("ADVERTISED");
            WANT = _walk.newFlag("WANT");
            PEER_HAS = _walk.newFlag("PEER_HAS");
            COMMON = _walk.newFlag("COMMON");
            _walk.carry(PEER_HAS);

            SAVE = new RevFlagSet { ADVERTISED, WANT, PEER_HAS };
        }
Example #17
0
 /// <summary>
 /// Initialize a new advertisement formatter.
 /// </summary>
 /// <param name="protoWalk">the RevWalk used to parse objects that are advertised.</param>
 /// <param name="advertisedFlag">
 /// flag marked on any advertised objects parsed out of the
 /// <paramref name="protoWalk"/>'s object pool, permitting the caller to
 /// later quickly determine if an object was advertised (or not).
 /// </param>
 public void init(RevWalk.RevWalk protoWalk, RevFlag advertisedFlag)
 {
     _walk = protoWalk;
     ADVERTISED = advertisedFlag;
 }
Example #18
0
 /// <summary>
 /// Remove the given flag from all commits.
 ///
 /// Same as <code>clearFlag(flag, 0, size())</code>, but without the
 /// incremental behavior.
 /// </summary>
 /// <param name="flag">the flag to remove. Applications are responsible for
 /// allocating this flag from the source <see cref="RevWalk"/>.</param>
 public void clearFlag(RevFlag flag)
 {
     clearFlag(flag, 0, Size);
 }
Example #19
0
 /// <summary>
 /// Remove a flag from this object.
 /// <para />
 /// If the flag is not set on this object then the method has no effect.
 /// </summary>
 /// <param name="flag">
 /// The flag to remove from this object.
 /// </param>
 public void remove(RevFlag flag)
 {
     Flags &= ~flag.Mask;
 }
Example #20
0
 /// <summary>
 /// Add a flag to this object.
 /// <para />
 /// If the flag is already set on this object then the method has no effect.
 /// </summary>
 /// <param name="flag">
 /// The flag to mark on this object, for later testing.
 /// </param>
 public void add(RevFlag flag)
 {
     Flags |= flag.Mask;
 }
Example #21
0
 /// <summary>
 /// Apply a flag to all commits matching the specified filter.
 ///
 /// <code>applyFlag(matching, flag, 0, size())</code>, but without
 /// the incremental behavior.
 /// </summary>
 /// <param name="matching">
 /// the filter to test commits with. If the filter includes a
 /// commit it will have the flag set; if the filter does not
 /// include the commit the flag will be unset.
 /// </param>
 /// <param name="flag">
 /// revision filter needed to Read additional objects, but an
 /// error occurred while reading the pack files or loose objects
 /// of the repository.
 /// </param>
 public void applyFlag(RevFilter matching, RevFlag flag)
 {
     applyFlag(matching, flag, 0, Size);
 }
Example #22
0
 /// <summary>
 /// Test to see if the flag has been set on this object.
 /// </summary>
 /// <param name="flag">the flag to test.</param>
 /// <returns>
 /// true if the flag has been added to this object; false if not.
 /// </returns>
 public bool has(RevFlag flag)
 {
     return (Flags & flag.Mask) != 0;
 }
Example #23
0
 /// <summary>
 /// Add a flag to this object.
 /// <para />
 /// If the flag is already set on this object then the method has no effect.
 /// </summary>
 /// <param name="flag">
 /// The flag to mark on this object, for later testing.
 /// </param>
 public void add(RevFlag flag)
 {
     Flags |= flag.Mask;
 }
Example #24
0
 /// <summary>
 /// Remove a flag from this object.
 /// <para />
 /// If the flag is not set on this object then the method has no effect.
 /// </summary>
 /// <param name="flag">
 /// The flag to remove from this object.
 /// </param>
 public void remove(RevFlag flag)
 {
     Flags &= ~flag.Mask;
 }
Example #25
0
        /// <summary>
        /// Add a commit's parents if one does not have a flag set yet.
		/// <para />
		/// This method permits the application to test if the commit has the given
		/// flag; if it does not already have the flag than the commit is added to
		/// the queue and the flag is set. This later will prevent the commit from
		/// being added twice.
        /// </summary>
        /// <param name="c">
        /// commit whose parents should be added.
        /// </param>
        /// <param name="queueControl">
        /// flag that controls admission to the queue.
        /// </param>
        public void addParents(RevCommit c, RevFlag queueControl)
        {
            RevCommit[] pList = c.Parents;
            if (pList == null) return;
            foreach (RevCommit p in pList)
            {
            	add(p, queueControl);
            }
        }