コード例 #1
0
ファイル: DirCacheBuilder.cs プロジェクト: gilran/GitSharp
 private static InvalidOperationException bad(DirCacheEntry a, String msg)
 {
     return new InvalidOperationException(msg + ": " + a.getStage() + " " + a.getPathString());
 }
コード例 #2
0
 /**
  * Create a new unmerged path exception.
  *
  * @param dce
  *            the first non-zero stage of the unmerged path.
  */
 public UnmergedPathException(DirCacheEntry dce) 
     : base("Unmerged path: " + dce.getPathString())
 {
     entry = dce;
 }
コード例 #3
0
 /// <summary>
 /// Create a new unmerged path exception.
 /// </summary>
 /// <param name="entry">The first non-zero stage of the unmerged path.</param>
 public UnmergedPathException(DirCacheEntry entry)
     : base("Unmerged path: " + entry.getPathString())
 {
     _entry = entry;
 }
コード例 #4
0
        private void testLongPath(int len)
        {
            string longPath = makeLongPath(len);
            string shortPath = "~~~ shorter-path";

            DirCacheEntry longEnt = new DirCacheEntry(longPath);
            DirCacheEntry shortEnt = new DirCacheEntry(shortPath);
            Assert.AreEqual(longPath, longEnt.getPathString());
            Assert.AreEqual(shortPath, shortEnt.getPathString());

            DirCache dc1 = DirCache.Lock(db);
            DirCacheBuilder b = dc1.builder();
            b.add(longEnt);
            b.add(shortEnt);
            Assert.IsTrue(b.commit());
            Assert.AreEqual(2, dc1.getEntryCount());
            Assert.AreSame(longEnt, dc1.getEntry(0));
            Assert.AreSame(shortEnt, dc1.getEntry(1));

            DirCache dc2 = DirCache.read(db);
            Assert.AreEqual(2, dc2.getEntryCount());
            Assert.AreNotSame(longEnt, dc2.getEntry(0));
            Assert.AreEqual(longPath, dc2.getEntry(0).getPathString());
            Assert.AreNotSame(shortEnt, dc2.getEntry(1));
            Assert.AreEqual(shortPath, dc2.getEntry(1).getPathString());
        }
コード例 #5
0
        public void testFindSingleFile()
        {
            string path = "a-File-path";
            DirCache dc = DirCache.read(db);
            DirCacheBuilder b = dc.builder();
            Assert.IsNotNull(b);

            DirCacheEntry entOrig = new DirCacheEntry(path);
            Assert.AreNotSame(path, entOrig.getPathString());
            Assert.AreEqual(path, entOrig.getPathString());
            b.add(entOrig);
            b.finish();

            Assert.AreEqual(1, dc.getEntryCount());
            Assert.AreSame(entOrig, dc.getEntry(0));
            Assert.AreEqual(0, dc.findEntry(path));

            Assert.AreEqual(-1, dc.findEntry("@@-before"));
            Assert.AreEqual(0, real(dc.findEntry("@@-before")));

            Assert.AreEqual(-2, dc.findEntry("a-zoo"));
            Assert.AreEqual(1, real(dc.findEntry("a-zoo")));

            Assert.AreSame(entOrig, dc.getEntry(path));
        }
コード例 #6
0
        public void testBuildOneFile_FinishWriteCommit()
        {
            string path = "a-File-path";
            var mode = GitSharp.FileMode.RegularFile;
            long lastModified = 1218123387057L;
            int Length = 1342;
            DirCacheEntry entOrig;

            DirCache dc = DirCache.Lock(db);
            DirCacheBuilder b = dc.builder();
            Assert.IsNotNull(b);

            entOrig = new DirCacheEntry(path);
            entOrig.setFileMode(mode);
            entOrig.setLastModified(lastModified);
            entOrig.setLength(Length);

            Assert.AreNotSame(path, entOrig.getPathString());
            Assert.AreEqual(path, entOrig.getPathString());
            Assert.AreEqual(ObjectId.ZeroId, entOrig.getObjectId());
            Assert.AreEqual(mode.Bits, entOrig.getRawMode());
            Assert.AreEqual(0, entOrig.getStage());
            Assert.AreEqual(lastModified, entOrig.getLastModified());
            Assert.AreEqual(Length, entOrig.getLength());
            Assert.IsFalse(entOrig.isAssumeValid());
            b.add(entOrig);

            b.finish();
            Assert.AreEqual(1, dc.getEntryCount());
            Assert.AreSame(entOrig, dc.getEntry(0));

            dc.write();
            Assert.IsTrue(dc.commit());

            dc = DirCache.read(db);
            Assert.AreEqual(1, dc.getEntryCount());

            DirCacheEntry entRead = dc.getEntry(0);
            Assert.AreNotSame(entOrig, entRead);
            Assert.AreEqual(path, entRead.getPathString());
            Assert.AreEqual(ObjectId.ZeroId, entOrig.getObjectId());
            Assert.AreEqual(mode.Bits, entOrig.getRawMode());
            Assert.AreEqual(0, entOrig.getStage());
            Assert.AreEqual(lastModified, entOrig.getLastModified());
            Assert.AreEqual(Length, entOrig.getLength());
            Assert.IsFalse(entOrig.isAssumeValid());
        }
コード例 #7
0
 public static bool Equals(CGitIndexRecord cgir, DirCacheEntry dirCacheEntry)
 {
     return cgir.Mode == dirCacheEntry.getRawMode() &&
            cgir.Id == dirCacheEntry.getObjectId() &&
            cgir.Stage == dirCacheEntry.getStage() &&
            cgir.Path == dirCacheEntry.getPathString();
 }
コード例 #8
0
        private static void AssertAreEqual(CGitIndexRecord c, DirCacheEntry j)
        {
            Assert.IsNotNull(c);
            Assert.IsNotNull(j);

            Assert.AreEqual(c.Path, j.getPathString());
            Assert.AreEqual(c.Id, j.getObjectId());
            Assert.AreEqual(c.Mode, j.getRawMode());
            Assert.AreEqual(c.Stage, j.getStage());
        }