Package com.aragost.javahg

Examples of com.aragost.javahg.BaseRepository


        Assert.assertTrue(pool.getServers().isEmpty());
    }

    @Test
    public void testConfigChanges() throws IOException {
        BaseRepository repo = getTestRepository();
        GenericCommand cmd = new GenericCommand(repo, "version") {
            {
                {
                    cmdAppend("--config", "ui.username=xxx");
                }
            }
        };
        cmd.execute();
        writeFile("A");
        repo.workingCopy().add("A");
        try {
            // The previous config change is not forgotten
            CommitCommand commit = CommitCommand.on(repo).message("m");
            Changeset cs = commit.execute();
            assertFailedExecution(commit, "Username is " + cs.getUser());
View Full Code Here


    }

    /** validate that clone requiring auth will use auth in hgrc */
    @Test
    public void testCloneRequiringAuth() throws Exception {
        BaseRepository repoA = getTestRepository();

        writeFile(repoA, "x", "abc");
        AddCommand.on(repoA).execute();
        CommitCommand.on(repoA).message("added x").user("user").execute();

View Full Code Here

     * @throws IOException
     */
    private String retrieveStartupStderr(RepositoryConfiguration conf) throws IOException {
        conf.setHgrcPath(Utils.resourceAsFile("/missing-extension.hgrc").getPath());
        File dir = Files.createTempDir();
        BaseRepository repo = Repository.create(conf, dir);
        String stderr = getFirstServer(repo).getStartupStderr();
        repo.close();
        deleteTempDir(dir);
        return stderr;
    }
View Full Code Here

   
    @Test
    public void testServerIdle() throws InterruptedException {
        RepositoryConfiguration conf = makeRepoConf();
        conf.setServerIdleTime(1);
        BaseRepository repo = Repository.create(conf, Files.createTempDir());

        Assert.assertEquals(1, repo.getServerPool().getNumIdleServers());

        Thread.sleep(2000);

        Assert.assertEquals(0, repo.getServerPool().getNumIdleServers());
        LogCommand.on(repo).execute();
        Assert.assertEquals(1, repo.getServerPool().getNumIdleServers());
    }
View Full Code Here

    public void testPushCreatingNewHead() throws IOException {
        Repository repoA = getTestRepository();
        Changeset base = createChangeset();

        File dir = createTempDir();
        BaseRepository repoB = Repository.clone(dir, repoA.getDirectory().getPath());

        Changeset a = createChangeset();
        update(base);
        Changeset b = createChangeset();

        Files.write("a".getBytes(), new File(repoB.getDirectory(), "file"));
        AddCommand.on(repoB).execute();
        CommitCommand.on(repoB).message("m").user("u").execute();
        PushCommand push = PushCommand.on(repoA);
        try {
            push.execute(repoB.getDirectory().getPath());
            assertFailedExecution(push);
        } catch (ExecutionException e) {
            Assert.assertTrue(e.getMessage().startsWith("push creates new remote head"));
        }

        List<Changeset> changesets = PushCommand.on(repoA).force().execute(repoB.getDirectory().getPath());
        // This strange assert is because mercurial 3.1.1 returns more than 2 changesets
        // not sure when the change happened between 2.8.1 and 3.1.1
        Assert.assertTrue(2 <= changesets.size() && changesets.size() <= 7);
        Assert.assertTrue(changesets.contains(a));
        Assert.assertTrue(changesets.contains(b));

        repoB.close();
        deleteTempDir(dir);
    }
View Full Code Here

    public void testPushCreatingNewHead() throws IOException {
        Repository repoA = getTestRepository();
        Changeset base = createChangeset();

        File dir = createTempDir();
        BaseRepository repoB = Repository.clone(dir, repoA.getDirectory().getPath());

        Changeset a = createChangeset();
        update(base);
        Changeset b = createChangeset();

        Files.write("a".getBytes(), new File(repoB.getDirectory(), "file"));
        AddCommand.on(repoB).execute();
        CommitCommand.on(repoB).message("m").user("u").execute();
        PushCommand push = PushCommand.on(repoA);
        try {
            push.execute(repoB.getDirectory().getPath());
            assertFailedExecution(push);
        } catch (ExecutionException e) {
            Assert.assertTrue(e.getMessage().startsWith("push creates new remote head"));
        }

        List<Changeset> changesets = PushCommand.on(repoA).force().execute(repoB.getDirectory().getPath());
        Assert.assertEquals(2, changesets.size());
        Assert.assertTrue(changesets.contains(a));
        Assert.assertTrue(changesets.contains(b));

        repoB.close();
        deleteTempDir(dir);
    }
View Full Code Here

public class BranchCommandTest extends AbstractTestCase {

    @Test
    public void testSet() throws IOException {
        BaseRepository repo = getTestRepository();
        BranchCommand.on(repo).set("x");
        Changeset cs = commit();
        Assert.assertEquals("x", cs.getBranch());
    }
View Full Code Here

        Assert.assertEquals("x", cs.getBranch());
    }

    @Test
    public void testGet() throws IOException {
        BaseRepository repo = getTestRepository();
        Assert.assertEquals("default", BranchCommand.on(repo).get());
        BranchCommand.on(repo).set("x");
        Assert.assertEquals("x", BranchCommand.on(repo).get());
        commit();
        Assert.assertEquals("x", BranchCommand.on(repo).get());
View Full Code Here


   
    @Test
    public void testClean() throws IOException {
        BaseRepository repo = getTestRepository();
        BranchCommand.on(repo).set("x");
        String oldName = BranchCommand.on(repo).clean();
        Assert.assertEquals("default", oldName);

        BranchCommand.on(repo).set("y");
View Full Code Here

import com.aragost.javahg.test.AbstractTestCase;

public class GraftCommandTest extends AbstractTestCase {

    private boolean isGraftSupported() {
        BaseRepository repo = getTestRepository();
        try {
            PhaseCommand.on(repo).rev(Changeset.NULL_ID).execute();
            return true;
        } catch (UnknownCommandException e) {
            return false;
View Full Code Here

TOP

Related Classes of com.aragost.javahg.BaseRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.