コード例 #1
0
        /// <summary>A conflict is detected - add the three different stages to the index</summary>
        /// <param name="path">the path of the conflicting entry</param>
        /// <param name="e">the previous index entry</param>
        /// <param name="h">the first tree you want to merge (the HEAD)</param>
        /// <param name="m">the second tree you want to merge</param>
        private void Conflict(string path, DirCacheEntry e, AbstractTreeIterator h, AbstractTreeIterator
                              m)
        {
            conflicts.AddItem(path);
            DirCacheEntry entry;

            if (e != null)
            {
                entry = new DirCacheEntry(e.PathString, DirCacheEntry.STAGE_1);
                entry.CopyMetaData(e);
                builder.Add(entry);
            }
            if (h != null && !FileMode.TREE.Equals(h.EntryFileMode))
            {
                entry          = new DirCacheEntry(h.EntryPathString, DirCacheEntry.STAGE_2);
                entry.FileMode = h.EntryFileMode;
                entry.SetObjectId(h.EntryObjectId);
                builder.Add(entry);
            }
            if (m != null && !FileMode.TREE.Equals(m.EntryFileMode))
            {
                entry          = new DirCacheEntry(m.EntryPathString, DirCacheEntry.STAGE_3);
                entry.FileMode = m.EntryFileMode;
                entry.SetObjectId(m.EntryObjectId);
                builder.Add(entry);
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: DirCacheCheckout.cs プロジェクト: stinos/ngit
        /// <summary>A conflict is detected - add the three different stages to the index</summary>
        /// <param name="path">the path of the conflicting entry</param>
        /// <param name="e">the previous index entry</param>
        /// <param name="h">the first tree you want to merge (the HEAD)</param>
        /// <param name="m">the second tree you want to merge</param>
        private void Conflict(string path, DirCacheEntry e, AbstractTreeIterator h, AbstractTreeIterator
			 m)
        {
            conflicts.AddItem(path);
            DirCacheEntry entry;
            if (e != null)
            {
                entry = new DirCacheEntry(e.PathString, DirCacheEntry.STAGE_1);
                entry.CopyMetaData(e, true);
                builder.Add(entry);
            }
            if (h != null && !FileMode.TREE.Equals(h.EntryFileMode))
            {
                entry = new DirCacheEntry(h.EntryPathString, DirCacheEntry.STAGE_2);
                entry.FileMode = h.EntryFileMode;
                entry.SetObjectId(h.EntryObjectId);
                builder.Add(entry);
            }
            if (m != null && !FileMode.TREE.Equals(m.EntryFileMode))
            {
                entry = new DirCacheEntry(m.EntryPathString, DirCacheEntry.STAGE_3);
                entry.FileMode = m.EntryFileMode;
                entry.SetObjectId(m.EntryObjectId);
                builder.Add(entry);
            }
        }
コード例 #4
0
		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);
		}