Package org.tmatesoft.hg.internal

Examples of org.tmatesoft.hg.internal.ByteArrayChannel


  }

  private void testReadWorkingCopy() throws Exception {
    for (String fname : cmdLineOpts.getList("")) {
      HgDataFile fn = hgRepo.getFileNode(fname);
      ByteArrayChannel sink = new ByteArrayChannel();
      fn.workingCopy(sink);
      System.out.printf("%s: read %d bytes of working copy", fname, sink.toArray().length);
    }
  }
View Full Code Here


      System.out.println();
    }
  }
 
  private static String formatFileRevision(HgFileRevision r) throws Exception {
    final ByteArrayChannel sink = new ByteArrayChannel();
    r.putContentTo(sink);
    return String.format("%s %s (%d bytes)", r.getPath(), r.getRevision(), sink.toArray().length);
  }
View Full Code Here

  private void inflaterLengthException() throws Exception {
    HgDataFile f1 = hgRepo.getFileNode("src/com/tmate/hgkit/console/Bundle.java");
    HgDataFile f2 = hgRepo.getFileNode("test-repos.jar");
    System.out.println(f1.isCopy());
    System.out.println(f2.isCopy());
    ByteArrayChannel bac = new ByteArrayChannel();
    f1.content(1, bac); // 0: 1151, 1: 1139
    System.out.println(bac.toArray().length);
    f2.content(0, bac = new ByteArrayChannel()); // 0: 14269
    System.out.println(bac.toArray().length);
  }
View Full Code Here

      HgDataFile fn = hgRepo.getFileNode(fname);
      if (fn.exists()) {
        int total = fn.getRevisionCount();
        System.out.printf("Total revisions: %d\n", total);
        for (int i = 0; i < total; i++) {
          ByteArrayChannel sink = new ByteArrayChannel();
          fn.content(i, sink);
          System.out.println("==========>");
          byte[] content = sink.toArray();
          System.out.println(new String(content));
          int[] parentRevisions = new int[2];
          byte[] parent1 = new byte[20];
          byte[] parent2 = new byte[20];
          fn.parents(i, parentRevisions, parent1, parent2);
View Full Code Here

    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

    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

    errorCollector.assertTrue(status.getErrors().isEmpty());
    errorCollector.assertTrue(status.get(Kind.Added).isEmpty());
    errorCollector.assertTrue(status.get(newFileNode.getPath()).contains(Kind.Clean));
    //
    errorCollector.assertTrue(newFileNode.exists());
    final ByteArrayChannel read1 = new ByteArrayChannel();
    newFileNode.content(0, read1);
    errorCollector.assertEquals("Read from existing HgDataFile instance", newFileContent, read1.toArray());
    final ByteArrayChannel read2 = new ByteArrayChannel();
    hgRepo.getFileNode(newFileNode.getPath()).content(0, read2);
    errorCollector.assertEquals("Read from fresh HgDataFile instance", newFileContent, read2.toArray());
  }
View Full Code Here

            } else {
              final Nodeid base = ge.firstParent();
              if (!changelog.isKnown(base) /*only first parent, that's Bundle contract*/) {
                throw new IllegalStateException(String.format("Revision %s needs a parent %s, which is missing in the supplied repo %s", ge.node().shortNotation(), base.shortNotation(), hgRepo.toString()));
              }
              ByteArrayChannel bac = new ByteArrayChannel();
              changelog.rawContent(base, bac); // TODO post-1.0 get DataAccess directly, to avoid
              // extra byte[] (inside ByteArrayChannel) duplication just for the sake of subsequent ByteArrayDataChannel wrap.
              prevRevContent = new ByteArrayDataAccess(bac.toArray());
            }
          }
          //
          byte[] csetContent = ge.patch().apply(prevRevContent, -1);
          dh = dh.sha1(ge.firstParent(), ge.secondParent(), csetContent); // XXX ge may give me access to byte[] content of nodeid directly, perhaps, I don't need DH to be friend of Nodeid?
View Full Code Here

    HgCatCommand cmd = new HgCatCommand(repo);
    final Path file = Path.create("src/org/tmatesoft/hg/internal/RevlogStream.java");
    cmd.file(file);
    final Nodeid cset = Nodeid.fromAscii("08db726a0fb7914ac9d27ba26dc8bbf6385a0554");
    cmd.changeset(cset);
    final ByteArrayChannel sink = new ByteArrayChannel();
    cmd.execute(sink);
    final int result1 = sink.toArray().length;
    HgChangesetFileSneaker i = new HgChangesetFileSneaker(repo);
    boolean result = i.changeset(cset).checkExists(file);
    assertFalse(result);
    assertFalse(i.exists());
    result = i.followRenames(true).checkExists(file);
    assertTrue(result);
    assertTrue(i.exists());
    HgCatCommand cmd2 = new HgCatCommand(repo).revision(i.getFileRevision());
    final ByteArrayChannel sink2 = new ByteArrayChannel();
    cmd2.execute(sink2);
    final int result2 = sink2.toArray().length;
    assertEquals(result1, result2);
  }
View Full Code Here

    repo = Configuration.get().find("log-renames");
    HgCatCommand cmd1 = new HgCatCommand(repo);
    HgCatCommand cmd2 = new HgCatCommand(repo);
    cmd1.file(Path.create("a")); // a is initial b through temporary c
    cmd2.file(Path.create("c"));
    ByteArrayChannel sink1, sink2;
    // a from wc/tip was c in rev 4
    cmd1.changeset(4).execute(sink1 = new ByteArrayChannel());
    cmd2.changeset(4).execute(sink2 = new ByteArrayChannel());
    assertArrayEquals(sink2.toArray(), sink1.toArray());
    //
    // d from wc/tip was a in 0..2 and b in rev 3..4. Besides, there's another d in r4
    cmd2.file(Path.create("d"));
    cmd1.changeset(2).execute(sink1 = new ByteArrayChannel());
    cmd2.changeset(2).execute(sink2 = new ByteArrayChannel());
    assertArrayEquals(sink1.toArray(), sink2.toArray());
    //
    cmd1.file(Path.create("b"));
    cmd1.changeset(3).execute(sink1 = new ByteArrayChannel());
    cmd2.changeset(3).execute(sink2 = new ByteArrayChannel());
    assertArrayEquals(sink1.toArray(), sink2.toArray());
    //
    cmd2.changeset(4).execute(sink2 = new ByteArrayChannel()); // ensure d in r4 is not from a or b
    assertArrayEquals("d:4\n".getBytes(), sink2.toArray());
    cmd2.changeset(5).execute(sink2 = new ByteArrayChannel()); // d in r5 is copy of b in r4
    cmd1.changeset(4).execute(sink1 = new ByteArrayChannel());
    assertArrayEquals(sink1.toArray(), sink2.toArray());
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.internal.ByteArrayChannel

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.