Package org.tmatesoft.hg.core

Examples of org.tmatesoft.hg.core.Nodeid


  private void checkFileSneakerPerformance() throws Exception {
    HgChangesetFileSneaker fs1 = new HgChangesetFileSneaker(hgRepo);
    HgChangesetFileSneaker fs2 = new HgChangesetFileSneaker(hgRepo);
    fs1.followRenames(true);
    fs2.followRenames(true);
    Nodeid cset = hgRepo.getChangelog().getRevision(2);
    Path fname = Path.create("dir9/file9"); // close to the manifest end
    fs1.changeset(cset);
    fs2.changeset(cset);
//    hgRepo.getManifest().getFileRevision(TIP, fname);
    final long start1 = System.nanoTime();
    boolean e1 = fs1.checkExists(fname);
    final long end1 = System.nanoTime();
    boolean e2 = fs2.checkExists(fname);
    final long end2 = System.nanoTime();
    Nodeid fr = hgRepo.getManifest().getFileRevision(TIP, fname);
    final long end3 = System.nanoTime();
    System.out.printf("\t1st run: %d ms, %b\n\t2nd run: %d ms, %b\n\tfile only: %d ms", (end1 - start1) / 1000000, e1, (end2 - end1) / 1000000, e2, (end3-end2)/1000000);
    if (!fr.equals(fs1.revision()) || !fr.equals(fs2.revision())) {
      throw new AssertionError();
    }
    ManifestRevision mr = new ManifestRevision(null, null);
    final long _s1 = System.nanoTime();
    hgRepo.getManifest().walk(0, 0, mr);
View Full Code Here


  private void testStatusInternals() throws HgException, HgRuntimeException {
    HgDataFile n = hgRepo.getFileNode(Path.create("design.txt"));
    for (String s : new String[] {"011dfd44417c72bd9e54cf89b82828f661b700ed", "e5529faa06d53e06a816e56d218115b42782f1ba", "c18e7111f1fc89a80a00f6a39d51288289a382fc"}) {
      // expected: 359, 2123, 3079
      byte[] b = s.getBytes();
      final Nodeid nid = Nodeid.fromAscii(b, 0, b.length);
      System.out.println(s + " : " + n.getLength(nid));
    }
  }
View Full Code Here

  }

  private String print(HgChangeset cset) throws HgException, HgRuntimeException {
    StringBuilder sb = new StringBuilder();
    Formatter f = new Formatter(sb);
    final Nodeid csetNodeid = cset.getNodeid();
    f.format("changeset:   %d:%s\n", cset.getRevisionIndex(), complete ? csetNodeid : csetNodeid.shortNotation());
    if (cset.getRevisionIndex() == tip || repo.getTags().isTagged(csetNodeid)) {
      sb.append("tag:         ");
      for (String t : repo.getTags().tags(csetNodeid)) {
        sb.append(t);
        sb.append(' ');
      }
      if (cset.getRevisionIndex() == tip) {
        sb.append("tip");
      }
      sb.append('\n');
    }
    if (complete) {
      f.format("phase:       %s\n", cset.getPhase().name());
      Nodeid p1 = cset.getFirstParentRevision();
      Nodeid p2 = cset.getSecondParentRevision();
      Nodeid mr = cset.getManifestRevision();
      int p1x = p1.isNull() ? -1 : repo.getChangelog().getRevisionIndex(p1);
      int p2x = p2.isNull() ? -1 : repo.getChangelog().getRevisionIndex(p2);
      int mx = mr.isNull() ? -1 : repo.getManifest().getRevisionIndex(mr);
      f.format("parent:      %d:%s\nparent:      %d:%s\nmanifest:    %d:%s\n", p1x, p1, p2x, p2, mx, cset.getManifestRevision());
    }
    f.format("user:        %s\ndate:        %s\n", cset.getUser(), cset.getDate().toString());
    if (!complete && verbose) {
      final List<Path> files = cset.getAffectedFiles();
View Full Code Here

    HgPhase[] expected = readPhases(repo);
    ArrayList<Nodeid> secret = new ArrayList<Nodeid>();
    ArrayList<Nodeid> draft = new ArrayList<Nodeid>();
    ArrayList<Nodeid> pub = new ArrayList<Nodeid>();
    for (int i = 0; i < expected.length; i++) {
      Nodeid n = repo.getChangelog().getRevision(i);
      switch (expected[i]) {
      case Secret : secret.add(n); break;
      case Draft : draft.add(n); break;
      case Public : pub.add(n); break;
      default : throw new IllegalStateException();
View Full Code Here

    HgRepository hgRepo = new HgLookup().detect(repoLoc);
    CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), 0);
    HgDataFile df = hgRepo.getFileNode("file1");
    cf.add(df, new ByteArrayDataSource("hello\nworld".getBytes()));
    Transaction tr = newTransaction(hgRepo);
    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);
View Full Code Here

    HgDataFile df = hgRepo.getFileNode(fname);
    final byte[] initialContent = "hello\nworld".getBytes();
    cf.add(df, new ByteArrayDataSource(initialContent));
    String comment = "commit 1";
    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());
View Full Code Here

    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);
View Full Code Here

    CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), hgRepo.getChangelog().getLastRevision());
    FileContentSupplier contentProvider = new FileContentSupplier(hgRepo, new File(repoLoc, "xx"));
    cf.add(hgRepo.getFileNode("xx"), contentProvider);
    cf.forget(hgRepo.getFileNode("d"));
    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());
View Full Code Here

    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);
    //
    RepoUtils.modifyFileAppend(fileD, " 2 \n");
    cf.add(dfD, contentProvider = new FileContentSupplier(hgRepo, fileD));
    cf.branch("branch2");
    Nodeid commitRev2 = cf.commit("SECOND",  tr);
    //
    RepoUtils.modifyFileAppend(fileD, " 2 \n");
    cf.add(dfD, contentProvider = new FileContentSupplier(hgRepo, fileD));
    cf.branch(DEFAULT_BRANCH_NAME);
    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);
View Full Code Here

    HgCommitCommand cmd = new HgCommitCommand(hgRepo);
    assertFalse(cmd.isMergeCommit());
    Outcome r = cmd.message("FIRST").execute();
    errorCollector.assertTrue(r.isOk());
    Nodeid c1 = cmd.getCommittedRevision();
   
    // check that modified files are no longer reported as such
    TestStatus.StatusCollector status = new TestStatus.StatusCollector();
    new HgStatusCommand(hgRepo).all().execute(status);
    errorCollector.assertTrue(status.getErrors().isEmpty());
    errorCollector.assertTrue(status.get(Kind.Modified).isEmpty());
    errorCollector.assertEquals(1, status.get(dfB.getPath()).size());
    errorCollector.assertTrue(status.get(dfB.getPath()).contains(Kind.Clean));
   
    HgDataFile dfD = hgRepo.getFileNode("d");
    assertTrue("[sanity]", dfD.exists());
    File fileD = new File(repoLoc, "d");
    assertTrue("[sanity]", fileD.canRead());
    //
    RepoUtils.modifyFileAppend(fileD, " 1 \n");
    cmd = new HgCommitCommand(hgRepo);
    assertFalse(cmd.isMergeCommit());
    r = cmd.message("SECOND").execute();
    errorCollector.assertTrue(r.isOk());
    Nodeid c2 = cmd.getCommittedRevision();
    //
    errorCollector.assertEquals("SECOND", hgRepo.getCommitLastMessage());
    //
    int lastRev = hgRepo.getChangelog().getLastRevision();
    List<HgChangeset> csets = new HgLogCommand(hgRepo).range(lastRev-1, lastRev).execute();
View Full Code Here

TOP

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

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.