Package org.tmatesoft.hg.core

Examples of org.tmatesoft.hg.core.HgChangeset


          sb.append(", ");
        }
        final Pair<Nodeid, Nodeid> parents = entry.parentRevisions();
        final boolean isJoin = !parents.first().isNull() && !parents.second().isNull();
        final boolean isFork = entry.children().size() > 1;
        final HgChangeset cset = entry.changeset();
        System.out.printf("%d:%s - %s (%s)\n", cset.getRevisionIndex(), cset.getNodeid().shortNotation(), cset.getComment(), cset.getPhase());
        System.out.printf("\tKnown as %s (file rev:%s)\n", entry.file().getPath(), entry.fileRevision().shortNotation());
        if (!isJoin && !isFork && !entry.children().isEmpty()) {
          HgChangeset p1 = entry.parents().first();
          HgChangeset p2 = entry.parents().second();
          System.out.printf("\tp1:%d, p2:%d\n", p1 == null ? -1 : p1.getRevisionIndex(), p2 == null ? -1 : p2.getRevisionIndex());
          System.out.printf("\t=> %s\n", sb);
        }
        if (isJoin) {
          HgChangeset p1 = entry.parents().first();
          HgChangeset p2 = entry.parents().second();
          System.out.printf("\tjoin <= (%d:%s, %d:%s)", p1.getRevisionIndex(), p1.getNodeid().shortNotation(), p2.getRevisionIndex(), p2.getNodeid().shortNotation());
          if (isFork) {
            System.out.print(", ");
          }
        }
        if (isFork) {
View Full Code Here


          sb.append(", ");
        }
        final Pair<Nodeid, Nodeid> parents = entry.parentRevisions();
        final boolean isJoin = !parents.first().isNull() && !parents.second().isNull();
        final boolean isFork = entry.children().size() > 1;
        final HgChangeset cset = entry.changeset();
        System.out.printf("%d:%s - %s (%s)\n", cset.getRevisionIndex(), cset.getNodeid().shortNotation(), cset.getComment(), cset.getPhase());
        System.out.printf("\tKnown as %s (file rev:%s)\n", entry.file().getPath(), entry.fileRevision().shortNotation());
        if (!isJoin && !isFork && !entry.children().isEmpty()) {
          HgChangeset p1 = entry.parents().first();
          HgChangeset p2 = entry.parents().second();
          System.out.printf("\tp1:%d, p2:%d\n", p1 == null ? -1 : p1.getRevisionIndex(), p2 == null ? -1 : p2.getRevisionIndex());
          System.out.printf("\t=> %s\n", sb);
        }
        if (isJoin) {
          HgChangeset p1 = entry.parents().first();
          HgChangeset p2 = entry.parents().second();
          System.out.printf("\tjoin <= (%d:%s, %d:%s)", p1.getRevisionIndex(), p1.getNodeid().shortNotation(), p2.getRevisionIndex(), p2.getNodeid().shortNotation());
          if (isFork) {
            System.out.print(", ");
          }
        }
        if (isFork) {
View Full Code Here

    Transaction tr = newTransaction(hgRepo);
    Nodeid commitRev = cf.commit("Commit with add/remove cmd",  tr);
    tr.commit();
    //
    List<HgChangeset> commits = new HgLogCommand(hgRepo).changeset(commitRev).execute();
    HgChangeset cmt = commits.get(0);
    errorCollector.assertEquals(1, cmt.getAddedFiles().size());
    errorCollector.assertEquals("xx", cmt.getAddedFiles().get(0).getPath().toString());
    errorCollector.assertEquals(1, cmt.getRemovedFiles().size());
    errorCollector.assertEquals("d", cmt.getRemovedFiles().get(0).toString());
    ByteArrayChannel sink = new ByteArrayChannel();
    new HgCatCommand(hgRepo).file(Path.create("xx")).changeset(commitRev).execute(sink);
    assertArrayEquals("xyz".getBytes(), sink.toArray());
    //
    RepoUtils.assertHgVerifyOk(errorCollector, repoLoc);
View Full Code Here

    Nodeid commitRev3 = cf.commit("THIRD",  tr);
    tr.commit();
    //
    List<HgChangeset> commits = new HgLogCommand(hgRepo).range(parentCsetRevIndex+1, TIP).execute();
    assertEquals(3, commits.size());
    HgChangeset c1 = commits.get(0);
    HgChangeset c2 = commits.get(1);
    HgChangeset c3 = commits.get(2);
    errorCollector.assertEquals(c1.getNodeid(), commitRev1);
    errorCollector.assertEquals(c2.getNodeid(), commitRev2);
    errorCollector.assertEquals(c3.getNodeid(), commitRev3);
    errorCollector.assertEquals("branch1", c1.getBranch());
    errorCollector.assertEquals("branch2", c2.getBranch());
    errorCollector.assertEquals(DEFAULT_BRANCH_NAME, c3.getBranch());
    errorCollector.assertEquals("FIRST", c1.getComment());
    errorCollector.assertEquals("SECOND", c2.getComment());
    errorCollector.assertEquals("THIRD", c3.getComment());
    RepoUtils.assertHgVerifyOk(errorCollector, repoLoc);
  }
View Full Code Here

    Nodeid secondRev = cf.commit("SECOND", tr);
    tr.commit();
    //
    List<HgChangeset> commits = new HgLogCommand(hgRepo).execute();
    errorCollector.assertEquals(2, commits.size());
    HgChangeset c1 = commits.get(0);
    HgChangeset c2 = commits.get(1);
    errorCollector.assertEquals("FIRST", c1.getComment());
    errorCollector.assertEquals("SECOND", c2.getComment());
    errorCollector.assertEquals(df.getPath(), c2.getAffectedFiles().get(0));
    errorCollector.assertEquals(c1.getNodeid(), c2.getFirstParentRevision());
    errorCollector.assertEquals(Nodeid.NULL, c2.getSecondParentRevision());
    errorCollector.assertEquals(secondRev, c2.getNodeid());
  }
View Full Code Here

    Transaction tr = newTransaction(hgRepo);
    Nodeid c1Rev = cf.commit(comment,  tr);
    tr.commit();
    List<HgChangeset> commits = new HgLogCommand(hgRepo).execute();
    errorCollector.assertEquals(1, commits.size());
    HgChangeset c1 = commits.get(0);
    errorCollector.assertEquals(1, c1.getAffectedFiles().size());
    errorCollector.assertEquals(df.getPath(), c1.getAffectedFiles().get(0));
    errorCollector.assertEquals(0, c1.getRevisionIndex());
    errorCollector.assertEquals(Nodeid.NULL, c1.getFirstParentRevision());
    errorCollector.assertEquals(Nodeid.NULL, c1.getSecondParentRevision());
    errorCollector.assertEquals(HgRepository.DEFAULT_BRANCH_NAME, c1.getBranch());
    errorCollector.assertEquals(comment, c1.getComment());
    errorCollector.assertEquals(c1Rev, c1.getNodeid());
    ByteArrayChannel bac = new ByteArrayChannel();
    new HgCatCommand(hgRepo).file(df.getPath()).execute(bac);
    assertArrayEquals(initialContent, bac.toArray());
  }
View Full Code Here

    HgDataFile dfD = hgRepo.getFileNode("d");
    assertTrue("[sanity]", dfD.exists());
    File fileD = new File(repoLoc, "d");
    assertTrue("[sanity]", fileD.canRead());
    final int parentCsetRevIndex = hgRepo.getChangelog().getLastRevision();
    HgChangeset parentCset = new HgLogCommand(hgRepo).range(parentCsetRevIndex, parentCsetRevIndex).execute().get(0);
    assertEquals("[sanity]", DEFAULT_BRANCH_NAME, parentCset.getBranch());
    assertEquals("[sanity]", DEFAULT_BRANCH_NAME, hgRepo.getWorkingCopyBranchName());
    //
    RepoUtils.modifyFileAppend(fileD, "A CHANGE\n");
    CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), parentCsetRevIndex);
    FileContentSupplier contentProvider = new FileContentSupplier(hgRepo, fileD);
    cf.add(dfD, contentProvider);
    cf.branch("branch1");
    Transaction tr = newTransaction(hgRepo);
    Nodeid commitRev1 = cf.commit("FIRST",  tr);
    tr.commit();
    //
    List<HgChangeset> commits = new HgLogCommand(hgRepo).range(parentCsetRevIndex+1, TIP).execute();
    assertEquals(1, commits.size());
    HgChangeset c1 = commits.get(0);
    errorCollector.assertEquals(c1.getNodeid(), commitRev1);
    errorCollector.assertEquals("branch1", c1.getBranch());
    errorCollector.assertEquals("FIRST", c1.getComment());
    //
    // check if cached value in hgRepo got updated
    errorCollector.assertEquals("branch1", hgRepo.getWorkingCopyBranchName());
    //
    RepoUtils.assertHgVerifyOk(errorCollector, repoLoc);
View Full Code Here

      } else {
        errorCollector.assertEquals(parents_b.second(), parents_a.second().getNodeid());
      }
      //
      if (checkPrevInChildren && !cmdResult.isEmpty()) {
        HgChangeset prevChangeset = reverseResult ? cmdResult.getFirst() : cmdResult.getLast();
        String msg = String.format("No parent-child bind between revisions %d and %d", prevChangeset.getRevisionIndex(), entry.changeset().getRevisionIndex());
        errorCollector.assertTrue(msg, entry.children().contains(prevChangeset));
      }
      if (checkPrevInParents && !cmdResult.isEmpty()) {
        HgChangeset prevChangeset = reverseResult ? cmdResult.getFirst() : cmdResult.getLast();
        String msg = String.format("No parent-child bind between revisions %d and %d", prevChangeset.getRevisionIndex(), entry.changeset().getRevisionIndex());
        errorCollector.assertTrue(msg, p.first() == prevChangeset || p.second() == prevChangeset);
      }
      //
      if (reverseResult) {
        cmdResult.addFirst(entry.changeset());
View Full Code Here

    public final RenameCollector rh = new RenameCollector();
    public List<HgChangeset> lastChangesetReportedAtRename = new LinkedList<HgChangeset>();

    public void copy(HgFileRevision from, HgFileRevision to) throws HgCallbackTargetException {
      Assert.assertTrue("Renames couldn't be reported prior to any change", getChanges().size() > 0);
      HgChangeset lastKnown = getChanges().get(getChanges().size() - 1);
      lastChangesetReportedAtRename.add(lastKnown);
      rh.copy(from, to);
    }
View Full Code Here

TOP

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

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.