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


C# NGit.Error方法代码示例

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


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

示例1: ParseBody

        internal virtual int ParseBody(NGit.Patch.Patch script, int end)
        {
            byte[] buf = file.buf;
            int c = RawParseUtils.NextLF(buf, startOffset);
            int last = c;
            old.nDeleted = 0;
            old.nAdded = 0;
            for (; c < end; last = c, c = RawParseUtils.NextLF(buf, c))
            {
                switch (buf[c])
                {
                    case (byte)(' '):
                    case (byte)('\n'):
                    {
                        nContext++;
                        continue;
                        goto case (byte)('-');
                    }

                    case (byte)('-'):
                    {
                        old.nDeleted++;
                        continue;
                        goto case (byte)('+');
                    }

                    case (byte)('+'):
                    {
                        old.nAdded++;
                        continue;
                        goto case (byte)('\\');
                    }

                    case (byte)('\\'):
                    {
                        // Matches "\ No newline at end of file"
                        continue;
                        goto default;
                    }

                    default:
                    {
                        goto SCAN_break;
                        break;
                    }
                }
            SCAN_continue: ;
            }
            SCAN_break: ;
            if (last < end && nContext + old.nDeleted - 1 == old.lineCount && nContext + old.
                nAdded == newLineCount && RawParseUtils.Match(buf, last, NGit.Patch.Patch.SIG_FOOTER
                ) >= 0)
            {
                // This is an extremely common occurrence of "corruption".
                // Users add footers with their signatures after this mark,
                // and git diff adds the git executable version number.
                // Let it slide; the hunk otherwise looked sound.
                //
                old.nDeleted--;
                return last;
            }
            if (nContext + old.nDeleted < old.lineCount)
            {
                int missingCount = old.lineCount - (nContext + old.nDeleted);
                script.Error(buf, startOffset, MessageFormat.Format(JGitText.Get().truncatedHunkOldLinesMissing
                    , missingCount));
            }
            else
            {
                if (nContext + old.nAdded < newLineCount)
                {
                    int missingCount = newLineCount - (nContext + old.nAdded);
                    script.Error(buf, startOffset, MessageFormat.Format(JGitText.Get().truncatedHunkNewLinesMissing
                        , missingCount));
                }
                else
                {
                    if (nContext + old.nDeleted > old.lineCount || nContext + old.nAdded > newLineCount)
                    {
                        string oldcnt = old.lineCount + ":" + newLineCount;
                        string newcnt = (nContext + old.nDeleted) + ":" + (nContext + old.nAdded);
                        script.Warn(buf, startOffset, MessageFormat.Format(JGitText.Get().hunkHeaderDoesNotMatchBodyLineCountOf
                            , oldcnt, newcnt));
                    }
                }
            }
            return c;
        }
开发者ID:kenji-tan,项目名称:ngit,代码行数:88,代码来源:HunkHeader.cs

示例2: ParseBody

		internal override int ParseBody(NGit.Patch.Patch script, int end)
		{
			byte[] buf = file.buf;
			int c = RawParseUtils.NextLF(buf, startOffset);
			foreach (CombinedHunkHeader.CombinedOldImage o in old)
			{
				o.nDeleted = 0;
				o.nAdded = 0;
				o.nContext = 0;
			}
			nContext = 0;
			int nAdded = 0;
			for (int eol; c < end; c = eol)
			{
				eol = RawParseUtils.NextLF(buf, c);
				if (eol - c < old.Length + 1)
				{
					// Line isn't long enough to mention the state of each
					// ancestor. It must be the end of the hunk.
					goto SCAN_break;
				}
				switch (buf[c])
				{
					case (byte)(' '):
					case (byte)('-'):
					case (byte)('+'):
					{
						break;
					}

					default:
					{
						// Line can't possibly be part of this hunk; the first
						// ancestor information isn't recognizable.
						//
						goto SCAN_break;
						break;
					}
				}
				int localcontext = 0;
				for (int ancestor = 0; ancestor < old.Length; ancestor++)
				{
					switch (buf[c + ancestor])
					{
						case (byte)(' '):
						{
							localcontext++;
							old[ancestor].nContext++;
							continue;
							goto case (byte)('-');
						}

						case (byte)('-'):
						{
							old[ancestor].nDeleted++;
							continue;
							goto case (byte)('+');
						}

						case (byte)('+'):
						{
							old[ancestor].nAdded++;
							nAdded++;
							continue;
							goto default;
						}

						default:
						{
							goto SCAN_break;
							break;
						}
					}
				}
				if (localcontext == old.Length)
				{
					nContext++;
				}
SCAN_continue: ;
			}
SCAN_break: ;
			for (int ancestor_1 = 0; ancestor_1 < old.Length; ancestor_1++)
			{
				CombinedHunkHeader.CombinedOldImage o_1 = old[ancestor_1];
				int cmp = o_1.nContext + o_1.nDeleted;
				if (cmp < o_1.lineCount)
				{
					int missingCnt = o_1.lineCount - cmp;
					script.Error(buf, startOffset, MessageFormat.Format(JGitText.Get().truncatedHunkLinesMissingForAncestor
						, Sharpen.Extensions.ValueOf(missingCnt), Sharpen.Extensions.ValueOf(ancestor_1 
						+ 1)));
				}
			}
			if (nContext + nAdded < newLineCount)
			{
				int missingCount = newLineCount - (nContext + nAdded);
				script.Error(buf, startOffset, MessageFormat.Format(JGitText.Get().truncatedHunkNewLinesMissing
					, Sharpen.Extensions.ValueOf(missingCount)));
			}
			return c;
//.........这里部分代码省略.........
开发者ID:LunarLanding,项目名称:ngit,代码行数:101,代码来源:CombinedHunkHeader.cs


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