本文整理汇总了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;
}
示例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());
}
}
示例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);
}
}
示例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);
}
示例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);
}