Package org.tmatesoft.hg.core

Examples of org.tmatesoft.hg.core.HgPushCommand


    HgRemoteRepository hgRemote = new HgLookup().detectRemote(cmdLineOpts.getSingle(""), hgRepo.getRepository());
    if (hgRemote.isInvalid()) {
      System.err.printf("Remote repository %s is not valid", hgRemote.getLocation());
      return;
    }
    HgPushCommand cmd = hgRepo.createPushCommand();
    cmd.destination(hgRemote);
    cmd.execute();
    System.out.printf("Added %d changesets\n", cmd.getPushedRevisions().size());
  }
View Full Code Here


    File dstRepoLoc = RepoUtils.initEmptyTempRepo("test-push2empty-dst");
    HgServer server = new HgServer().start(dstRepoLoc);
    try {
      final HgLookup hgLookup = new HgLookup();
      HgRepository srcRepo = hgLookup.detect(srcRepoLoc);
      HgPushCommand cmd = new HgPushCommand(srcRepo);
      final HgRemoteRepository dstRemote = hgLookup.detect(server.getURL());
      cmd.destination(dstRemote);
      cmd.execute();
      final HgRepository dstRepo = hgLookup.detect(dstRepoLoc);
      checkRepositoriesAreSame(srcRepo, dstRepo);
      final List<Nodeid> outgoing = new HgOutgoingCommand(srcRepo).against(dstRemote).executeLite();
      errorCollector.assertTrue(outgoing.toString(), outgoing.isEmpty());
    } finally {
View Full Code Here

      new HgCheckoutCommand(srcRepo).changeset(7).clean(true).execute();
      assertEquals("[sanity]", "no-merge", srcRepo.getWorkingCopyBranchName());
      RepoUtils.modifyFileAppend(f1, "change2");
      new HgCommitCommand(srcRepo).message("Commit 2").execute();
      //
      new HgPushCommand(srcRepo).destination(dstRemote).execute();
      checkRepositoriesAreSame(srcRepo, hgLookup.detect(dstRepoLoc));
      final List<Nodeid> outgoing = new HgOutgoingCommand(srcRepo).against(dstRemote).executeLite();
      errorCollector.assertTrue(outgoing.toString(), outgoing.isEmpty());
    } finally {
      server.stop();
View Full Code Here

      RepoUtils.modifyFileAppend(f1, "// aaa");
      final HgCommitCommand commitCmd = new HgCommitCommand(srcRepo).message("Commit aaa");
      assertTrue(commitCmd.execute().isOk());
      Nodeid newCommit = commitCmd.getCommittedRevision();
      //
      new HgPushCommand(srcRepo).destination(dstRemote).execute();
      HgRepository dstRepo = hgLookup.detect(dstRepoLoc);
      final HgChangelog srcClog = srcRepo.getChangelog();
      final HgChangelog dstClog = dstRepo.getChangelog();
      // refresh PhasesHelper
      phaseHelper = new PhasesHelper(HgInternals.getImplementationRepo(srcRepo));
View Full Code Here

      RepoUtils.modifyFileAppend(f1, "// aaa");
      final HgCommitCommand commitCmd = new HgCommitCommand(srcRepo).message("Commit aaa");
      assertTrue(commitCmd.execute().isOk());
      final Nodeid newCommit = commitCmd.getCommittedRevision();
      //
      new HgPushCommand(srcRepo).destination(dstRemote).execute();
      // refresh phase information
      srcPhase = new PhasesHelper(HgInternals.getImplementationRepo(srcRepo));
      // r5 and r6 are changed to match server phases (more exposed)
      errorCollector.assertEquals(HgPhase.Public, srcPhase.getPhase(r5, null));
      errorCollector.assertEquals(HgPhase.Draft, srcPhase.getPhase(r6, null));
View Full Code Here

    HgServer server = new HgServer().publishing(false).start(dstRepoLoc);
    try {
      final HgLookup hgLookup = new HgLookup();
      final HgRepository srcRepo = hgLookup.detect(srcRepoLoc);
      final HgRemoteRepository dstRemote = hgLookup.detect(server.getURL());
      new HgPushCommand(srcRepo).destination(dstRemote).execute();
      //
      // make sure pushed repository got same draft root
      final Nodeid r4PublicHead = srcRepo.getChangelog().getRevision(r4);
      final Nodeid r5DraftRoot = srcRepo.getChangelog().getRevision(r5);
      HgRepository dstRepo = hgLookup.detect(dstRepoLoc);
      final HgChangelog dstClog = dstRepo.getChangelog();
      PhasesHelper dstPhase = new PhasesHelper(HgInternals.getImplementationRepo(dstRepo));
      assertEquals(HgPhase.Public, dstPhase.getPhase(dstClog.getRevisionIndex(r4PublicHead), r4PublicHead));
      assertEquals(HgPhase.Draft, dstPhase.getPhase(dstClog.getRevisionIndex(r5DraftRoot), r5DraftRoot));
      //
      // now, graduate some local revisions, r5:draft->public, r6:secret->public, r9: secret->draft
      final ExecHelper srcRun = new ExecHelper(new OutputParser.Stub(), srcRepoLoc);
      srcRun.exec("hg", "phase", "--public", String.valueOf(r5));
      srcRun.exec("hg", "phase", "--public", String.valueOf(r6));
      srcRun.exec("hg", "phase", "--draft", String.valueOf(r9));
      // PhaseHelper shall be new for the command, and would pick up these external changes
      new HgPushCommand(srcRepo).destination(dstRemote).execute();
      final Nodeid r6Nodeid = srcRepo.getChangelog().getRevision(r6);
      final Nodeid r9Nodeid = srcRepo.getChangelog().getRevision(r9);
      // refresh
      dstPhase = new PhasesHelper(HgInternals.getImplementationRepo(dstRepo));
      // not errorCollector as subsequent code would fail if these secret revs didn't get into dst
View Full Code Here

      final HgRemoteRepository dstRemote = hgLookup.detect(server.getURL());
      PhasesHelper phaseHelper = new PhasesHelper(HgInternals.getImplementationRepo(srcRepo));
      final RevisionSet allDraft = phaseHelper.allDraft();
      assertFalse("[sanity]", allDraft.isEmpty());
      // push all changes
      new HgPushCommand(srcRepo).destination(dstRemote).execute();
      HgRepository dstRepo = hgLookup.detect(dstRepoLoc);
      final HgChangelog srcClog = srcRepo.getChangelog();
      final HgChangelog dstClog = dstRepo.getChangelog();
      // refresh PhasesHelper
      phaseHelper = new PhasesHelper(HgInternals.getImplementationRepo(srcRepo));
View Full Code Here

      final HgRepository srcRepo = hgLookup.detect(srcRepoLoc);
      final HgRemoteRepository dstRemote = hgLookup.detect(server.getURL());
      PhasesHelper phaseHelper = new PhasesHelper(HgInternals.getImplementationRepo(srcRepo));
      final RevisionSet allSecret = phaseHelper.allSecret();
      assertFalse("[sanity]", allSecret.isEmpty());
      new HgPushCommand(srcRepo).destination(dstRemote).execute();
      HgRepository dstRepo = hgLookup.detect(dstRepoLoc);
      final HgChangelog srcClog = srcRepo.getChangelog();
      final HgChangelog dstClog = dstRepo.getChangelog();
      errorCollector.assertEquals(srcClog.getRevisionCount() - allSecret.size(), dstClog.getRevisionCount());
      for (Nodeid n : allSecret) {   
View Full Code Here

      final HgCommitCommand commitCmd = new HgCommitCommand(srcRepo).message("Commit 1");
      assertTrue(commitCmd.execute().isOk());
      assertEquals(bm1, srcRepo.getBookmarks().getActiveBookmarkName());
      assertEquals(commitCmd.getCommittedRevision(), srcRepo.getBookmarks().getRevision(bm1));
      //
      new HgPushCommand(srcRepo).destination(dstRemote).execute();
      Thread.sleep(300); // let the server perform the update
      //
      HgBookmarks srcBookmarks = srcRepo.getBookmarks();
      final HgChangelog srcClog = srcRepo.getChangelog();
      // first, check local bookmarks are intact
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.core.HgPushCommand

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.