Mercurial > hg4j
diff test/org/tmatesoft/hg/test/TestCommit.java @ 539:9edfd5a223b8
Commit: handle empty repository case
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 13 Feb 2013 18:44:58 +0100 |
parents | dd4f6311af52 |
children | 6ca3d0c5b4bc |
line wrap: on
line diff
--- a/test/org/tmatesoft/hg/test/TestCommit.java Tue Feb 05 22:30:21 2013 +0100 +++ b/test/org/tmatesoft/hg/test/TestCommit.java Wed Feb 13 18:44:58 2013 +0100 @@ -16,6 +16,8 @@ */ package org.tmatesoft.hg.test; +import static org.tmatesoft.hg.repo.HgRepository.NO_REVISION; + import java.io.File; import java.io.FileWriter; import java.nio.ByteBuffer; @@ -41,15 +43,32 @@ new ExecHelper(new OutputParser.Stub(true), repoLoc).run("hg", "commit", "--addremove", "-m", "FIRST"); // HgRepository hgRepo = new HgLookup().detect(repoLoc); - CommitFacility cf = new CommitFacility(hgRepo, 0 /*NO_REVISION*/); + CommitFacility cf = new CommitFacility(hgRepo, 0); + // FIXME test diff for processing changed newlines - if a whole line or just changed endings are in the patch! + cf.add(hgRepo.getFileNode("file1"), new ByteArraySupplier("hello\nworld".getBytes())); + cf.commit("SECOND"); + // /tmp/test-commit2non-empty/.hg/ store/data/file1.i dumpData + } + + @Test + public void testCommitToEmpty() throws Exception { + File repoLoc = RepoUtils.initEmptyTempRepo("test-commit2empty"); + FileWriter fw = new FileWriter(new File(repoLoc, "file1")); + fw.write("hello"); + fw.close(); + // + HgRepository hgRepo = new HgLookup().detect(repoLoc); + CommitFacility cf = new CommitFacility(hgRepo, NO_REVISION); // FIXME test diff for processing changed newlines - if a whole line or just changed endings are in the patch! cf.add(hgRepo.getFileNode("file1"), new ByteArraySupplier("hello\nworld".getBytes())); cf.commit("commit 1"); - // /tmp/test-commit2non-empty/.hg/ store/data/file1.i dumpData } - + public static void main(String[] args) throws Exception { - new TestCommit().testCommitToNonEmpty(); + new TestCommit().testCommitToEmpty(); + if (Boolean.TRUE.booleanValue()) { + return; + } String input = "abcdefghijklmnopqrstuvwxyz"; ByteArraySupplier bas = new ByteArraySupplier(input.getBytes()); ByteBuffer bb = ByteBuffer.allocate(7);