当前位置: 首页>>代码示例>>C#>>正文


C# ProgressMonitor.Update方法代码示例

本文整理汇总了C#中NGit.ProgressMonitor.Update方法的典型用法代码示例。如果您正苦于以下问题:C# ProgressMonitor.Update方法的具体用法?C# ProgressMonitor.Update怎么用?C# ProgressMonitor.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NGit.ProgressMonitor的用法示例。


在下文中一共展示了ProgressMonitor.Update方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Search

        /// <exception cref="System.IO.IOException"></exception>
        internal virtual void Search(ProgressMonitor monitor, ObjectToPack[] toSearch, int
			 off, int cnt)
        {
            try
            {
                for (int end = off + cnt; off < end; off++)
                {
                    res = window[resSlot];
                    if (0 < maxMemory)
                    {
                        Clear(res);
                        int tail = Next(resSlot);
                        long need = EstimateSize(toSearch[off]);
                        while (maxMemory < loaded + need && tail != resSlot)
                        {
                            Clear(window[tail]);
                            tail = Next(tail);
                        }
                    }
                    res.Set(toSearch[off]);
                    if ([email protected]())
                    {
                        // We don't actually want to make a delta for
                        // them, just need to push them into the window
                        // so they can be read by other objects.
                        //
                        KeepInWindow();
                    }
                    else
                    {
                        // Search for a delta for the current window slot.
                        //
                        monitor.Update(1);
                        Search();
                    }
                }
            }
            finally
            {
                if (deflater != null)
                {
                    deflater.Finish();
                }
            }
        }
开发者ID:sharwell,项目名称:ngit,代码行数:46,代码来源:DeltaWindow.cs

示例2: Parse

		/// <summary>Parse the pack stream.</summary>
		/// <remarks>Parse the pack stream.</remarks>
		/// <param name="receiving">
		/// receives progress feedback during the initial receiving
		/// objects phase. If null,
		/// <see cref="NGit.NullProgressMonitor">NGit.NullProgressMonitor</see>
		/// will be
		/// used.
		/// </param>
		/// <param name="resolving">receives progress feedback during the resolving objects phase.
		/// 	</param>
		/// <returns>
		/// the pack lock, if one was requested by setting
		/// <see cref="SetLockMessage(string)">SetLockMessage(string)</see>
		/// .
		/// </returns>
		/// <exception cref="System.IO.IOException">the stream is malformed, or contains corrupt objects.
		/// 	</exception>
		public virtual PackLock Parse(ProgressMonitor receiving, ProgressMonitor resolving
			)
		{
			if (receiving == null)
			{
				receiving = NullProgressMonitor.INSTANCE;
			}
			if (resolving == null)
			{
				resolving = NullProgressMonitor.INSTANCE;
			}
			if (receiving == resolving)
			{
				receiving.Start(2);
			}
			try
			{
				ReadPackHeader();
				entries = new PackedObjectInfo[(int)objectCount];
				baseById = new ObjectIdOwnerMap<PackParser.DeltaChain>();
				baseByPos = new LongMap<PackParser.UnresolvedDelta>();
				deferredCheckBlobs = new BlockList<PackedObjectInfo>();
				receiving.BeginTask(JGitText.Get().receivingObjects, (int)objectCount);
				try
				{
					for (int done = 0; done < objectCount; done++)
					{
						IndexOneObject();
						receiving.Update(1);
						if (receiving.IsCancelled())
						{
							throw new IOException(JGitText.Get().downloadCancelled);
						}
					}
					ReadPackFooter();
					EndInput();
				}
				finally
				{
					receiving.EndTask();
				}
				if (!deferredCheckBlobs.IsEmpty())
				{
					DoDeferredCheckBlobs();
				}
				if (deltaCount > 0)
				{
					if (resolving is BatchingProgressMonitor)
					{
						((BatchingProgressMonitor)resolving).SetDelayStart(1000, TimeUnit.MILLISECONDS);
					}
					resolving.BeginTask(JGitText.Get().resolvingDeltas, deltaCount);
					ResolveDeltas(resolving);
					if (entryCount < objectCount)
					{
						if (!IsAllowThin())
						{
							throw new IOException(MessageFormat.Format(JGitText.Get().packHasUnresolvedDeltas
								, Sharpen.Extensions.ValueOf(objectCount - entryCount)));
						}
						ResolveDeltasWithExternalBases(resolving);
						if (entryCount < objectCount)
						{
							throw new IOException(MessageFormat.Format(JGitText.Get().packHasUnresolvedDeltas
								, Sharpen.Extensions.ValueOf(objectCount - entryCount)));
						}
					}
					resolving.EndTask();
				}
				packDigest = null;
				baseById = null;
				baseByPos = null;
			}
			finally
			{
				try
				{
					if (readCurs != null)
					{
						readCurs.Release();
					}
				}
//.........这里部分代码省略.........
开发者ID:LunarLanding,项目名称:ngit,代码行数:101,代码来源:PackParser.cs

示例3: ResolveDeltas

		/// <exception cref="System.IO.IOException"></exception>
		private void ResolveDeltas(PackParser.DeltaVisit visit, int type, PackParser.ObjectTypeAndSize
			 info, ProgressMonitor progress)
		{
			do
			{
				progress.Update(1);
				info = OpenDatabase(visit.delta, info);
				switch (info.type)
				{
					case Constants.OBJ_OFS_DELTA:
					case Constants.OBJ_REF_DELTA:
					{
						break;
					}

					default:
					{
						throw new IOException(MessageFormat.Format(JGitText.Get().unknownObjectType, Sharpen.Extensions.ValueOf
							(info.type)));
					}
				}
				byte[] delta = InflateAndReturn(PackParser.Source.DATABASE, info.size);
				CheckIfTooLarge(type, BinaryDelta.GetResultSize(delta));
				visit.data = BinaryDelta.Apply(visit.parent.data, delta);
				delta = null;
				if (!CheckCRC(visit.delta.crc))
				{
					throw new IOException(MessageFormat.Format(JGitText.Get().corruptionDetectedReReadingAt
						, Sharpen.Extensions.ValueOf(visit.delta.position)));
				}
				objectDigest.Update(Constants.EncodedTypeString(type));
				objectDigest.Update(unchecked((byte)' '));
				objectDigest.Update(Constants.EncodeASCII(visit.data.Length));
				objectDigest.Update(unchecked((byte)0));
				objectDigest.Update(visit.data);
				tempObjectId.FromRaw(objectDigest.Digest(), 0);
				VerifySafeObject(tempObjectId, type, visit.data);
				PackedObjectInfo oe;
				oe = NewInfo(tempObjectId, visit.delta, visit.parent.id);
				oe.SetOffset(visit.delta.position);
				OnInflatedObjectData(oe, type, visit.data);
				AddObjectAndTrack(oe);
				visit.id = oe;
				visit.nextChild = FirstChildOf(oe);
				visit = visit.Next();
			}
			while (visit != null);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:49,代码来源:PackParser.cs

示例4: WriteTo

			/// <exception cref="System.IO.IOException"></exception>
			public override void WriteTo(OutputStream os, ProgressMonitor pm)
			{
				if (onDiskFile == null)
				{
					base.WriteTo(os, pm);
					return;
				}
				if (pm == null)
				{
					pm = NullProgressMonitor.INSTANCE;
				}
				FileInputStream @in = new FileInputStream(onDiskFile);
				try
				{
					int cnt;
					byte[] buf = new byte[TemporaryBuffer.Block.SZ];
					while ((cnt = @in.Read(buf)) >= 0)
					{
						os.Write(buf, 0, cnt);
						pm.Update(cnt / 1024);
					}
				}
				finally
				{
					@in.Close();
				}
			}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:28,代码来源:TemporaryBuffer.cs

示例5: Execute

		/// <summary>Execute this batch update.</summary>
		/// <remarks>
		/// Execute this batch update.
		/// <p>
		/// The default implementation of this method performs a sequential reference
		/// update over each reference.
		/// </remarks>
		/// <param name="walk">
		/// a RevWalk to parse tags in case the storage system wants to
		/// store them pre-peeled, a common performance optimization.
		/// </param>
		/// <param name="update">progress monitor to receive update status on.</param>
		/// <exception cref="System.IO.IOException">
		/// the database is unable to accept the update. Individual
		/// command status must be tested to determine if there is a
		/// partial failure, or a total failure.
		/// </exception>
		public virtual void Execute(RevWalk walk, ProgressMonitor update)
		{
			update.BeginTask(JGitText.Get().updatingReferences, commands.Count);
			foreach (ReceiveCommand cmd in commands)
			{
				try
				{
					update.Update(1);
					if (cmd.GetResult() == ReceiveCommand.Result.NOT_ATTEMPTED)
					{
						cmd.UpdateType(walk);
						RefUpdate ru = NewUpdate(cmd);
						switch (cmd.GetType())
						{
							case ReceiveCommand.Type.DELETE:
							{
								cmd.SetResult(ru.Delete(walk));
								continue;
								goto case ReceiveCommand.Type.CREATE;
							}

							case ReceiveCommand.Type.CREATE:
							case ReceiveCommand.Type.UPDATE:
							case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:
							{
								cmd.SetResult(ru.Update(walk));
								continue;
							}
						}
					}
				}
				catch (IOException err)
				{
					cmd.SetResult(ReceiveCommand.Result.REJECTED_OTHER_REASON, MessageFormat.Format(JGitText
						.Get().lockError, err.Message));
				}
			}
			update.EndTask();
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:56,代码来源:BatchRefUpdate.cs

示例6: SelectObjectRepresentation

		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="NGit.Errors.MissingObjectException"></exception>
		public void SelectObjectRepresentation(PackWriter packer, ProgressMonitor monitor
			, Iterable<ObjectToPack> objects)
		{
			foreach (ObjectToPack otp in objects)
			{
				db.SelectObjectRepresentation(packer, otp, this);
				monitor.Update(1);
			}
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:11,代码来源:WindowCursor.cs

示例7: ResolveDeltas

		// By default there is no locking.
		/// <exception cref="System.IO.IOException"></exception>
		private void ResolveDeltas(ProgressMonitor progress)
		{
			progress.BeginTask(JGitText.Get().resolvingDeltas, deltaCount);
			int last = entryCount;
			for (int i = 0; i < last; i++)
			{
				int before = entryCount;
				ResolveDeltas(entries[i]);
				progress.Update(entryCount - before);
				if (progress.IsCancelled())
				{
					throw new IOException(JGitText.Get().downloadCancelledDuringIndexing);
				}
			}
			progress.EndTask();
		}
开发者ID:raufbutt,项目名称:monodevelop-old,代码行数:18,代码来源:PackParser.cs

示例8: OpenIndex

			/// <exception cref="System.IO.IOException"></exception>
			internal virtual void OpenIndex(ProgressMonitor pm)
			{
				if (this.index != null)
				{
					return;
				}
				if (this.tmpIdx == null)
				{
					this.tmpIdx = FilePath.CreateTempFile("jgit-walk-", ".idx");
				}
				else
				{
					if (this.tmpIdx.IsFile())
					{
						try
						{
							this.index = PackIndex.Open(this.tmpIdx);
							return;
						}
						catch (FileNotFoundException)
						{
						}
					}
				}
				// Fall through and get the file.
				WalkRemoteObjectDatabase.FileStream s;
				s = this.connection.Open("pack/" + this.idxName);
				pm.BeginTask("Get " + Sharpen.Runtime.Substring(this.idxName, 0, 12) + "..idx", s
					.length < 0 ? ProgressMonitor.UNKNOWN : (int)(s.length / 1024));
				try
				{
					FileOutputStream fos = new FileOutputStream(this.tmpIdx);
					try
					{
						byte[] buf = new byte[2048];
						int cnt;
						while (!pm.IsCancelled() && (cnt = [email protected](buf)) >= 0)
						{
							fos.Write(buf, 0, cnt);
							pm.Update(cnt / 1024);
						}
					}
					finally
					{
						fos.Close();
					}
				}
				catch (IOException err)
				{
					FileUtils.Delete(this.tmpIdx);
					throw;
				}
				finally
				{
					[email protected]();
				}
				pm.EndTask();
				if (pm.IsCancelled())
				{
					FileUtils.Delete(this.tmpIdx);
					return;
				}
				try
				{
					this.index = PackIndex.Open(this.tmpIdx);
				}
				catch (IOException e)
				{
					FileUtils.Delete(this.tmpIdx);
					throw;
				}
			}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:73,代码来源:WalkFetchConnection.cs

示例9: BuildMatrix

		/// <exception cref="System.IO.IOException"></exception>
		private int BuildMatrix(ProgressMonitor pm)
		{
			// Allocate for the worst-case scenario where every pair has a
			// score that we need to consider. We might not need that many.
			//
			matrix = new long[srcs.Count * dsts.Count];
			long[] srcSizes = new long[srcs.Count];
			long[] dstSizes = new long[dsts.Count];
			BitSet dstTooLarge = null;
			// Consider each pair of files, if the score is above the minimum
			// threshold we need record that scoring in the matrix so we can
			// later find the best matches.
			//
			int mNext = 0;
			for (int srcIdx = 0; srcIdx < srcs.Count; srcIdx++)
			{
				DiffEntry srcEnt = srcs[srcIdx];
				if (!IsFile(srcEnt.oldMode))
				{
					pm.Update(dsts.Count);
					continue;
				}
				SimilarityIndex s = null;
				for (int dstIdx = 0; dstIdx < dsts.Count; dstIdx++)
				{
					DiffEntry dstEnt = dsts[dstIdx];
					if (!IsFile(dstEnt.newMode))
					{
						pm.Update(1);
						continue;
					}
					if (!RenameDetector.SameType(srcEnt.oldMode, dstEnt.newMode))
					{
						pm.Update(1);
						continue;
					}
					if (dstTooLarge != null && dstTooLarge.Get(dstIdx))
					{
						pm.Update(1);
						continue;
					}
					long srcSize = srcSizes[srcIdx];
					if (srcSize == 0)
					{
						srcSize = Size(DiffEntry.Side.OLD, srcEnt) + 1;
						srcSizes[srcIdx] = srcSize;
					}
					long dstSize = dstSizes[dstIdx];
					if (dstSize == 0)
					{
						dstSize = Size(DiffEntry.Side.NEW, dstEnt) + 1;
						dstSizes[dstIdx] = dstSize;
					}
					long max = Math.Max(srcSize, dstSize);
					long min = Math.Min(srcSize, dstSize);
					if (min * 100 / max < renameScore)
					{
						// Cannot possibly match, as the file sizes are so different
						pm.Update(1);
						continue;
					}
					if (s == null)
					{
						try
						{
							s = Hash(DiffEntry.Side.OLD, srcEnt);
						}
						catch (SimilarityIndex.TableFullException)
						{
							tableOverflow = true;
							goto SRC_continue;
						}
					}
					SimilarityIndex d;
					try
					{
						d = Hash(DiffEntry.Side.NEW, dstEnt);
					}
					catch (SimilarityIndex.TableFullException)
					{
						if (dstTooLarge == null)
						{
							dstTooLarge = new BitSet(dsts.Count);
						}
						dstTooLarge.Set(dstIdx);
						tableOverflow = true;
						pm.Update(1);
						continue;
					}
					int contentScore = s.Score(d, 10000);
					// nameScore returns a value between 0 and 100, but we want it
					// to be in the same range as the content score. This allows it
					// to be dropped into the pretty formula for the final score.
					int nameScore = NameScore(srcEnt.oldPath, dstEnt.newPath) * 100;
					int score = (contentScore * 99 + nameScore * 1) / 10000;
					if (score < renameScore)
					{
						pm.Update(1);
						continue;
//.........这里部分代码省略.........
开发者ID:yayanyang,项目名称:monodevelop,代码行数:101,代码来源:SimilarityRenameDetector.cs

示例10: Compute

		/// <exception cref="System.IO.IOException"></exception>
		internal virtual void Compute(ProgressMonitor pm)
		{
			if (pm == null)
			{
				pm = NullProgressMonitor.INSTANCE;
			}
			pm.BeginTask(JGitText.Get().renamesFindingByContent, 2 * srcs.Count * dsts.Count);
			//
			int mNext = BuildMatrix(pm);
			@out = new AList<DiffEntry>(Math.Min(mNext, dsts.Count));
			// Match rename pairs on a first come, first serve basis until
			// we have looked at everything that is above our minimum score.
			//
			for (--mNext; mNext >= 0; mNext--)
			{
				long ent = matrix[mNext];
				int sIdx = SrcFile(ent);
				int dIdx = DstFile(ent);
				DiffEntry s = srcs[sIdx];
				DiffEntry d = dsts[dIdx];
				if (d == null)
				{
					pm.Update(1);
					continue;
				}
				// was already matched earlier
				DiffEntry.ChangeType type;
				if (s.changeType == DiffEntry.ChangeType.DELETE)
				{
					// First use of this source file. Tag it as a rename so we
					// later know it is already been used as a rename, other
					// matches (if any) will claim themselves as copies instead.
					//
					s.changeType = DiffEntry.ChangeType.RENAME;
					type = DiffEntry.ChangeType.RENAME;
				}
				else
				{
					type = DiffEntry.ChangeType.COPY;
				}
				@out.AddItem(DiffEntry.Pair(type, s, d, Score(ent)));
				dsts.Set(dIdx, null);
				// Claim the destination was matched.
				pm.Update(1);
			}
			srcs = CompactSrcList(srcs);
			dsts = CompactDstList(dsts);
			pm.EndTask();
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:50,代码来源:SimilarityRenameDetector.cs

示例11: MergeTrees

		public static MergeCommandResult MergeTrees (ProgressMonitor monitor, NGit.Repository repo, RevCommit srcBase, RevCommit srcCommit, string sourceDisplayName, bool commitResult)
		{
			RevCommit newHead;
			RevWalk revWalk = new RevWalk(repo);
			try
			{
				// get the head commit
				Ref headRef = repo.GetRef(Constants.HEAD);
				if (headRef == null)
				{
					throw new NoHeadException(JGitText.Get().commitOnRepoWithoutHEADCurrentlyNotSupported
						);
				}
				RevCommit headCommit = revWalk.ParseCommit(headRef.GetObjectId());
				
				ResolveMerger merger = (ResolveMerger)((ThreeWayMerger)MergeStrategy.RESOLVE.NewMerger
					(repo));
				
				merger.SetWorkingTreeIterator(new FileTreeIterator(repo));
				
				merger.SetBase(srcBase);
				
				bool noProblems;
				IDictionary<string, MergeResult<Sequence>> lowLevelResults = null;
				IDictionary<string, ResolveMerger.MergeFailureReason> failingPaths = null;
				IList<string> modifiedFiles = null;
				
				ResolveMerger resolveMerger = merger;
				resolveMerger.SetCommitNames(new string[] { "BASE", "HEAD", sourceDisplayName });
				noProblems = merger.Merge(headCommit, srcCommit);
				lowLevelResults = resolveMerger.GetMergeResults();
				modifiedFiles = resolveMerger.GetModifiedFiles();
				failingPaths = resolveMerger.GetFailingPaths();
				
				if (monitor != null)
					monitor.Update (50);
				
				if (noProblems)
				{
					if (modifiedFiles != null && modifiedFiles.Count == 0) {
						return new MergeCommandResult(headCommit, null, new ObjectId[] { headCommit.Id, srcCommit
							.Id }, MergeStatus.ALREADY_UP_TO_DATE, MergeStrategy.RESOLVE, null, null);
					}
					DirCacheCheckout dco = new DirCacheCheckout(repo, headCommit.Tree, repo.LockDirCache
						(), merger.GetResultTreeId());
					dco.SetFailOnConflict(true);
					dco.Checkout();
					if (commitResult) {
						newHead = new NGit.Api.Git(repo).Commit().SetMessage(srcCommit.GetFullMessage()
							).SetAuthor(srcCommit.GetAuthorIdent()).Call();
						return new MergeCommandResult(newHead.Id, null, new ObjectId[] { headCommit.Id, srcCommit
							.Id }, MergeStatus.MERGED, MergeStrategy.RESOLVE, null, null);
					} else {
						return new MergeCommandResult(headCommit, null, new ObjectId[] { headCommit.Id, srcCommit
							.Id }, MergeStatus.MERGED, MergeStrategy.RESOLVE, null, null);
					}
				}
				else
				{
					if (failingPaths != null)
					{
						return new MergeCommandResult(null, merger.GetBaseCommit(0, 1), new ObjectId[] { 
							headCommit.Id, srcCommit.Id }, MergeStatus.FAILED, MergeStrategy.RESOLVE, lowLevelResults
							, failingPaths, null);
					}
					else
					{
						return new MergeCommandResult(null, merger.GetBaseCommit(0, 1), new ObjectId[] { 
							headCommit.Id, srcCommit.Id }, MergeStatus.CONFLICTING, MergeStrategy.RESOLVE, lowLevelResults
							, null);
					}
				}
			}
			finally
			{
				revWalk.Release();
			}
		}
开发者ID:llucenic,项目名称:monodevelop,代码行数:78,代码来源:GitUtil.cs

示例12: ExecuteImp

 /// <exception cref="System.NotSupportedException"></exception>
 /// <exception cref="NGit.Errors.TransportException"></exception>
 private void ExecuteImp(ProgressMonitor monitor, FetchResult result)
 {
     conn = transport.OpenFetch();
     try
     {
         result.SetAdvertisedRefs(transport.GetURI(), conn.GetRefsMap());
         ICollection<Ref> matched = new HashSet<Ref>();
         foreach (RefSpec spec in toFetch)
         {
             if (spec.GetSource() == null)
             {
                 throw new TransportException(MessageFormat.Format(JGitText.Get().sourceRefNotSpecifiedForRefspec
                     , spec));
             }
             if (spec.IsWildcard())
             {
                 ExpandWildcard(spec, matched);
             }
             else
             {
                 ExpandSingle(spec, matched);
             }
         }
         ICollection<Ref> additionalTags = Sharpen.Collections.EmptyList<Ref>();
         TagOpt tagopt = transport.GetTagOpt();
         if (tagopt == TagOpt.AUTO_FOLLOW)
         {
             additionalTags = ExpandAutoFollowTags();
         }
         else
         {
             if (tagopt == TagOpt.FETCH_TAGS)
             {
                 ExpandFetchTags();
             }
         }
         bool includedTags;
         if (!askFor.IsEmpty() && !AskForIsComplete())
         {
             FetchObjects(monitor);
             includedTags = conn.DidFetchIncludeTags();
             // Connection was used for object transfer. If we
             // do another fetch we must open a new connection.
             //
             CloseConnection(result);
         }
         else
         {
             includedTags = false;
         }
         if (tagopt == TagOpt.AUTO_FOLLOW && !additionalTags.IsEmpty())
         {
             // There are more tags that we want to follow, but
             // not all were asked for on the initial request.
             //
             Sharpen.Collections.AddAll(have, askFor.Keys);
             askFor.Clear();
             foreach (Ref r in additionalTags)
             {
                 ObjectId id = r.GetPeeledObjectId();
                 if (id == null)
                 {
                     id = r.GetObjectId();
                 }
                 if (transport.local.HasObject(id))
                 {
                     WantTag(r);
                 }
             }
             if (!askFor.IsEmpty() && (!includedTags || !AskForIsComplete()))
             {
                 ReopenConnection();
                 if (!askFor.IsEmpty())
                 {
                     FetchObjects(monitor);
                 }
             }
         }
     }
     finally
     {
         CloseConnection(result);
     }
     RevWalk walk = new RevWalk(transport.local);
     try
     {
         if (monitor is BatchingProgressMonitor)
         {
             ((BatchingProgressMonitor)monitor).SetDelayStart(250, TimeUnit.MILLISECONDS);
         }
         monitor.BeginTask(JGitText.Get().updatingReferences, localUpdates.Count);
         if (transport.IsRemoveDeletedRefs())
         {
             DeleteStaleTrackingRefs(result, walk);
         }
         foreach (TrackingRefUpdate u in localUpdates)
         {
             try
//.........这里部分代码省略.........
开发者ID:kenji-tan,项目名称:ngit,代码行数:101,代码来源:FetchProcess.cs

示例13: Index

		/// <summary>Consume data from the input stream until the packfile is indexed.</summary>
		/// <remarks>Consume data from the input stream until the packfile is indexed.</remarks>
		/// <param name="progress">progress feedback</param>
		/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
		public virtual void Index(ProgressMonitor progress)
		{
			progress.Start(2);
			try
			{
				try
				{
					ReadPackHeader();
					entries = new PackedObjectInfo[(int)objectCount];
					baseById = new ObjectIdSubclassMap<IndexPack.DeltaChain>();
					baseByPos = new LongMap<IndexPack.UnresolvedDelta>();
					deferredCheckBlobs = new AList<PackedObjectInfo>();
					progress.BeginTask(JGitText.Get().receivingObjects, (int)objectCount);
					for (int done = 0; done < objectCount; done++)
					{
						IndexOneObject();
						progress.Update(1);
						if (progress.IsCancelled())
						{
							throw new IOException(JGitText.Get().downloadCancelled);
						}
					}
					ReadPackFooter();
					EndInput();
					if (!deferredCheckBlobs.IsEmpty())
					{
						DoDeferredCheckBlobs();
					}
					progress.EndTask();
					if (deltaCount > 0)
					{
						if (packOut == null)
						{
							throw new IOException(JGitText.Get().needPackOut);
						}
						ResolveDeltas(progress);
						if (entryCount < objectCount)
						{
							if (!fixThin)
							{
								throw new IOException(MessageFormat.Format(JGitText.Get().packHasUnresolvedDeltas
									, (objectCount - entryCount)));
							}
							FixThinPack(progress);
						}
					}
					if (packOut != null && (keepEmpty || entryCount > 0))
					{
						packOut.GetChannel().Force(true);
					}
					packDigest = null;
					baseById = null;
					baseByPos = null;
					if (dstIdx != null && (keepEmpty || entryCount > 0))
					{
						WriteIdx();
					}
				}
				finally
				{
					try
					{
						if (readCurs != null)
						{
							readCurs.Release();
						}
					}
					finally
					{
						readCurs = null;
					}
					try
					{
						inflater.Release();
					}
					finally
					{
						inflater = null;
						objectDatabase.Close();
					}
					progress.EndTask();
					if (packOut != null)
					{
						packOut.Close();
					}
				}
				if (keepEmpty || entryCount > 0)
				{
					if (dstPack != null)
					{
						dstPack.SetReadOnly();
					}
					if (dstIdx != null)
					{
						dstIdx.SetReadOnly();
					}
//.........这里部分代码省略.........
开发者ID:nickname100,项目名称:monodevelop,代码行数:101,代码来源:IndexPack.cs


注:本文中的NGit.ProgressMonitor.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。