本文整理汇总了C#中GitIndex类的典型用法代码示例。如果您正苦于以下问题:C# GitIndex类的具体用法?C# GitIndex怎么用?C# GitIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GitIndex类属于命名空间,在下文中一共展示了GitIndex类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: testModified
public void testModified()
{
var index = new GitIndex(db);
index.add(trash, writeTrashFile("file2", "file2"));
index.add(trash, writeTrashFile("dir/file3", "dir/file3"));
writeTrashFile("dir/file3", "changed");
var t = new Tree(db);
t.AddFile("file2").Id = ObjectId.FromString("0123456789012345678901234567890123456789");
t.AddFile("dir/file3").Id = ObjectId.FromString("0123456789012345678901234567890123456789");
Assert.AreEqual(2, t.MemberCount);
var tree2 = (Tree) t.findTreeMember("dir");
tree2.Id = new ObjectWriter(db).WriteTree(tree2);
t.Id = new ObjectWriter(db).WriteTree(t);
var diff = new IndexDiff(t, index);
diff.Diff();
Assert.AreEqual(2, diff.Changed.Count);
Assert.IsTrue(diff.Changed.Contains("file2"));
Assert.IsTrue(diff.Changed.Contains("dir/file3"));
Assert.AreEqual(1, diff.Modified.Count);
Assert.IsTrue(diff.Modified.Contains("dir/file3"));
Assert.AreEqual(0, diff.Added.Count);
Assert.AreEqual(0, diff.Removed.Count);
Assert.AreEqual(0, diff.Missing.Count);
}
开发者ID:georgeck,项目名称:GitSharp,代码行数:28,代码来源:IndexDiffTest.cs
示例2: handler
void IndexTreeVisitor.VisitEntry(TreeEntry treeEntry, TreeEntry auxEntry, GitIndex.Entry indexEntry, FileInfo file)
{
VisitEntryAuxDelegate handler = VisitEntryAux;
if (handler != null)
{
handler(treeEntry, auxEntry, indexEntry, file);
}
}
开发者ID:dev218,项目名称:GitSharp,代码行数:8,代码来源:AbstractIndexTreeVisitor.cs
示例3: WorkDirCheckout
internal WorkDirCheckout(Repository repo, DirectoryInfo workDir, GitIndex oldIndex, GitIndex newIndex)
: this()
{
_repo = repo;
_root = workDir;
_index = oldIndex;
_merge = repo.MapTree(newIndex.writeTree());
}
开发者ID:dev218,项目名称:GitSharp,代码行数:8,代码来源:WorkDirCheckout.cs
示例4: IndexTreeWalker
public IndexTreeWalker(GitIndex index, Tree mainTree, Tree newTree, FileSystemInfo root,
IndexTreeVisitor visitor)
{
_mainTree = mainTree;
_newTree = newTree;
_root = root;
_visitor = visitor;
_threeTrees = newTree != null;
_indexMembers = index.Members;
}
开发者ID:stschake,项目名称:GitSharp,代码行数:10,代码来源:IndexTreeWalker.cs
示例5: IndexTreeWalker
/// <summary>Construct a walker for the index and one tree.</summary>
/// <remarks>Construct a walker for the index and one tree.</remarks>
/// <param name="index"></param>
/// <param name="tree"></param>
/// <param name="root"></param>
/// <param name="visitor"></param>
public IndexTreeWalker(GitIndex index, Tree tree, FilePath root, IndexTreeVisitor
visitor)
{
//import org.eclipse.jgit.JGitText;
this.mainTree = tree;
this.root = root;
this.visitor = visitor;
this.newTree = null;
threeTrees = false;
indexMembers = index.GetMembers();
}
开发者ID:famousthom,项目名称:monodevelop,代码行数:17,代码来源:IndexTreeWalker.cs
示例6: IndexDiff
public IndexDiff(Tree tree, GitIndex index)
{
_anyChanges = false;
_tree = tree;
_index = index;
Added = new HashSet<string>();
Changed = new HashSet<string>();
Removed = new HashSet<string>();
Missing = new HashSet<string>();
Modified = new HashSet<string>();
}
开发者ID:georgeck,项目名称:GitSharp,代码行数:12,代码来源:IndexDiff.cs
示例7: TestBoth
public virtual void TestBoth()
{
GitIndex index = new GitIndex(db);
Tree tree = new Tree(db);
index.Add(trash, WriteTrashFile("a", "a"));
tree.AddFile("b/b");
index.Add(trash, WriteTrashFile("c", "c"));
tree.AddFile("c");
new IndexTreeWalker(index, tree, trash, new IndexTreeWalkerTest.TestIndexTreeVisitor
(this)).Walk();
NUnit.Framework.Assert.IsTrue(indexOnlyEntriesVisited.Contains("a"));
NUnit.Framework.Assert.IsTrue(treeOnlyEntriesVisited.Contains("b/b"));
NUnit.Framework.Assert.IsTrue(bothVisited.Contains("c"));
}
开发者ID:charles-cai,项目名称:ngit,代码行数:14,代码来源:IndexTreeWalkerTest.cs
示例8: ShouldSupportNotModifiedExtensionlessFilesWithoutContentChecking
public void ShouldSupportNotModifiedExtensionlessFilesWithoutContentChecking()
{
var index = new GitIndex(db);
writeTrashFile("extensionless-file", "contents");
var file = new FileInfo(Path.Combine(trash.FullName, "extensionless-file"));
index.add(trash, file);
var entry = index.GetEntry("extensionless-file");
Assert.IsFalse(entry.IsModified(trash));
}
开发者ID:dev218,项目名称:GitSharp,代码行数:14,代码来源:IndexModifiedTests.cs
示例9: testAdded2
public void testAdded2()
{
var index = new GitIndex(db);
writeTrashFile("test/für henon.txt", "Weißebier");
var tree = new Core.Tree(db);
index.add(trash, new FileInfo(Path.Combine(trash.FullName, "test/für henon.txt")));
var diff = new IndexDiff(tree, index);
diff.Diff();
Assert.AreEqual(1, diff.Added.Count);
Assert.IsTrue(diff.Added.Contains("test/für henon.txt"));
Assert.AreEqual(0, diff.Changed.Count);
Assert.AreEqual(0, diff.Modified.Count);
Assert.AreEqual(0, diff.Removed.Count);
}
开发者ID:jagregory,项目名称:GitSharp,代码行数:16,代码来源:IndexDiffTest.cs
示例10: Compare
private static int Compare(TreeEntry t, GitIndex.Entry i)
{
if ((t == null) && (i == null))
{
return 0;
}
if (t == null)
{
return 1;
}
if (i == null)
{
return -1;
}
return Tree.CompareNames(t.FullNameUTF8, i.NameUTF8, TreeEntry.LastChar(t), TreeEntry.LastChar(i));
}
开发者ID:dev218,项目名称:GitSharp,代码行数:16,代码来源:IndexTreeWalker.cs
示例11: testAdded
public void testAdded()
{
var index = new GitIndex(db);
writeTrashFile("file1", "file1");
writeTrashFile("dir/subfile", "dir/subfile");
var tree = new Tree(db);
index.add(trash, new FileInfo(Path.Combine(trash.FullName, "file1")));
index.add(trash, new FileInfo(Path.Combine(trash.FullName, "dir/subfile")));
var diff = new IndexDiff(tree, index);
diff.Diff();
Assert.AreEqual(2, diff.Added.Count);
Assert.IsTrue(diff.Added.Contains("file1"));
Assert.IsTrue(diff.Added.Contains("dir/subfile"));
Assert.AreEqual(0, diff.Changed.Count);
Assert.AreEqual(0, diff.Modified.Count);
Assert.AreEqual(0, diff.Removed.Count);
}
开发者ID:georgeck,项目名称:GitSharp,代码行数:19,代码来源:IndexDiffTest.cs
示例12: TestAdded
public virtual void TestAdded()
{
GitIndex index = new GitIndex(db);
WriteTrashFile("file1", "file1");
WriteTrashFile("dir/subfile", "dir/subfile");
Tree tree = new Tree(db);
tree.SetId(InsertTree(tree));
index.Add(trash, new FilePath(trash, "file1"));
index.Add(trash, new FilePath(trash, "dir/subfile"));
index.Write();
FileTreeIterator iterator = new FileTreeIterator(db);
IndexDiff diff = new IndexDiff(db, tree.GetId(), iterator);
diff.Diff();
NUnit.Framework.Assert.AreEqual(2, diff.GetAdded().Count);
NUnit.Framework.Assert.IsTrue(diff.GetAdded().Contains("file1"));
NUnit.Framework.Assert.IsTrue(diff.GetAdded().Contains("dir/subfile"));
NUnit.Framework.Assert.AreEqual(0, diff.GetChanged().Count);
NUnit.Framework.Assert.AreEqual(0, diff.GetModified().Count);
NUnit.Framework.Assert.AreEqual(0, diff.GetRemoved().Count);
}
开发者ID:ashmind,项目名称:ngit,代码行数:20,代码来源:IndexDiffTest.cs
示例13: ShouldAllowComparingOfAlreadyOpenedFile
public void ShouldAllowComparingOfAlreadyOpenedFile()
{
var index = new GitIndex(db);
var file = writeTrashFile("extensionless-file", "contents");
index.add(trash, file);
var entry = index.GetEntry("extensionless-file");
// [henon] failed on my windows box (originally only observed on mono/unix) when executed in resharper or with nunit without waiting a second!
// as the timing is not the point of the test here let's wait a sec anyway.
Thread.Sleep(TimeSpan.FromSeconds(1));
// replace contents of file (with same size so it passes the size check)
using (var writer = file.CreateText())
writer.Write("stnetnoc");
// opening the file for reading shoudn't block us from checking the contents
using (file.OpenRead())
Assert.IsTrue(entry.IsModified(trash, true));
}
开发者ID:dev218,项目名称:GitSharp,代码行数:21,代码来源:IndexModifiedTests.cs
示例14: TestCheckingOutWithConflicts
public virtual void TestCheckingOutWithConflicts()
{
GitIndex index = new GitIndex(db);
index.Add(trash, WriteTrashFile("bar", "bar"));
index.Add(trash, WriteTrashFile("foo/bar/baz/qux", "foo/bar"));
RecursiveDelete(new FilePath(trash, "bar"));
RecursiveDelete(new FilePath(trash, "foo"));
WriteTrashFile("bar/baz/qux/foo", "another nasty one");
WriteTrashFile("foo", "troublesome little bugger");
try
{
WorkDirCheckout workDirCheckout = new WorkDirCheckout(db, trash, index, index);
workDirCheckout.Checkout();
NUnit.Framework.Assert.Fail("Should have thrown exception");
}
catch (NGit.Errors.CheckoutConflictException)
{
}
// all is well
WorkDirCheckout workDirCheckout_1 = new WorkDirCheckout(db, trash, index, index);
workDirCheckout_1.SetFailOnConflict(false);
workDirCheckout_1.Checkout();
NUnit.Framework.Assert.IsTrue(new FilePath(trash, "bar").IsFile());
NUnit.Framework.Assert.IsTrue(new FilePath(trash, "foo/bar/baz/qux").IsFile());
GitIndex index2 = new GitIndex(db);
RecursiveDelete(new FilePath(trash, "bar"));
RecursiveDelete(new FilePath(trash, "foo"));
index2.Add(trash, WriteTrashFile("bar/baz/qux/foo", "bar"));
WriteTrashFile("bar/baz/qux/bar", "evil? I thought it said WEEVIL!");
index2.Add(trash, WriteTrashFile("foo", "lalala"));
workDirCheckout_1 = new WorkDirCheckout(db, trash, index2, index);
workDirCheckout_1.SetFailOnConflict(false);
workDirCheckout_1.Checkout();
NUnit.Framework.Assert.IsTrue(new FilePath(trash, "bar").IsFile());
NUnit.Framework.Assert.IsTrue(new FilePath(trash, "foo/bar/baz/qux").IsFile());
NUnit.Framework.Assert.IsNotNull(index2.GetEntry("bar"));
NUnit.Framework.Assert.IsNotNull(index2.GetEntry("foo/bar/baz/qux"));
NUnit.Framework.Assert.IsNull(index2.GetEntry("bar/baz/qux/foo"));
NUnit.Framework.Assert.IsNull(index2.GetEntry("foo"));
}
开发者ID:charles-cai,项目名称:ngit,代码行数:40,代码来源:WorkDirCheckoutTest.cs
示例15: testCheckingOutWithConflicts
public void testCheckingOutWithConflicts()
{
var index = new GitIndex(db);
index.add(trash, writeTrashFile("bar", "bar"));
index.add(trash, writeTrashFile("foo/bar/baz/qux", "foo/bar"));
recursiveDelete(new FileInfo(Path.Combine(trash.FullName, "bar")));
recursiveDelete(new DirectoryInfo(Path.Combine(trash.FullName, "foo")));
writeTrashFile("bar/baz/qux/foo", "another nasty one");
writeTrashFile("foo", "troublesome little bugger");
var workDirCheckout1 = new WorkDirCheckout(db, trash, index, index);
AssertHelper.Throws<CheckoutConflictException>(workDirCheckout1.checkout);
var workDirCheckout2 = new WorkDirCheckout(db, trash, index, index) { FailOnConflict = false };
workDirCheckout2.checkout();
Assert.IsTrue(new FileInfo(Path.Combine(trash.FullName, "bar")).IsFile());
Assert.IsTrue(new FileInfo(Path.Combine(trash.FullName, "foo/bar/baz/qux")).IsFile());
var index2 = new GitIndex(db);
recursiveDelete(new FileInfo(Path.Combine(trash.FullName, "bar")));
recursiveDelete(new DirectoryInfo(Path.Combine(trash.FullName, "foo")));
index2.add(trash, writeTrashFile("bar/baz/qux/foo", "bar"));
writeTrashFile("bar/baz/qux/bar", "evil? I thought it said WEEVIL!");
index2.add(trash, writeTrashFile("foo", "lalala"));
workDirCheckout2 = new WorkDirCheckout(db, trash, index2, index) { FailOnConflict = false };
workDirCheckout2.checkout();
Assert.IsTrue(new FileInfo(Path.Combine(trash.FullName, "bar")).IsFile());
Assert.IsTrue(new FileInfo(Path.Combine(trash.FullName, "foo/bar/baz/qux")).IsFile());
Assert.IsNotNull(index2.GetEntry("bar"));
Assert.IsNotNull(index2.GetEntry("foo/bar/baz/qux"));
Assert.IsNull(index2.GetEntry("bar/baz/qux/foo"));
Assert.IsNull(index2.GetEntry("foo"));
}
开发者ID:dev218,项目名称:GitSharp,代码行数:38,代码来源:WorkDirCheckoutTest.cs
示例16: ShouldAllowComparingOfAlreadyOpenedFile
public void ShouldAllowComparingOfAlreadyOpenedFile()
{
var index = new GitIndex(db);
var file = writeTrashFile("extensionless-file", "contents");
index.add(trash, file);
var entry = index.GetEntry("extensionless-file");
if (AssertHelper.IsRunningOnMono())
{
// File timestamps on Unix based systems are only precise to the second
Thread.Sleep(TimeSpan.FromSeconds(1));
}
// replace contents of file (with same size so it passes the size check)
using (var writer = file.CreateText())
writer.Write("stnetnoc");
// opening the file for reading shoudn't block us from checking the contents
using (file.OpenRead())
Assert.IsTrue(entry.IsModified(trash, true));
}
开发者ID:jagregory,项目名称:GitSharp,代码行数:23,代码来源:IndexModifiedTests.cs
示例17: TestIndexOnlySubDirs
public virtual void TestIndexOnlySubDirs()
{
GitIndex index = new GitIndex(db);
Tree tree = new Tree(db);
index.Add(trash, WriteTrashFile("foo/bar/baz", "foobar"));
index.Add(trash, WriteTrashFile("asdf", "asdf"));
new IndexTreeWalker(index, tree, trash, new IndexTreeWalkerTest.TestIndexTreeVisitor
(this)).Walk();
NUnit.Framework.Assert.AreEqual("asdf", indexOnlyEntriesVisited[0]);
NUnit.Framework.Assert.AreEqual("foo/bar/baz", indexOnlyEntriesVisited[1]);
}
开发者ID:charles-cai,项目名称:ngit,代码行数:11,代码来源:IndexTreeWalkerTest.cs
示例18: ProcessEntry
private void ProcessEntry(TreeEntry h, TreeEntry m, GitIndex.Entry i)
{
ObjectId iId = (i == null ? null : i.ObjectId);
ObjectId mId = (m == null ? null : m.Id);
ObjectId hId = (h == null ? null : h.Id);
string name = (i != null ? i.Name : (h != null ? h.FullName : m.FullName));
if (i == null)
{
//
// I (index) H M Result
// -------------------------------------------------------
// 0 nothing nothing nothing (does not happen)
// 1 nothing nothing exists use M
// 2 nothing exists nothing remove path from index
// 3 nothing exists exists use M
if (h == null)
{
_updated.Add(name, mId);
}
else if (m == null)
{
Removed.Add(name);
}
else
{
_updated.Add(name, mId);
}
}
else if (h == null)
{
//
// clean I==H I==M H M Result
// -----------------------------------------------------
// 4 yes N/A N/A nothing nothing keep index
// 5 no N/A N/A nothing nothing keep index
//
// 6 yes N/A yes nothing exists keep index
// 7 no N/A yes nothing exists keep index
// 8 yes N/A no nothing exists fail
// 9 no N/A no nothing exists fail
if (m == null || mId.Equals(iId))
{
if (HasParentBlob(_merge, name))
{
if (i.IsModified(_root, true))
{
Conflicts.Add(name);
}
else
{
Removed.Add(name);
}
}
}
else
{
Conflicts.Add(name);
}
}
else if (m == null)
{
//
// 10 yes yes N/A exists nothing remove path from index
// 11 no yes N/A exists nothing fail
// 12 yes no N/A exists nothing fail
// 13 no no N/A exists nothing fail
//
if (hId.Equals(iId))
{
if (i.IsModified(_root, true))
{
Conflicts.Add(name);
}
else
{
Removed.Add(name);
}
}
else
{
Conflicts.Add(name);
}
}
else
{
if (!hId.Equals(mId) && !hId.Equals(iId) && !mId.Equals(iId))
{
Conflicts.Add(name);
}
else if (hId.Equals(iId) && !mId.Equals(iId))
{
if (i.IsModified(_root, true))
{
Conflicts.Add(name);
}
//.........这里部分代码省略.........
开发者ID:dev218,项目名称:GitSharp,代码行数:101,代码来源:WorkDirCheckout.cs
示例19: LastChar
/// <summary>Helper for accessing tree/blob/index methods.</summary>
/// <remarks>Helper for accessing tree/blob/index methods.</remarks>
/// <param name="i"></param>
/// <returns>'/' for Tree entries and NUL for non-treeish objects</returns>
public static int LastChar(GitIndex.Entry i)
{
// FIXME, gitlink etc. Currently Trees cannot appear in the
// index so '\0' is always returned, except maybe for submodules
// which we do not support yet.
return FileMode.TREE.Equals(i.GetModeBits()) ? '/' : '\0';
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:11,代码来源:TreeEntry.cs
示例20: VisitEntry
public override void VisitEntry(TreeEntry treeEntry, GitIndex.Entry indexEntry, FilePath
file)
{
if (treeEntry == null)
{
this._enclosing.indexOnlyEntriesVisited.AddItem(indexEntry.GetName());
}
else
{
if (indexEntry == null)
{
this._enclosing.treeOnlyEntriesVisited.AddItem(treeEntry.GetFullName());
}
else
{
this._enclosing.bothVisited.AddItem(indexEntry.GetName());
}
}
}
开发者ID:charles-cai,项目名称:ngit,代码行数:19,代码来源:IndexTreeWalkerTest.cs
注:本文中的GitIndex类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论