Package org.tmatesoft.hg.internal

Examples of org.tmatesoft.hg.internal.ByteArrayChannel.toArray()


  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);
    }
  }
 
  private void testParents() throws Exception {
    // hg parents cmd
View Full Code Here


  }
 
  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);
  }
 
  private void testFileStatus() throws Exception {
//    final Path path = Path.create("src/org/tmatesoft/hg/util/");
//    final Path path = Path.create("src/org/tmatesoft/hg/internal/Experimental.java");
View Full Code Here

    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);
  }
 
  private void dumpIgnored() throws HgInvalidControlFileException {
View Full Code Here

    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);
  }
 
  private void dumpIgnored() throws HgInvalidControlFileException {
    String[] toCheck = new String[] {"design.txt", "src/com/tmate/hgkit/ll/Changelog.java", "src/Extras.java", "bin/com/tmate/hgkit/ll/Changelog.class"};
    HgIgnore ignore = hgRepo.getIgnore();
View Full Code Here

        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(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());
  }
 
  @Test
  public void testCommitIntoBranch() throws Exception {
    File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-commit2branch", false);
View Full Code Here

    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);
  }
  /**
   * perform few commits one by one, into different branches
View Full Code Here

    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

    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());
  }
 
  @Test
  public void testRollback() throws Exception {
    // Important: copy, not a clone of a repo to ensure old timestamps
View Full Code Here

                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

TOP
Copyright © 2018 www.massapi.com. 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.