當前位置: 首頁>>代碼示例>>C#>>正文


C# DirCacheEntry.GetObjectId方法代碼示例

本文整理匯總了C#中NGit.Dircache.DirCacheEntry.GetObjectId方法的典型用法代碼示例。如果您正苦於以下問題:C# DirCacheEntry.GetObjectId方法的具體用法?C# DirCacheEntry.GetObjectId怎麽用?C# DirCacheEntry.GetObjectId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NGit.Dircache.DirCacheEntry的用法示例。


在下文中一共展示了DirCacheEntry.GetObjectId方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Keep

 /// <summary>
 /// adds a entry to the index builder which is a copy of the specified
 /// DirCacheEntry
 /// </summary>
 /// <param name="e">the entry which should be copied</param>
 /// <returns>the entry which was added to the index</returns>
 private DirCacheEntry Keep(DirCacheEntry e)
 {
     DirCacheEntry newEntry = new DirCacheEntry(e.PathString, e.Stage);
     newEntry.FileMode = e.FileMode;
     newEntry.SetObjectId(e.GetObjectId());
     newEntry.LastModified = e.LastModified;
     newEntry.SetLength(e.Length);
     builder.Add(newEntry);
     return newEntry;
 }
開發者ID:stinos,項目名稱:ngit,代碼行數:16,代碼來源:ResolveMerger.cs

示例2: CheckoutEntry

        /// <summary>
        /// Updates the file in the working tree with content and mode from an entry
        /// in the index.
        /// </summary>
        /// <remarks>
        /// Updates the file in the working tree with content and mode from an entry
        /// in the index. The new content is first written to a new temporary file in
        /// the same directory as the real file. Then that new file is renamed to the
        /// final filename.
        /// <p>
        /// TODO: this method works directly on File IO, we may need another
        /// abstraction (like WorkingTreeIterator). This way we could tell e.g.
        /// Eclipse that Files in the workspace got changed
        /// </p>
        /// </remarks>
        /// <param name="repo"></param>
        /// <param name="f">
        /// the file to be modified. The parent directory for this file
        /// has to exist already
        /// </param>
        /// <param name="entry">the entry containing new mode and content</param>
        /// <param name="or">object reader to use for checkout</param>
        /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
        public static void CheckoutEntry(Repository repo, FilePath f, DirCacheEntry entry
			, ObjectReader or)
        {
            ObjectLoader ol = or.Open(entry.GetObjectId());
            FilePath parentDir = f.GetParentFile();
            FilePath tmpFile = FilePath.CreateTempFile("._" + f.GetName(), null, parentDir);
            WorkingTreeOptions opt = repo.GetConfig().Get(WorkingTreeOptions.KEY);
            FileOutputStream rawChannel = new FileOutputStream(tmpFile);
            OutputStream channel;
            if (opt.GetAutoCRLF() == CoreConfig.AutoCRLF.TRUE)
            {
                channel = new AutoCRLFOutputStream(rawChannel);
            }
            else
            {
                channel = rawChannel;
            }
            try
            {
                ol.CopyTo(channel);
            }
            finally
            {
                channel.Close();
            }
            FS fs = repo.FileSystem;
            if (opt.IsFileMode() && fs.SupportsExecute())
            {
                if (FileMode.EXECUTABLE_FILE.Equals(entry.RawMode))
                {
                    if (!fs.CanExecute(tmpFile))
                    {
                        fs.SetExecute(tmpFile, true);
                    }
                }
                else
                {
                    if (fs.CanExecute(tmpFile))
                    {
                        fs.SetExecute(tmpFile, false);
                    }
                }
            }
            if (!tmpFile.RenameTo(f))
            {
                // tried to rename which failed. Let' delete the target file and try
                // again
                FileUtils.Delete(f);
                if (!tmpFile.RenameTo(f))
                {
                    throw new IOException(MessageFormat.Format(JGitText.Get().couldNotWriteFile, tmpFile
                        .GetPath(), f.GetPath()));
                }
            }
            entry.LastModified = f.LastModified();
            if (opt.GetAutoCRLF() != CoreConfig.AutoCRLF.FALSE)
            {
                entry.SetLength(f.Length());
            }
            else
            {
                // AutoCRLF wants on-disk-size
                entry.SetLength((int)ol.GetSize());
            }
        }
開發者ID:stinos,項目名稱:ngit,代碼行數:88,代碼來源:DirCacheCheckout.cs

示例3: TestBuildOneFile_FinishWriteCommit

		public virtual void TestBuildOneFile_FinishWriteCommit()
		{
			string path = "a-file-path";
			FileMode mode = FileMode.REGULAR_FILE;
			long lastModified = 1218123387057L;
			int length = 1342;
			DirCacheEntry entOrig;
			{
				DirCache dc = db.LockDirCache();
				DirCacheBuilder b = dc.Builder();
				NUnit.Framework.Assert.IsNotNull(b);
				entOrig = new DirCacheEntry(path);
				entOrig.FileMode = mode;
				entOrig.LastModified = lastModified;
				entOrig.SetLength(length);
				NUnit.Framework.Assert.AreNotSame(path, entOrig.PathString);
				NUnit.Framework.Assert.AreEqual(path, entOrig.PathString);
				NUnit.Framework.Assert.AreEqual(ObjectId.ZeroId, entOrig.GetObjectId());
				NUnit.Framework.Assert.AreEqual(mode.GetBits(), entOrig.RawMode);
				NUnit.Framework.Assert.AreEqual(0, entOrig.Stage);
				NUnit.Framework.Assert.AreEqual(lastModified, entOrig.LastModified);
				NUnit.Framework.Assert.AreEqual(length, entOrig.Length);
				NUnit.Framework.Assert.IsFalse(entOrig.IsAssumeValid);
				b.Add(entOrig);
				b.Finish();
				NUnit.Framework.Assert.AreEqual(1, dc.GetEntryCount());
				NUnit.Framework.Assert.AreSame(entOrig, dc.GetEntry(0));
				dc.Write();
				NUnit.Framework.Assert.IsTrue(dc.Commit());
			}
			{
				DirCache dc = db.ReadDirCache();
				NUnit.Framework.Assert.AreEqual(1, dc.GetEntryCount());
				DirCacheEntry entRead = dc.GetEntry(0);
				NUnit.Framework.Assert.AreNotSame(entOrig, entRead);
				NUnit.Framework.Assert.AreEqual(path, entRead.PathString);
				NUnit.Framework.Assert.AreEqual(ObjectId.ZeroId, entOrig.GetObjectId());
				NUnit.Framework.Assert.AreEqual(mode.GetBits(), entOrig.RawMode);
				NUnit.Framework.Assert.AreEqual(0, entOrig.Stage);
				NUnit.Framework.Assert.AreEqual(lastModified, entOrig.LastModified);
				NUnit.Framework.Assert.AreEqual(length, entOrig.Length);
				NUnit.Framework.Assert.IsFalse(entOrig.IsAssumeValid);
			}
		}
開發者ID:shoff,項目名稱:ngit,代碼行數:44,代碼來源:DirCacheBuilderTest.cs

示例4: AssertEqual

		private static void AssertEqual(DirCacheCGitCompatabilityTest.CGitIndexRecord c, 
			DirCacheEntry j)
		{
			NUnit.Framework.Assert.IsNotNull(c);
			NUnit.Framework.Assert.IsNotNull(j);
			NUnit.Framework.Assert.AreEqual(c.path, j.PathString);
			NUnit.Framework.Assert.AreEqual(c.id, j.GetObjectId());
			NUnit.Framework.Assert.AreEqual(c.mode, j.RawMode);
			NUnit.Framework.Assert.AreEqual(c.stage, j.Stage);
		}
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:10,代碼來源:DirCacheCGitCompatabilityTest.cs

示例5: CopyMetaDataHelper

		private void CopyMetaDataHelper(bool keepStage)
		{
			DirCacheEntry e = new DirCacheEntry("some/path", DirCacheEntry.STAGE_2);
			e.IsAssumeValid = false;
			e.SetCreationTime(2L);
			e.FileMode = FileMode.EXECUTABLE_FILE;
			e.LastModified = 3L;
			e.SetLength(100L);
			e.SetObjectId(ObjectId.FromString("0123456789012345678901234567890123456789"));
			e.IsUpdateNeeded = true;
			DirCacheEntry f = new DirCacheEntry("someother/path", DirCacheEntry.STAGE_1);
			f.IsAssumeValid = true;
			f.SetCreationTime(10L);
			f.FileMode = FileMode.SYMLINK;
			f.LastModified = 20L;
			f.SetLength(100000000L);
			f.SetObjectId(ObjectId.FromString("1234567890123456789012345678901234567890"));
			f.IsUpdateNeeded = true;
			e.CopyMetaData(f, keepStage);
			NUnit.Framework.Assert.IsTrue(e.IsAssumeValid);
			NUnit.Framework.Assert.AreEqual(10L, e.GetCreationTime());
			NUnit.Framework.Assert.AreEqual(ObjectId.FromString("1234567890123456789012345678901234567890"
				), e.GetObjectId());
			NUnit.Framework.Assert.AreEqual(FileMode.SYMLINK, e.FileMode);
			NUnit.Framework.Assert.AreEqual(20L, e.LastModified);
			NUnit.Framework.Assert.AreEqual(100000000L, e.Length);
			if (keepStage)
			{
				NUnit.Framework.Assert.AreEqual(DirCacheEntry.STAGE_2, e.Stage);
			}
			else
			{
				NUnit.Framework.Assert.AreEqual(DirCacheEntry.STAGE_1, e.Stage);
			}
			NUnit.Framework.Assert.IsTrue(e.IsUpdateNeeded);
			NUnit.Framework.Assert.AreEqual("some/path", e.PathString);
		}
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:37,代碼來源:DirCacheEntryTest.cs


注:本文中的NGit.Dircache.DirCacheEntry.GetObjectId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。